Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork33.7k
gh-123339: Fix cases of inconsistency of __module__ and __firstlineno__ in classes#123613
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
gh-123339: Fix cases of inconsistency of __module__ and __firstlineno__ in classes#123613
Uh oh!
There was an error while loading.Please reload this page.
Conversation
Eclips4 commentedSep 2, 2024
Serhiy, it's seems that you forgot to commit the actual fix(and tests) and accidentally added two |
…lineno__ in classes* Setting the __module__ attribute for a class now removes the __firstlineno__ item from the type's dict.* The _collections_abc and _pydecimal modules now completely replace the collections.abc and decimal modules after importing the latters. This allows to get the source of classes and functions defined in these modules.* inspect.findsource() now checks whether the first line number for a class is out of bound.
fa4c94a tof2a8b90Compareserhiy-storchaka commentedSep 2, 2024
Thanks for noticing this@Eclips4! I somewhere accidentally used Two NEWS entries are intentional, as they belong to different sections (Core and Library). |
Uh oh!
There was an error while loading.Please reload this page.
Doc/reference/datamodel.rst Outdated
| :attr:`__firstlineno__` | ||
| The line number of the first line of the class definition, including decorators. | ||
| Setting:attr:`__module__` removes:attr:`__firstlineno__`. |
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.
| Setting:attr:`__module__` removes:attr:`__firstlineno__`. | |
| Setting:attr:`!__module__` removes:attr:`!__firstlineno__`. |
Note that the link to__module__ does not exist (we don't have a global.. attribute:: __module__). We can address this issue in a follow-up PR, but for now, let's just suppress the link.
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.
Well, the link to__firstlineno__ should be suppressed, but the link to__module__ may work in future.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Doc/reference/datamodel.rst Outdated
| :attr:`__firstlineno__` | ||
| The line number of the first line of the class definition, including decorators. | ||
| Setting:attr:`__module__` removes:attr:`__firstlineno__`. |
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.
Well, the link to__firstlineno__ should be suppressed, but the link to__module__ may work in future.
Uh oh!
There was an error while loading.Please reload this page.
Thanks@serhiy-storchaka for the PR 🌮🎉.. I'm working now to backport this PR to: 3.13. |
Sorry,@serhiy-storchaka, I could not cleanly backport this to |
…__firstlineno__ in classes (pythonGH-123613)* Setting the __module__ attribute for a class now removes the __firstlineno__ item from the type's dict.* The _collections_abc and _pydecimal modules now completely replace the collections.abc and decimal modules after importing them. This allows to get the source of classes and functions defined in these modules.* inspect.findsource() now checks whether the first line number for a class is out of bound.(cherry picked from commit69a4063)Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
GH-124735 is a backport of this pull request to the3.13 branch. |
…tlineno__ in classes (GH-123613) (#124735)* Setting the __module__ attribute for a class now removes the __firstlineno__ item from the type's dict.* The _collections_abc and _pydecimal modules now completely replace the collections.abc and decimal modules after importing them. This allows to get the source of classes and functions defined in these modules.* inspect.findsource() now checks whether the first line number for a class is out of bound.(cherry picked from commit69a4063)
Uh oh!
There was an error while loading.Please reload this page.
__module__attribute for a class now removes the__firstlineno__item from the type's dict.collections.abcmodule is asked. #123339