large 32 bit int, which comes out as a negative int. Workaround this to
prevent warnings from the test suite.
__all__ = ["Repr","repr"]
+import sys
+
class Repr:
def __init__(self):
self.maxlevel = 6
# Bugs in x.__repr__() can cause arbitrary
# exceptions -- then make up something
except:
- return '<' + x.__class__.__name__ + ' instance at ' + \
- hex(id(x))[2:] + '>'
+ # On some systems (RH10) id() can be a negative number.
+ # work around this.
+ MAX = 2L*sys.maxint+1
+ return '<' + x.__class__.__name__ + ' instance at %x>'%(id(x)&MAX)
if len(s) > self.maxstring:
i = max(0, (self.maxstring-3)//2)
j = max(0, self.maxstring-3-i)
eq(r(i2), expected)
i3 = ClassWithFailingRepr()
- eq(r(i3), ("<ClassWithFailingRepr instance at %x>"%id(i3)))
+ # On some systems (RH10) id() can be a negative number.
+ # work around this.
+ MAX = 2L*sys.maxint+1
+ eq(r(i3), ("<ClassWithFailingRepr instance at %x>"%(id(i3)&MAX)))
s = r(ClassWithFailingRepr)
self.failUnless(s.startswith("<class "))