summaryrefslogtreecommitdiff
path: root/Lib/types.py
diff options
context:
space:
mode:
authorMartin v. Löwis <martin@v.loewis.de>2001-08-11 15:02:57 +0000
committerMartin v. Löwis <martin@v.loewis.de>2001-08-11 15:02:57 +0000
commitb82f1d3a85e3fa46085a754712ed8aae4bb2e78a (patch)
treeb299abaa35ec422d9fc9807c40c39e2da7fa8d7e /Lib/types.py
parent0f7767d64ec04baeedd0396152fdd91a7a31ec50 (diff)
downloadcpython-b82f1d3a85e3fa46085a754712ed8aae4bb2e78a.tar.gz
Only catch the errors that can actually occur, as reported in bug #411881.
Diffstat (limited to 'Lib/types.py')
-rw-r--r--Lib/types.py10
1 files changed, 7 insertions, 3 deletions
diff --git a/Lib/types.py b/Lib/types.py
index 742b8cc5ff..01af463640 100644
--- a/Lib/types.py
+++ b/Lib/types.py
@@ -31,7 +31,8 @@ FunctionType = type(_f)
LambdaType = type(lambda: None) # Same as FunctionType
try:
CodeType = type(_f.func_code)
-except:
+except RuntimeError:
+ # Execution in restricted environment
pass
def g():
@@ -54,7 +55,8 @@ ModuleType = type(sys)
try:
FileType = type(sys.__stdin__)
-except:
+except AttributeError:
+ # Not available in restricted mode
pass
XRangeType = type(xrange(0))
@@ -65,7 +67,9 @@ except TypeError:
tb = sys.exc_info()[2]
TracebackType = type(tb)
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
tb = None; del tb