Author: Philip Jenvey <[email protected]>
Branch:
Changeset: r65724:2d035ae827dd
Date: 2013-07-27 15:29 -0700
http://bitbucket.org/pypy/pypy/changeset/2d035ae827dd/
Log: more %N for the sake of py3k
diff --git a/pypy/interpreter/function.py b/pypy/interpreter/function.py
--- a/pypy/interpreter/function.py
+++ b/pypy/interpreter/function.py
@@ -414,8 +414,8 @@
closure_len = len(self.closure)
if isinstance(code, PyCode) and closure_len != len(code.co_freevars):
raise operationerrfmt(space.w_ValueError,
- "%s() requires a code object with %d free vars, not %d",
- self.name, closure_len, len(code.co_freevars))
+ "%N() requires a code object with %d free vars, not %d",
+ self, closure_len, len(code.co_freevars))
self.fget_func_doc(space) # see test_issue1293
self.code = code
@@ -482,7 +482,6 @@
space.abstract_isinstance_w(w_firstarg, self.w_class)):
pass # ok
else:
- myname = self.getname(space, "")
clsdescr = self.w_class.getname(space, "")
if clsdescr:
clsdescr += " instance"
@@ -497,10 +496,10 @@
instdescr = instname + " instance"
else:
instdescr = "instance"
- msg = ("unbound method %s() must be called with %s "
+ msg = ("unbound method %N() must be called with %s "
"as first argument (got %s instead)")
raise operationerrfmt(space.w_TypeError, msg,
- myname, clsdescr, instdescr)
+ self, clsdescr, instdescr)
return space.call_args(self.w_function, args)
def descr_method_get(self, w_obj, w_cls=None):
diff --git a/pypy/interpreter/typedef.py b/pypy/interpreter/typedef.py
--- a/pypy/interpreter/typedef.py
+++ b/pypy/interpreter/typedef.py
@@ -553,9 +553,9 @@
def typecheck(self, space, w_obj):
if not space.isinstance_w(w_obj, self.w_cls):
- m = "descriptor '%s' for '%s' objects doesn't apply to '%T' object"
+ m = "descriptor '%N' for '%N' objects doesn't apply to '%T' object"
raise operationerrfmt(space.w_TypeError, m,
- self.name, self.w_cls.name, w_obj)
+ self, self.w_cls, w_obj)
def descr_member_get(self, space, w_obj, w_cls=None):
"""member.__get__(obj[, type]) -> value
diff --git a/pypy/objspace/std/dictproxyobject.py
b/pypy/objspace/std/dictproxyobject.py
--- a/pypy/objspace/std/dictproxyobject.py
+++ b/pypy/objspace/std/dictproxyobject.py
@@ -98,8 +98,8 @@
space = self.space
w_type = self.unerase(w_dict.dstorage)
if not w_type.is_heaptype():
- msg = "can't clear dictionary of type '%s'"
- raise operationerrfmt(space.w_TypeError, msg, w_type.name)
+ msg = "can't clear dictionary of type '%N'"
+ raise operationerrfmt(space.w_TypeError, msg, w_type)
w_type.dict_w.clear()
w_type.mutated(None)
diff --git a/pypy/objspace/std/typeobject.py b/pypy/objspace/std/typeobject.py
--- a/pypy/objspace/std/typeobject.py
+++ b/pypy/objspace/std/typeobject.py
@@ -265,8 +265,8 @@
def setdictvalue(w_self, space, name, w_value):
if not w_self.is_heaptype():
- msg = "can't set attributes on type object '%s'"
- raise operationerrfmt(space.w_TypeError, msg, w_self.name)
+ msg = "can't set attributes on type object '%N'"
+ raise operationerrfmt(space.w_TypeError, msg, w_self)
if name == "__del__" and name not in w_self.dict_w:
msg = ("a __del__ method added to an existing type will not be "
"called")
@@ -289,8 +289,8 @@
if w_self.lazyloaders:
w_self._cleanup_() # force un-lazification
if not w_self.is_heaptype():
- msg = "can't delete attributes on type object '%s'"
- raise operationerrfmt(space.w_TypeError, msg, w_self.name)
+ msg = "can't delete attributes on type object '%N'"
+ raise operationerrfmt(space.w_TypeError, msg, w_self)
try:
del w_self.dict_w[key]
except KeyError:
@@ -417,12 +417,12 @@
w_subtype)
if not w_subtype.issubtype(w_self):
raise operationerrfmt(space.w_TypeError,
- "%s.__new__(%s): %s is not a subtype of %s",
- w_self.name, w_subtype.name, w_subtype.name, w_self.name)
+ "%N.__new__(%N): %N is not a subtype of %N",
+ w_self, w_subtype, w_subtype, w_self)
if w_self.instancetypedef is not w_subtype.instancetypedef:
raise operationerrfmt(space.w_TypeError,
- "%s.__new__(%s) is not safe, use %s.__new__()",
- w_self.name, w_subtype.name, w_subtype.name)
+ "%N.__new__(%N) is not safe, use %N.__new__()",
+ w_self, w_subtype, w_subtype)
return w_subtype
def _cleanup_(w_self):
@@ -630,7 +630,7 @@
w_type = _check(space, w_type)
if not w_type.is_heaptype():
raise operationerrfmt(space.w_TypeError,
- "can't set %s.__name__", w_type.name)
+ "can't set %N.__name__", w_type)
w_type.name = space.str_w(w_value)
def descr_get__mro__(space, w_type):
@@ -662,16 +662,16 @@
w_type = _check(space, w_type)
if not w_type.is_heaptype():
raise operationerrfmt(space.w_TypeError,
- "can't set %s.__bases__", w_type.name)
+ "can't set %N.__bases__", w_type)
if not space.isinstance_w(w_value, space.w_tuple):
raise operationerrfmt(space.w_TypeError,
- "can only assign tuple to %s.__bases__, not %T",
- w_type.name, w_value)
+ "can only assign tuple to %N.__bases__, not %T",
+ w_type, w_value)
newbases_w = space.fixedview(w_value)
if len(newbases_w) == 0:
raise operationerrfmt(space.w_TypeError,
- "can only assign non-empty tuple to %s.__bases__, not ()",
- w_type.name)
+ "can only assign non-empty tuple to %N.__bases__, not ()",
+ w_type)
for w_newbase in newbases_w:
if isinstance(w_newbase, W_TypeObject):
@@ -884,9 +884,9 @@
"only classic bases"))
if not w_bestbase.instancetypedef.acceptable_as_base_class:
raise operationerrfmt(space.w_TypeError,
- "type '%s' is not an "
+ "type '%N' is not an "
"acceptable base class",
- w_bestbase.instancetypedef.name)
+ w_bestbase)
# check that all other bases' layouts are superclasses of the bestbase
w_bestlayout = w_bestbase.w_same_layout_as or w_bestbase
@@ -1136,8 +1136,8 @@
if w_descr is not None:
return space.get(w_descr, w_type)
raise operationerrfmt(space.w_AttributeError,
- "type object '%s' has no attribute '%s'",
- w_type.name, name)
+ "type object '%N' has no attribute %R",
+ w_type, w_name)
def eq__Type_Type(space, w_self, w_other):
return space.is_(w_self, w_other)
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit