]> granicus.if.org Git - python/commitdiff
remove unqualified excepts - catch ImportError when trying to import
authorSkip Montanaro <skip@pobox.com>
Mon, 25 Mar 2002 21:44:07 +0000 (21:44 +0000)
committerSkip Montanaro <skip@pobox.com>
Mon, 25 Mar 2002 21:44:07 +0000 (21:44 +0000)
readline and get rid of string exception fallback when showing syntax
errors.
see bug 411881

Lib/code.py

index ad42a9b1e6e184f3a22e59d6f9c904d86c7d24cd..64b7bc086b77fc8b0e25b9f319e902fa5f3260fb 100644 (file)
@@ -133,12 +133,7 @@ class InteractiveInterpreter:
                 pass
             else:
                 # Stuff in the right filename
-                try:
-                    # Assume SyntaxError is a class exception
-                    value = SyntaxError(msg, (filename, lineno, offset, line))
-                except:
-                    # If that failed, assume SyntaxError is a string
-                    value = msg, (filename, lineno, offset, line)
+                value = SyntaxError(msg, (filename, lineno, offset, line))
                 sys.last_value = value
         list = traceback.format_exception_only(type, value)
         map(self.write, list)
@@ -302,7 +297,7 @@ def interact(banner=None, readfunc=None, local=None):
     else:
         try:
             import readline
-        except:
+        except ImportError:
             pass
     console.interact(banner)