[pypy-svn] pypy fast-forward: More uniform error handling

amauryfa commits-noreply at bitbucket.org
Tue Jan 4 19:37:54 CET 2011


Author: Amaury Forgeot d'Arc <amauryfa at gmail.com>
Branch: fast-forward
Changeset: r40393:3b843b81c6e6
Date: 2011-01-04 19:36 +0100
http://bitbucket.org/pypy/pypy/changeset/3b843b81c6e6/

Log:	More uniform error handling

diff --git a/pypy/interpreter/astcompiler/astbuilder.py b/pypy/interpreter/astcompiler/astbuilder.py
--- a/pypy/interpreter/astcompiler/astbuilder.py
+++ b/pypy/interpreter/astcompiler/astbuilder.py
@@ -1095,7 +1095,8 @@
                 if not e.match(space, space.w_UnicodeError):
                     raise
                 # UnicodeError in literal: turn into SyntaxError
-                self.error(e.errorstr(space), atom_node)
+                message = space.str_w(space.str(e.get_w_value(space)))
+                self.error("%s: %s" % (e.w_type, message), atom_node)
                 sub_strings_w = [] # please annotator
             # This implements implicit string concatenation.
             if len(sub_strings_w) > 1:

diff --git a/pypy/interpreter/pyparser/pyparse.py b/pypy/interpreter/pyparser/pyparse.py
--- a/pypy/interpreter/pyparser/pyparse.py
+++ b/pypy/interpreter/pyparser/pyparse.py
@@ -122,11 +122,11 @@
                     # check using 'is_w' not to mask potential IndexError or
                     # KeyError
                     space = self.space
-                    if space.is_w(e.w_type, space.w_LookupError):
+                    if e.match(space, space.w_LookupError):
                         raise error.SyntaxError("Unknown encoding: %s" % enc,
                                                 filename=compile_info.filename)
                     # Transform unicode errors into SyntaxError
-                    if space.is_w(e.w_type, space.w_UnicodeDecodeError):
+                    if e.match(space, space.w_UnicodeDecodeError):
                         e.normalize_exception(space)
                         w_message = space.str(e.get_w_value(space))
                         raise error.SyntaxError(space.str_w(w_message))


More information about the Pypy-commit mailing list