diff options
author | Martin v. Löwis <martin@v.loewis.de> | 2001-08-11 15:02:57 (GMT) |
---|---|---|
committer | Martin v. Löwis <martin@v.loewis.de> | 2001-08-11 15:02:57 (GMT) |
commit | 58682b7fe53d9bf7fefea59413d47ddd3c9a7d5f (patch) | |
tree | 900facacfa724e3b211ffb331c6d586e453de606 /Lib | |
parent | f3456912e46ba74233e219a94f48e29c85280abc (diff) | |
download | cpython-58682b7fe53d9bf7fefea59413d47ddd3c9a7d5f.zip cpython-58682b7fe53d9bf7fefea59413d47ddd3c9a7d5f.tar.gz cpython-58682b7fe53d9bf7fefea59413d47ddd3c9a7d5f.tar.bz2 |
Only catch the errors that can actually occur, as reported in bug #411881.
Diffstat (limited to 'Lib')
-rw-r--r-- | Lib/types.py | 10 | ||||
-rw-r--r-- | Lib/urllib.py | 4 |
2 files changed, 9 insertions, 5 deletions
diff --git a/Lib/types.py b/Lib/types.py index 742b8cc..01af463 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 diff --git a/Lib/urllib.py b/Lib/urllib.py index 82b5fb9..f60a841 100644 --- a/Lib/urllib.py +++ b/Lib/urllib.py @@ -134,7 +134,7 @@ class URLopener: for file in self.__tempfiles: try: self.__unlink(file) - except: + except OSError: pass del self.__tempfiles[:] if self.tempcache: @@ -1069,7 +1069,7 @@ def unquote(s): try: myappend(mychr(myatoi(item[:2], 16)) + item[2:]) - except: + except ValueError: myappend('%' + item) else: myappend('%' + item) |