FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

gh-82062: correctly set module for built-in instance methods in inspect.signature() by skirpichev · Pull Request #115270 · python/cpython · GitHub

Repository navigation

gh-82062: correctly set module for built-in instance methods in inspect.signature() - #115270

Merged
serhiy-storchaka merged 8 commits into
python:mainfrom
skirpichev:text_signature-scope-82062
May 2, 2024
Merged

serhiy-storchaka merged 8 commits into
python:mainfrom
skirpichev:text_signature-scope-82062

Conversation

skirpichev commented Feb 11, 2024 •
edited by bedevere-app Bot
Loading

Copy link
Copy Markdown
Member

The __module__ attribute is missing for instance methods in extension modules, so instead we use in this case __objclass__.__module__.

… inspect.signature()

The ``__module__`` attribute is missing for instance methods in extension
modules, so instead we use in this case ``__objclass__.__module__``.

Copy link
Copy Markdown
Member Author

Alternatively, we could set the __module__ attribute for instance methods, see #115232. Right now for built-in instance methods its missing (c.f. pure-python classes):

>>> int.to_bytes.__module__
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: 'method_descriptor' object has no attribute '__module__'. Did you mean: '__reduce__'?

serhiy-storchaka self-requested a review April 30, 2024 09:04
Comment thread Lib/inspect.py Outdated
Comment thread Lib/test/test_capi/test_misc.py Outdated

Copy link
Copy Markdown
Member Author

@serhiy-storchaka, I hope I did requested changes.

…S6w7.rst

Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>

serhiy-storchaka left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

LGTM.

serhiy-storchaka merged commit 9789440 into python:main May 2, 2024
skirpichev deleted the text_signature-scope-82062 branch May 3, 2024 00:26
SonicField pushed a commit to SonicField/cpython that referenced this pull request May 8, 2024
…sion modules (pythonGH-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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants


Back | FazBrowse Home | New Git URL