[pypy-commit] pypy py3k: utilize %N/%T

pjenvey noreply at buildbot.pypy.org
Tue May 28 23:45:00 CEST 2013


Author: Philip Jenvey <pjenvey at underboss.org>
Branch: py3k
Changeset: r64641:1c0f22d3facb
Date: 2013-05-28 14:35 -0700
http://bitbucket.org/pypy/pypy/changeset/1c0f22d3facb/

Log:	utilize %N/%T

diff --git a/pypy/interpreter/pyopcode.py b/pypy/interpreter/pyopcode.py
--- a/pypy/interpreter/pyopcode.py
+++ b/pypy/interpreter/pyopcode.py
@@ -1428,13 +1428,13 @@
     if (not space.is_none(w_globals) and
         not space.isinstance_w(w_globals, space.w_dict)):
         raise operationerrfmt(space.w_TypeError,
-                              '%s() arg 2 must be a dict, not %s',
-                              funcname, space.type(w_globals).getname(space))
+                              '%s() arg 2 must be a dict, not %T',
+                              funcname, w_globals)
     if (not space.is_none(w_locals) and
         space.lookup(w_locals, '__getitem__') is None):
         raise operationerrfmt(space.w_TypeError,
-                              '%s() arg 3 must be a mapping or None, not %s',
-                              funcname, space.type(w_locals).getname(space))
+                              '%s() arg 3 must be a mapping or None, not %T',
+                              funcname, w_locals)
 
     if space.is_none(w_globals):
         if caller is None:
diff --git a/pypy/module/__builtin__/operation.py b/pypy/module/__builtin__/operation.py
--- a/pypy/module/__builtin__/operation.py
+++ b/pypy/module/__builtin__/operation.py
@@ -106,8 +106,8 @@
     round = space.lookup(w_number, '__round__')
     if round is None:
         raise operationerrfmt(space.w_TypeError,
-                              "type %s doesn't define __round__ method",
-                              space.type(w_number).getname(space))
+                              "type %T doesn't define __round__ method",
+                              w_number)
     if w_ndigits is None:
         return space.get_and_call_function(round, w_number)
     else:
diff --git a/pypy/module/_codecs/interp_codecs.py b/pypy/module/_codecs/interp_codecs.py
--- a/pypy/module/_codecs/interp_codecs.py
+++ b/pypy/module/_codecs/interp_codecs.py
@@ -331,9 +331,9 @@
             raise OperationError(space.type(w_exc), w_exc)
         return space.newtuple([space.wrap(unichr(ch)), space.wrap(start + 3)])
     else:
-        typename = space.type(w_exc).getname(space)
         raise operationerrfmt(space.w_TypeError,
-            "don't know how to handle %s in error callback", typename)
+                              "don't know how to handle %T in error callback",
+                              w_exc)
 
 def surrogateescape_errors(space, w_exc):
     check_exception(space, w_exc)
@@ -371,9 +371,9 @@
         return space.newtuple([space.wrap(replace),
                                space.wrap(start + consumed)])
     else:
-        typename = space.type(w_exc).getname(space)
         raise operationerrfmt(space.w_TypeError,
-            "don't know how to handle %s in error callback", typename)
+                              "don't know how to handle %s in error callback",
+                              w_exc)
 
 def register_builtin_error_handlers(space):
     "NOT_RPYTHON"
diff --git a/pypy/module/_io/interp_iobase.py b/pypy/module/_io/interp_iobase.py
--- a/pypy/module/_io/interp_iobase.py
+++ b/pypy/module/_io/interp_iobase.py
@@ -174,8 +174,7 @@
 
     def getstate_w(self, space):
         raise operationerrfmt(space.w_TypeError,
-                              "cannot serialize '%s' object",
-                              space.type(self).getname(space))
+                              "cannot serialize '%T' object", self)
 
     # ______________________________________________________________
 
diff --git a/pypy/objspace/descroperation.py b/pypy/objspace/descroperation.py
--- a/pypy/objspace/descroperation.py
+++ b/pypy/objspace/descroperation.py
@@ -244,10 +244,9 @@
         w_restype = space.type(w_res)
         # Note there is no check for bool here because the only possible
         # instances of bool are w_False and w_True, which are checked above.
-        typename = space.type(w_obj).getname(space)
         raise operationerrfmt(space.w_TypeError,
-                              "__bool__ should return bool, returned %s",
-                              typename)
+                              "__bool__ should return bool, returned %T",
+                              w_obj)
 
     def nonzero(space, w_obj):
         if space.is_true(w_obj):
@@ -479,10 +478,9 @@
     def buffer(space, w_obj):
         w_impl = space.lookup(w_obj, '__buffer__')
         if w_impl is None:
-            typename = space.type(w_obj).getname(space)
-            raise operationerrfmt(
-                space.w_TypeError, 
-                "'%s' does not support the buffer interface", typename)
+            raise operationerrfmt(space.w_TypeError,
+                                  "'%T' does not support the buffer interface",
+                                  w_obj)
         return space.get_and_call_function(w_impl, w_obj)
 
 
@@ -601,11 +599,8 @@
             return space.not_(space.eq(w_obj1, w_obj2))
         #
         # if we arrived here, they are unorderable
-        typename1 = space.type(w_obj1).getname(space)
-        typename2 = space.type(w_obj2).getname(space)
-        raise operationerrfmt(space.w_TypeError,
-                              "unorderable types: %s %s %s",
-                              typename1, symbol, typename2)
+        raise operationerrfmt(space.w_TypeError, "unorderable types: %T %s %T",
+                              w_obj1, symbol, w_obj2)
 
     return func_with_new_name(comparison_impl, 'comparison_%s_impl'%left.strip('_'))
 
diff --git a/pypy/objspace/std/bytearrayobject.py b/pypy/objspace/std/bytearrayobject.py
--- a/pypy/objspace/std/bytearrayobject.py
+++ b/pypy/objspace/std/bytearrayobject.py
@@ -257,9 +257,8 @@
     except OperationError as e:
         if e.match(space, space.w_TypeError):
             msg = ("%s first arg must be bytes or a tuple of bytes, "
-                   "not %s")
-            typename = space.type(w_suffix).getname(space)
-            raise operationerrfmt(space.w_TypeError, msg, funcname, typename)
+                   "not %T")
+            raise operationerrfmt(space.w_TypeError, msg, funcname, w_suffix)
 
 def str_startswith__Bytearray_ANY_ANY_ANY(space, w_bytearray, w_prefix, w_start, w_stop):
     if space.isinstance_w(w_prefix, space.w_tuple):
diff --git a/pypy/objspace/std/stringobject.py b/pypy/objspace/std/stringobject.py
--- a/pypy/objspace/std/stringobject.py
+++ b/pypy/objspace/std/stringobject.py
@@ -708,9 +708,8 @@
     except OperationError as e:
         if e.match(space, space.w_TypeError):
             msg = ("%s first arg must be bytes or a tuple of bytes, "
-                   "not %s")
-            typename = space.type(w_suffix).getname(space)
-            raise operationerrfmt(space.w_TypeError, msg, funcname, typename)
+                   "not %T")
+            raise operationerrfmt(space.w_TypeError, msg, funcname, w_suffix)
 
 def str_endswith__String_ANY_ANY_ANY(space, w_self, w_suffix, w_start, w_end):
     (u_self, start, end) = _convert_idx_params(space, w_self, w_start,
diff --git a/pypy/objspace/std/stringtype.py b/pypy/objspace/std/stringtype.py
--- a/pypy/objspace/std/stringtype.py
+++ b/pypy/objspace/std/stringtype.py
@@ -287,9 +287,8 @@
     if w_bytes_method is not None:
         w_bytes = space.get_and_call_function(w_bytes_method, w_source)
         if not space.isinstance_w(w_bytes, space.w_bytes):
-            msg = "__bytes__ returned non-bytes (type '%s')"
-            raise operationerrfmt(space.w_TypeError, msg,
-                                  space.type(w_bytes).getname(space))
+            msg = "__bytes__ returned non-bytes (type '%T')"
+            raise operationerrfmt(space.w_TypeError, msg, w_bytes)
         return [c for c in space.bytes_w(w_bytes)]
 
     # String-like argument
diff --git a/pypy/objspace/std/unicodeobject.py b/pypy/objspace/std/unicodeobject.py
--- a/pypy/objspace/std/unicodeobject.py
+++ b/pypy/objspace/std/unicodeobject.py
@@ -181,9 +181,8 @@
         except OperationError, e:
             if not e.match(space, space.w_TypeError):
                 raise
-            raise operationerrfmt(space.w_TypeError,
-                                  "sequence item %d: expected string, %s "
-                                  "found", i, space.type(w_s).getname(space))
+            msg = "sequence item %d: expected string, %T found"
+            raise operationerrfmt(space.w_TypeError, msg, i, w_s)
     sb = UnicodeBuilder(prealloc_size)
     for i in range(size):
         if self and i != 0:
@@ -467,10 +466,8 @@
 def unicode_startswith__Unicode_ANY_ANY_ANY(space, w_unistr, w_prefixes,
                                               w_start, w_end):
     if not space.isinstance_w(w_prefixes, space.w_tuple):
-        typename = space.type(w_prefixes).getname(space)
-        msg = ("startswith first arg must be str or a tuple of str, not %s" %
-               typename)
-        raise OperationError(space.w_TypeError, space.wrap(msg))
+        msg = "startswith first arg must be str or a tuple of str, not %T"
+        raise operationerrfmt(space.w_TypeError, msg, w_prefixes)
 
     unistr, start, end = _convert_idx_params(space, w_unistr,
                                              w_start, w_end, True)
@@ -483,9 +480,8 @@
 def unicode_endswith__Unicode_ANY_ANY_ANY(space, w_unistr, w_suffixes,
                                             w_start, w_end):
     if not space.isinstance_w(w_suffixes, space.w_tuple):
-        typename = space.type(w_suffixes).getname(space)
-        msg = "endswith first arg must be str or a tuple of str, not %s" % typename
-        raise OperationError(space.w_TypeError, space.wrap(msg))
+        msg = "endswith first arg must be str or a tuple of str, not %T"
+        raise operationerrfmt(space.w_TypeError, msg, w_suffixes)
 
     unistr, start, end = _convert_idx_params(space, w_unistr,
                                              w_start, w_end, True)


More information about the pypy-commit mailing list