diff options
author | Sergey B Kirpichev <skirpichev@gmail.com> | 2024-05-02 14:44:33 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-05-02 14:44:33 (GMT) |
commit | 9789440de387219bb7677fe0d66860aa8c9deb02 (patch) | |
tree | 16f2ec47bb5d900e49a3c3bec3aca740e853143f /Lib/test/test_inspect | |
parent | 81939dad77001556c527485d31a2d0f4a759033e (diff) | |
download | cpython-9789440de387219bb7677fe0d66860aa8c9deb02.zip cpython-9789440de387219bb7677fe0d66860aa8c9deb02.tar.gz cpython-9789440de387219bb7677fe0d66860aa8c9deb02.tar.bz2 |
gh-82062: Fix support of parameter defaults on methods in extension modules (GH-115270)
Now inspect.signature() supports references to the module globals in
parameter defaults on methods in extension modules. Previously it was
only supported in functions. The workaround was to specify the fully
qualified name, including the module name.
Diffstat (limited to 'Lib/test/test_inspect')
-rw-r--r-- | Lib/test/test_inspect/test_inspect.py | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/Lib/test/test_inspect/test_inspect.py b/Lib/test/test_inspect/test_inspect.py index fbef34e..d122403 100644 --- a/Lib/test/test_inspect/test_inspect.py +++ b/Lib/test/test_inspect/test_inspect.py @@ -3069,6 +3069,13 @@ class TestSignatureObject(unittest.TestCase): self.assertEqual(inspect.signature(builtin), inspect.signature(template)) + @unittest.skipIf(MISSING_C_DOCSTRINGS, + "Signature information for builtins requires docstrings") + def test_signature_parsing_with_defaults(self): + _testcapi = import_helper.import_module("_testcapi") + meth = _testcapi.DocStringUnrepresentableSignatureTest.with_default + self.assertEqual(str(inspect.signature(meth)), '(self, /, x=1)') + def test_signature_on_non_function(self): with self.assertRaisesRegex(TypeError, 'is not a callable object'): inspect.signature(42) |