GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — gh-115231: fill __module__ for built-in staticmethods by skirpichev · Pull Request #115232 · python/cpython

Conversation

@skirpichev

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

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member
  • Issue: Empty __module__ attribute for built-in static methods #115231

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@skirpichev
pythongh-115231: fill __module__ attribute for built-in staticmethods
9b31877
@skirpichev
skirpichev requested a review from markshannon as a code owner February 10, 2024 02:44
@bedevere-app bedevere-app Bot added the awaiting review label Feb 10, 2024
@bedevere-app bedevere-app Bot mentioned this pull request Feb 10, 2024
Empty __module__ attribute for built-in static methods #115231
Closed
skirpichev
skirpichev commented Feb 10, 2024
View reviewed changes
Comment thread Lib/test/test_funcattrs.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

sobolevn
sobolevn reviewed Feb 10, 2024
View reviewed changes
Comment thread Objects/typeobject.c Resolved

Uh oh!

There was an error while loading. Please reload this page.

@skirpichev @sobolevn
PyObject_GetAttr -> PyObject_GetOptionalAttr
be1c7ef
Co-authored-by: Nikita Sobolev <[email protected]>
@skirpichev
skirpichev force-pushed the static-bltin-__module__-115231 branch from 8d2f05d to be1c7ef Compare February 10, 2024 13:40
@skirpichev
Merge branch 'main' into static-bltin-__module__-115231
1f854ee
@Eclips4 Eclips4 mentioned this pull request Feb 10, 2024
test_queue times out #115258
Closed
@skirpichev skirpichev changed the title gh-115231: fill __module__ attribute for built-in staticmethods gh-115231: fill __module__ for built-in class/staticmethods Feb 11, 2024
@skirpichev
skirpichev requested a review from sobolevn February 11, 2024 03:02
@skirpichev
fill __module__ attribute for built-in classmethods too
c4dec10
@skirpichev
skirpichev force-pushed the static-bltin-__module__-115231 branch from 28eec6f to c4dec10 Compare February 11, 2024 03:25
@skirpichev
use PyObject_GetAttr & ignore exceptions
1e25d84
@skirpichev

skirpichev commented Feb 11, 2024

Copy link
Copy Markdown
Member Author

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__'?
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@skirpichev skirpichev mentioned this pull request Feb 11, 2024
gh-82062: correctly set module for built-in instance methods in inspect.signature() #115270
Merged
@skirpichev

skirpichev commented Nov 2, 2024

Copy link
Copy Markdown
Member Author

CC @serhiy-storchaka

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

serhiy-storchaka
serhiy-storchaka reviewed Nov 2, 2024
View reviewed changes
Comment thread Objects/typeobject.c Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread Objects/descrobject.c Resolved

Uh oh!

There was an error while loading. Please reload this page.

skirpichev added 4 commits November 2, 2024 12:47
@skirpichev
Merge branch 'master' into static-bltin-__module__-115231
63b05a0
@skirpichev
address review: use type_module()
777bc8d
@skirpichev
+ rename news
d1650bf
@skirpichev
Merge branch 'main' into static-bltin-__module__-115231
d0f5bb0
@skirpichev
skirpichev marked this pull request as draft November 2, 2024 13:23
@bedevere-app bedevere-app Bot removed the awaiting review label Nov 2, 2024
skirpichev added 3 commits November 2, 2024 16:24
@skirpichev
XXX Revert "address review: use type_module()"
e20339b
This reverts commit 777bc8d.
@skirpichev
Merge branch 'main' into static-bltin-__module__-115231
4ba1288
@skirpichev
Address review: use type_module()
543a5b3
@skirpichev
skirpichev marked this pull request as ready for review February 24, 2025 08:36
@bedevere-app bedevere-app Bot added the awaiting review label Feb 24, 2025
skirpichev added 3 commits September 9, 2025 07:20
@skirpichev
Merge branch 'master' into static-bltin-__module__-115231
b3fbb8c
@skirpichev
Revert "fill __module__ attribute for built-in classmethods too"
6666a1a
This reverts commit c4dec10.
@skirpichev
+1
386f383
@skirpichev
skirpichev force-pushed the static-bltin-__module__-115231 branch from d29c90d to 386f383 Compare September 9, 2025 05:36
@skirpichev skirpichev changed the title gh-115231: fill __module__ for built-in class/staticmethods gh-115231: fill __module__ for built-in staticmethods Sep 9, 2025
@skirpichev
skirpichev requested a review from serhiy-storchaka October 10, 2025 04:49
serhiy-storchaka
serhiy-storchaka reviewed Oct 13, 2025
View reviewed changes

@serhiy-storchaka serhiy-storchaka left a comment

Copy link
Copy Markdown
Member

There was a problem hiding this 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.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
serhiy-storchaka
serhiy-storchaka approved these changes Oct 13, 2025
View reviewed changes
@bedevere-app bedevere-app Bot added awaiting merge and removed awaiting review labels Oct 13, 2025
@skirpichev

skirpichev commented Oct 14, 2025

Copy link
Copy Markdown
Member Author

class methods

Hmm, I don't see ways to speedup this. Maybe solution is just to pay this price at time of access the __module__ attribute.

only for static methods loses purpose

Why? Something meaningful is better than just None.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@skirpichev

skirpichev commented Jan 30, 2026

Copy link
Copy Markdown
Member Author

CC @vstinner

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

vstinner
vstinner reviewed Jan 30, 2026
View reviewed changes
Comment thread Objects/typeobject.c Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread Lib/test/test_funcattrs.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

@skirpichev @vstinner
Update Objects/typeobject.c
598a964
Co-authored-by: Victor Stinner <[email protected]>
vstinner
vstinner approved these changes Jan 30, 2026
View reviewed changes

@vstinner vstinner left a comment

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

LGTM

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@vstinner
Merge branch 'main' into static-bltin-__module__-115231
0481304
@vstinner

vstinner commented Jan 30, 2026

Copy link
Copy Markdown
Member

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

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

serhiy-storchaka
serhiy-storchaka approved these changes Feb 2, 2026
View reviewed changes
@vstinner
vstinner merged commit 15c9f24 into python:main Feb 2, 2026
47 checks passed

Uh oh!

There was an error while loading. Please reload this page.

@bedevere-app bedevere-app Bot removed the awaiting merge label Feb 2, 2026
@skirpichev
skirpichev deleted the static-bltin-__module__-115231 branch February 2, 2026 11:36
Aniketsy pushed a commit to Aniketsy/cpython that referenced this pull request Feb 3, 2026
@skirpichev @sobolevn
@vstinner @Aniketsy
pythongh-115231: Fill __module__ for built-in staticmethods (python#1…
a09aa1e
…15232)

Co-authored-by: Nikita Sobolev <[email protected]>
Co-authored-by: Victor Stinner <[email protected]>
thunder-coding pushed a commit to thunder-coding/cpython that referenced this pull request Feb 15, 2026
@skirpichev @sobolevn
@vstinner @thunder-coding
pythongh-115231: Fill __module__ for built-in staticmethods (python#1…
3e81347
…15232)

Co-authored-by: Nikita Sobolev <[email protected]>
Co-authored-by: Victor Stinner <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@vstinner vstinner vstinner approved these changes
@serhiy-storchaka serhiy-storchaka serhiy-storchaka approved these changes
@markshannon markshannon Awaiting requested review from markshannon markshannon is a code owner
@sobolevn sobolevn Awaiting requested review from sobolevn

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

4 participants

@skirpichev @vstinner @serhiy-storchaka @sobolevn
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.