[Python-checkins] cpython: inspect: Remove "0x..." IDs from Signature objects' __repr__

yury.selivanov python-checkins at python.org
Fri May 15 18:54:00 CEST 2015


https://hg.python.org/cpython/rev/d72d31f4b69a
changeset:   96064:d72d31f4b69a
parent:      96061:e7c7431f91b2
user:        Yury Selivanov <yselivanov at sprymix.com>
date:        Fri May 15 12:53:56 2015 -0400
summary:
  inspect: Remove "0x..." IDs from Signature objects' __repr__

Issue 24200.

files:
  Lib/inspect.py           |  9 +++------
  Lib/test/test_inspect.py |  3 +--
  2 files changed, 4 insertions(+), 8 deletions(-)


diff --git a/Lib/inspect.py b/Lib/inspect.py
--- a/Lib/inspect.py
+++ b/Lib/inspect.py
@@ -2346,8 +2346,7 @@
         return formatted
 
     def __repr__(self):
-        return '<{} at {:#x} "{}">'.format(self.__class__.__name__,
-                                           id(self), self)
+        return '<{} "{}">'.format(self.__class__.__name__, self)
 
     def __hash__(self):
         return hash((self.name, self.kind, self.annotation, self.default))
@@ -2464,8 +2463,7 @@
         args = []
         for arg, value in self.arguments.items():
             args.append('{}={!r}'.format(arg, value))
-        return '<{} at {:#x} ({})>'.format(self.__class__.__name__,
-                                           id(self), ', '.join(args))
+        return '<{} ({})>'.format(self.__class__.__name__, ', '.join(args))
 
 
 class Signature:
@@ -2835,8 +2833,7 @@
         self._return_annotation = state['_return_annotation']
 
     def __repr__(self):
-        return '<{} at {:#x} "{}">'.format(self.__class__.__name__,
-                                           id(self), self)
+        return '<{} {}>'.format(self.__class__.__name__, self)
 
     def __str__(self):
         result = []
diff --git a/Lib/test/test_inspect.py b/Lib/test/test_inspect.py
--- a/Lib/test/test_inspect.py
+++ b/Lib/test/test_inspect.py
@@ -3153,8 +3153,7 @@
         def foo(a, b, *, c:1={}, **kw) -> {42:'ham'}: pass
         sig = inspect.signature(foo)
         ba = sig.bind(20, 30, z={})
-        self.assertRegex(repr(ba),
-                         r'<BoundArguments at 0x[a-fA-F0-9]+ \(a=20,.*\}\}\)>')
+        self.assertRegex(repr(ba), r'<BoundArguments \(a=20,.*\}\}\)>')
 
 
 class TestSignaturePrivateHelpers(unittest.TestCase):

-- 
Repository URL: https://hg.python.org/cpython


More information about the Python-checkins mailing list