| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -353,7 +353,7 @@ class _FuncPtr(_CFuncPtr): | |||
| 353 | 353 | self._handle = handle | |
| 354 | 354 | ||
| 355 | 355 | def __repr__(self): | |
| 356 | - return "<%s '%s', handle %x at %x>" % \ | ||
| 356 | + return "<%s '%s', handle %x at %#x>" % \ | ||
| 357 | 357 | (self.__class__.__name__, self._name, | |
| 358 | 358 | (self._handle & (_sys.maxsize*2 + 1)), | |
| 359 | 359 | id(self) & (_sys.maxsize*2 + 1)) | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -136,7 +136,7 @@ def repr_instance(self, x, level): | |||
| 136 | 136 | # Bugs in x.__repr__() can cause arbitrary | |
| 137 | 137 | # exceptions -- then make up something | |
| 138 | 138 | except Exception: | |
| 139 | - return '<%s instance at %x>' % (x.__class__.__name__, id(x)) | ||
| 139 | + return '<%s instance at %#x>' % (x.__class__.__name__, id(x)) | ||
| 140 | 140 | if len(s) > self.maxother: | |
| 141 | 141 | i = max(0, (self.maxother-3)//2) | |
| 142 | 142 | j = max(0, self.maxother-3-i) | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -123,7 +123,7 @@ def test_instance(self): | |||
| 123 | 123 | eq(r(i2), expected) | |
| 124 | 124 | ||
| 125 | 125 | i3 = ClassWithFailingRepr() | |
| 126 | - eq(r(i3), ("<ClassWithFailingRepr instance at %x>"%id(i3))) | ||
| 126 | + eq(r(i3), ("<ClassWithFailingRepr instance at %#x>"%id(i3))) | ||
| 127 | 127 | ||
| 128 | 128 | s = r(ClassWithFailingRepr) | |
| 129 | 129 | self.assertTrue(s.startswith("<class ")) | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1536,6 +1536,14 @@ def __eq__(self, other): | |||
| 1536 | 1536 | self.assertEqual(len(d), 0) | |
| 1537 | 1537 | self.assertEqual(count, 2) | |
| 1538 | 1538 | ||
| 1539 | + def test_make_weak_valued_dict_repr(self): | ||
| 1540 | + dict = weakref.WeakValueDictionary() | ||
| 1541 | + self.assertRegex(repr(dict), '<WeakValueDictionary at 0x.*>') | ||
| 1542 | + | ||
| 1543 | + def test_make_weak_keyed_dict_repr(self): | ||
| 1544 | + dict = weakref.WeakKeyDictionary() | ||
| 1545 | + self.assertRegex(repr(dict), '<WeakKeyDictionary at 0x.*>') | ||
| 1546 | + | ||
| 1539 | 1547 | from test import mapping_tests | |
| 1540 | 1548 | ||
| 1541 | 1549 | class WeakValueDictionaryTestCase(mapping_tests.BasicTestMappingProtocol): | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -287,7 +287,7 @@ def test_datetime_datetime(self): | |||
| 287 | 287 | def test_repr(self): | |
| 288 | 288 | d = datetime.datetime(2007,1,2,3,4,5) | |
| 289 | 289 | t = xmlrpclib.DateTime(d) | |
| 290 | - val ="<DateTime '20070102T03:04:05' at %x>" % id(t) | ||
| 290 | + val ="<DateTime '20070102T03:04:05' at %#x>" % id(t) | ||
| 291 | 291 | self.assertEqual(repr(t), val) | |
| 292 | 292 | ||
| 293 | 293 | def test_decode(self): | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -144,7 +144,7 @@ def __contains__(self, key): | |||
| 144 | 144 | return o is not None | |
| 145 | 145 | ||
| 146 | 146 | def __repr__(self): | |
| 147 | - return "<WeakValueDictionary at %s>" % id(self) | ||
| 147 | + return "<WeakValueDictionary at %#x>" % id(self) | ||
| 148 | 148 | ||
| 149 | 149 | def __setitem__(self, key, value): | |
| 150 | 150 | if self._pending_removals: | |
@@ -348,7 +348,7 @@ def __len__(self): | |||
| 348 | 348 | return len(self.data) - len(self._pending_removals) | |
| 349 | 349 | ||
| 350 | 350 | def __repr__(self): | |
| 351 | - return "<WeakKeyDictionary at %s>" % id(self) | ||
| 351 | + return "<WeakKeyDictionary at %#x>" % id(self) | ||
| 352 | 352 | ||
| 353 | 353 | def __setitem__(self, key, value): | |
| 354 | 354 | self.data[ref(key, self._remove)] = value | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -354,7 +354,7 @@ def __str__(self): | |||
| 354 | 354 | return self.value | |
| 355 | 355 | ||
| 356 | 356 | def __repr__(self): | |
| 357 | - return "<DateTime %r at %x>" % (self.value, id(self)) | ||
| 357 | + return "<DateTime %r at %#x>" % (self.value, id(self)) | ||
| 358 | 358 | ||
| 359 | 359 | def decode(self, data): | |
| 360 | 360 | self.value = str(data).strip() | |
@@ -846,7 +846,7 @@ def __init__(self, server): | |||
| 846 | 846 | self.__call_list = [] | |
| 847 | 847 | ||
| 848 | 848 | def __repr__(self): | |
| 849 | - return "<MultiCall at %x>" % id(self) | ||
| 849 | + return "<MultiCall at %#x>" % id(self) | ||
| 850 | 850 | ||
| 851 | 851 | __str__ = __repr__ | |
| 852 | 852 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -108,6 +108,9 @@ Core and Builtins | |||
| 108 | 108 | Library | |
| 109 | 109 | ------- | |
| 110 | 110 | ||
| 111 | + - Issue #22031: Reprs now always use hexadecimal format with the "0x" prefix | ||
| 112 | + when contain an id in form " at 0x...". | ||
| 113 | + | ||
| 111 | 114 | - Issue #22018: signal.set_wakeup_fd() now raises an OSError instead of a | |
| 112 | 115 | ValueError on ``fstat()`` failure. | |
| 113 | 116 | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments