Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged

Conversation

@skirpichev
Copy link
Member

@skirpichevskirpichev commentedFeb 11, 2024
edited by bedevere-appbot
Loading

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 extensionmodules, so instead we use in this case ``__objclass__.__module__``.
@skirpichev
Copy link
MemberAuthor

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-storchakaserhiy-storchaka self-requested a reviewApril 30, 2024 09:04
@skirpichev
Copy link
MemberAuthor

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

…S6w7.rstCo-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
Copy link
Member

@serhiy-storchakaserhiy-storchaka left a comment

Choose a reason for hiding this comment

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

LGTM.

@serhiy-storchakaserhiy-storchaka merged commit9789440 intopython:mainMay 2, 2024
@skirpichevskirpichev deleted the text_signature-scope-82062 branchMay 3, 2024 00:26
SonicField pushed a commit to SonicField/cpython that referenced this pull requestMay 8, 2024
…sion modules (pythonGH-115270)Now inspect.signature() supports references to the module globals inparameter defaults on methods in extension modules.  Previously it wasonly supported in functions.  The workaround was to specify the fullyqualified name, including the module name.
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@JelleZijlstraJelleZijlstraJelleZijlstra left review comments

@AlexWaygoodAlexWaygoodAlexWaygood left review comments

@serhiy-storchakaserhiy-storchakaserhiy-storchaka approved these changes

@markshannonmarkshannonAwaiting requested review from markshannon

@gvanrossumgvanrossumAwaiting requested review from gvanrossum

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

4 participants

@skirpichev@JelleZijlstra@serhiy-storchaka@AlexWaygood

[8]ページ先頭

©2009-2026 Movatter.jp