mirror of
https://github.com/python/cpython
synced 2026-09-28 07:38:20 +03:00
Only catch the errors that can actually occur, as reported in bug #411881.
This commit is contained in:
parent
f3456912e4
commit
58682b7fe5
2 changed files with 9 additions and 5 deletions
10
Lib/types.py
10
Lib/types.py
|
|
@ -31,7 +31,8 @@ FunctionType = type(_f)
|
||||||
LambdaType = type(lambda: None) # Same as FunctionType
|
LambdaType = type(lambda: None) # Same as FunctionType
|
||||||
try:
|
try:
|
||||||
CodeType = type(_f.func_code)
|
CodeType = type(_f.func_code)
|
||||||
except:
|
except RuntimeError:
|
||||||
|
# Execution in restricted environment
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def g():
|
def g():
|
||||||
|
|
@ -54,7 +55,8 @@ ModuleType = type(sys)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
FileType = type(sys.__stdin__)
|
FileType = type(sys.__stdin__)
|
||||||
except:
|
except AttributeError:
|
||||||
|
# Not available in restricted mode
|
||||||
pass
|
pass
|
||||||
XRangeType = type(xrange(0))
|
XRangeType = type(xrange(0))
|
||||||
|
|
||||||
|
|
@ -65,7 +67,9 @@ except TypeError:
|
||||||
tb = sys.exc_info()[2]
|
tb = sys.exc_info()[2]
|
||||||
TracebackType = type(tb)
|
TracebackType = type(tb)
|
||||||
FrameType = type(tb.tb_frame)
|
FrameType = type(tb.tb_frame)
|
||||||
except:
|
except AttributeError:
|
||||||
|
# In the restricted environment, exc_info returns (None, None,
|
||||||
|
# None) Then, tb.tb_frame gives an attribute error
|
||||||
pass
|
pass
|
||||||
tb = None; del tb
|
tb = None; del tb
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -134,7 +134,7 @@ class URLopener:
|
||||||
for file in self.__tempfiles:
|
for file in self.__tempfiles:
|
||||||
try:
|
try:
|
||||||
self.__unlink(file)
|
self.__unlink(file)
|
||||||
except:
|
except OSError:
|
||||||
pass
|
pass
|
||||||
del self.__tempfiles[:]
|
del self.__tempfiles[:]
|
||||||
if self.tempcache:
|
if self.tempcache:
|
||||||
|
|
@ -1069,7 +1069,7 @@ def unquote(s):
|
||||||
try:
|
try:
|
||||||
myappend(mychr(myatoi(item[:2], 16))
|
myappend(mychr(myatoi(item[:2], 16))
|
||||||
+ item[2:])
|
+ item[2:])
|
||||||
except:
|
except ValueError:
|
||||||
myappend('%' + item)
|
myappend('%' + item)
|
||||||
else:
|
else:
|
||||||
myappend('%' + item)
|
myappend('%' + item)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue