bpo-43118: Fix bug in inspect.signature around 'base.__text_signature__' (GH-30285) (#30765)

(cherry picked from commit 881a763cfe)

Co-authored-by: Weipeng Hong <hongweichen8888@sina.com>

Co-authored-by: Weipeng Hong <hongweichen8888@sina.com>
This commit is contained in:
Miss Islington (bot) 2022-01-22 09:28:48 -08:00 committed by GitHub
parent 923c994400
commit 83aef4d340
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 27 additions and 2 deletions

View file

@ -4218,6 +4218,17 @@ class TestSignatureDefinitions(unittest.TestCase):
sig = inspect.signature(func)
self.assertEqual(str(sig), '(self, a, b=1, /, *args, c, d=2, **kwargs)')
def test_base_class_have_text_signature(self):
# see issue 43118
from test.ann_module7 import BufferedReader
class MyBufferedReader(BufferedReader):
"""buffer reader class."""
text_signature = BufferedReader.__text_signature__
self.assertEqual(text_signature, '(raw, buffer_size=DEFAULT_BUFFER_SIZE)')
sig = inspect.signature(MyBufferedReader)
self.assertEqual(str(sig), '(raw, buffer_size=8192)')
class NTimesUnwrappable:
def __init__(self, n):