[Python-checkins] r54036 - python/branches/p3yk_no_args_on_exc/Lib/codeop.py

brett.cannon python-checkins at python.org
Wed Feb 28 21:51:05 CET 2007

Author: brett.cannon
Date: Wed Feb 28 21:51:03 2007
New Revision: 54036

Fix codeop to compare against all attributes of the exception instead of just
its repr since it no longer properly reflects all fields of the exception.
Better solution would probably be to write a custom __eq__ the compares the
attributes or something.

Modified: python/branches/p3yk_no_args_on_exc/Lib/codeop.py
--- python/branches/p3yk_no_args_on_exc/Lib/codeop.py	(original)
+++ python/branches/p3yk_no_args_on_exc/Lib/codeop.py	Wed Feb 28 21:51:03 2007
@@ -95,8 +95,13 @@
     if code:
         return code
-    if not code1 and repr(err1) == repr(err2):
-        raise SyntaxError, err1
+    if not code1:
+        for attr in ('message', 'msg', 'filename', 'lineno', 'offset',
+                        'print_file_and_line', 'text'):
+            if getattr(err1, attr) != getattr(err2, attr):
+                break
+        else:
+            raise SyntaxError(err1)
 def _compile(source, filename, symbol):
     return compile(source, filename, symbol, PyCF_DONT_IMPLY_DEDENT)

More information about the Python-checkins mailing list