[pypy-svn] pypy fast-forward: Redo 1de01c8ed895 a bit differently in a more backward-compatible way.

amauryfa commits-noreply at bitbucket.org
Thu Jan 6 18:40:53 CET 2011


Author: Amaury Forgeot d'Arc <amauryfa at gmail.com>
Branch: fast-forward
Changeset: r40421:408fee8771cc
Date: 2011-01-06 18:29 +0100
http://bitbucket.org/pypy/pypy/changeset/408fee8771cc/

Log:	Redo 1de01c8ed895 a bit differently in a more backward-compatible
	way.

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,8 +1095,7 @@
                 if not e.match(space, space.w_UnicodeError):
                     raise
                 # UnicodeError in literal: turn into SyntaxError
-                message = space.str_w(space.str(e.get_w_value(space)))
-                self.error("%s: %s" % (e.w_type, message), atom_node)
+                self.error(e.errorstr(space, use_str=True), atom_node)
                 sub_strings_w = [] # please annotator
             # This implements implicit string concatenation.
             if len(sub_strings_w) > 1:

diff --git a/pypy/interpreter/error.py b/pypy/interpreter/error.py
--- a/pypy/interpreter/error.py
+++ b/pypy/interpreter/error.py
@@ -56,7 +56,7 @@
             s = self._compute_value()
         return '[%s: %s]' % (self.w_type, s)
 
-    def errorstr(self, space):
+    def errorstr(self, space, use_str=False):
         "The exception class and value, as a string."
         w_value = self.get_w_value(space)
         if space is None:
@@ -74,7 +74,10 @@
                 exc_value = ""
             else:
                 try:
-                    exc_value = space.str_w(space.repr(w_value))
+                    if use_str:
+                        exc_value = space.str_w(space.str(w_value))
+                    else:
+                        exc_value = space.str_w(space.repr(w_value))
                 except OperationError:
                     # oups, cannot __str__ the exception object
                     exc_value = "<oups, exception object itself cannot be str'd>"
@@ -230,8 +233,8 @@
                 objrepr = space.str_w(space.repr(w_object))
             except OperationError:
                 objrepr = '?'
-        msg = 'Exception %s in %s%s ignored\n' % (self.errorstr(space),
-                                                  where, objrepr)
+        msg = 'Exception %s in %s%s ignored\n' % (
+            self.errorstr(space, use_str=True), where, objrepr)
         try:
             space.call_method(space.sys.get('stderr'), 'write', space.wrap(msg))
         except OperationError:


More information about the Pypy-commit mailing list