[pypy-commit] pypy default: Fix two more cases that could, in theory, give strange results if
arigo
noreply at buildbot.pypy.org
Thu Apr 19 20:00:34 CEST 2012
Author: Armin Rigo <arigo at tunes.org>
Branch:
Changeset: r54555:96124bafacbe
Date: 2012-04-19 19:59 +0200
http://bitbucket.org/pypy/pypy/changeset/96124bafacbe/
Log: Fix two more cases that could, in theory, give strange results if
'name' happens to be something else than a string (like some
method).
diff --git a/pypy/interpreter/function.py b/pypy/interpreter/function.py
--- a/pypy/interpreter/function.py
+++ b/pypy/interpreter/function.py
@@ -49,7 +49,9 @@
def __repr__(self):
# return "function %s.%s" % (self.space, self.name)
# maybe we want this shorter:
- name = getattr(self, 'name', '?')
+ name = getattr(self, 'name', None)
+ if not isinstance(name, str):
+ name = '?'
return "<%s %s>" % (self.__class__.__name__, name)
def call_args(self, args):
diff --git a/pypy/objspace/std/model.py b/pypy/objspace/std/model.py
--- a/pypy/objspace/std/model.py
+++ b/pypy/objspace/std/model.py
@@ -378,7 +378,10 @@
__slots__ = ()
def __repr__(self):
- s = '%s(%s)' % (self.__class__.__name__, getattr(self, 'name', ''))
+ name = getattr(self, 'name', '')
+ if not isinstance(name, str):
+ name = ''
+ s = '%s(%s)' % (self.__class__.__name__, name)
w_cls = getattr(self, 'w__class__', None)
if w_cls is not None and w_cls is not self:
s += ' instance of %s' % self.w__class__
More information about the pypy-commit
mailing list