when contain an id in form " at 0x...".
self._handle = handle
def __repr__(self):
- return "<%s '%s', handle %x at %x>" % \
+ return "<%s '%s', handle %x at %#x>" % \
(self.__class__.__name__, self._name,
(self._handle & (_sys.maxsize*2 + 1)),
id(self) & (_sys.maxsize*2 + 1))
# Bugs in x.__repr__() can cause arbitrary
# exceptions -- then make up something
except Exception:
- return '<%s instance at %x>' % (x.__class__.__name__, id(x))
+ return '<%s instance at %#x>' % (x.__class__.__name__, id(x))
if len(s) > self.maxother:
i = max(0, (self.maxother-3)//2)
j = max(0, self.maxother-3-i)
eq(r(i2), expected)
i3 = ClassWithFailingRepr()
- eq(r(i3), ("<ClassWithFailingRepr instance at %x>"%id(i3)))
+ eq(r(i3), ("<ClassWithFailingRepr instance at %#x>"%id(i3)))
s = r(ClassWithFailingRepr)
self.assertTrue(s.startswith("<class "))
self.assertEqual(len(d), 0)
self.assertEqual(count, 2)
+ def test_make_weak_valued_dict_repr(self):
+ dict = weakref.WeakValueDictionary()
+ self.assertRegex(repr(dict), '<WeakValueDictionary at 0x.*>')
+
+ def test_make_weak_keyed_dict_repr(self):
+ dict = weakref.WeakKeyDictionary()
+ self.assertRegex(repr(dict), '<WeakKeyDictionary at 0x.*>')
+
from test import mapping_tests
class WeakValueDictionaryTestCase(mapping_tests.BasicTestMappingProtocol):
def test_repr(self):
d = datetime.datetime(2007,1,2,3,4,5)
t = xmlrpclib.DateTime(d)
- val ="<DateTime '20070102T03:04:05' at %x>" % id(t)
+ val ="<DateTime '20070102T03:04:05' at %#x>" % id(t)
self.assertEqual(repr(t), val)
def test_decode(self):
return o is not None
def __repr__(self):
- return "<WeakValueDictionary at %s>" % id(self)
+ return "<WeakValueDictionary at %#x>" % id(self)
def __setitem__(self, key, value):
if self._pending_removals:
return len(self.data) - len(self._pending_removals)
def __repr__(self):
- return "<WeakKeyDictionary at %s>" % id(self)
+ return "<WeakKeyDictionary at %#x>" % id(self)
def __setitem__(self, key, value):
self.data[ref(key, self._remove)] = value
return self.value
def __repr__(self):
- return "<DateTime %r at %x>" % (self.value, id(self))
+ return "<DateTime %r at %#x>" % (self.value, id(self))
def decode(self, data):
self.value = str(data).strip()
self.__call_list = []
def __repr__(self):
- return "<MultiCall at %x>" % id(self)
+ return "<MultiCall at %#x>" % id(self)
__str__ = __repr__
Library
-------
+- Issue #22031: Reprs now always use hexadecimal format with the "0x" prefix
+ when contain an id in form " at 0x...".
+
- Issue #22018: signal.set_wakeup_fd() now raises an OSError instead of a
ValueError on ``fstat()`` failure.