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-115231: fill __module__ for built-in staticmethods#115232

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 10, 2024
edited by bedevere-appbot
Loading

Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
@skirpichevskirpichevforce-pushed thestatic-bltin-__module__-115231 branch from8d2f05d tobe1c7efCompareFebruary 10, 2024 13:40
@Eclips4Eclips4 mentioned this pull requestFeb 10, 2024
@skirpichevskirpichev changed the titlegh-115231: fill __module__ attribute for built-in staticmethodsgh-115231: fill __module__ for built-in class/staticmethodsFeb 11, 2024
@skirpichevskirpichevforce-pushed thestatic-bltin-__module__-115231 branch from28eec6f toc4dec10CompareFebruary 11, 2024 03:25
@skirpichev
Copy link
MemberAuthor

See also#82062: we could fix that issue in a similar approach, using__objclass__.__module__ to set the__module__ attribute. 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__'?

@skirpichev
Copy link
MemberAuthor

CC@serhiy-storchaka

@skirpichevskirpichev marked this pull request as draftNovember 2, 2024 13:23
@skirpichevskirpichev marked this pull request as ready for reviewFebruary 24, 2025 08:36
@skirpichevskirpichevforce-pushed thestatic-bltin-__module__-115231 branch fromd29c90d to386f383CompareSeptember 9, 2025 05:36
@skirpichevskirpichev changed the titlegh-115231: fill __module__ for built-in class/staticmethodsgh-115231: fill __module__ for built-in staticmethodsSep 9, 2025
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. But I would look what can we do with unbound instance methods and class methods. Because providing__module__ only for static methods loses purpose.

@skirpichev
Copy link
MemberAuthor

class methods

Hmm, I don't see ways to speedup this. Maybe solution is just to pay this price at time ofaccess the__module__ attribute.

only for static methods loses purpose

Why? Something meaningful is better than justNone.

@skirpichev
Copy link
MemberAuthor

CC@vstinner

Co-authored-by: Victor Stinner <vstinner@python.org>
Copy link
Member

@vstinnervstinner left a comment

Choose a reason for hiding this comment

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

LGTM

@vstinner
Copy link
Member

I clicked on [Update branch] since this PR was created many months ago.

@vstinnervstinner merged commit15c9f24 intopython:mainFeb 2, 2026
47 checks passed
@skirpichevskirpichev deleted the static-bltin-__module__-115231 branchFebruary 2, 2026 11:36
Aniketsy pushed a commit to Aniketsy/cpython that referenced this pull requestFeb 3, 2026
…15232)Co-authored-by: Nikita Sobolev <mail@sobolevn.me>Co-authored-by: Victor Stinner <vstinner@python.org>
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@vstinnervstinnervstinner approved these changes

@serhiy-storchakaserhiy-storchakaserhiy-storchaka approved these changes

@markshannonmarkshannonAwaiting requested review from markshannonmarkshannon is a code owner

@sobolevnsobolevnAwaiting requested review from sobolevn

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@vstinner@serhiy-storchaka@sobolevn

[8]ページ先頭

©2009-2026 Movatter.jp