]> granicus.if.org Git - python/commitdiff
inspect: Remove "0x..." IDs from Signature objects' __repr__
authorYury Selivanov <yselivanov@sprymix.com>
Fri, 15 May 2015 16:53:56 +0000 (12:53 -0400)
committerYury Selivanov <yselivanov@sprymix.com>
Fri, 15 May 2015 16:53:56 +0000 (12:53 -0400)
Issue 24200.

Lib/inspect.py
Lib/test/test_inspect.py

index 9290b4b55f183a58f657fc7ff223d946103bad2a..9389f3bd4b47244a4c5a70681e2ecccffd8b0f24 100644 (file)
@@ -2346,8 +2346,7 @@ class Parameter:
         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 @@ class BoundArguments:
         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 @@ class Signature:
         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 = []
index 6f813be89573ab8a9f6bffe7c7e10da90abe1ed6..13db79a42ad51309bf35cf5fbf79c0e3fdef85f9 100644 (file)
@@ -3153,8 +3153,7 @@ class TestBoundArguments(unittest.TestCase):
         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):