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-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

Conversation

@serhiy-storchaka
Copy link
Member

@serhiy-storchakaserhiy-storchaka commentedSep 2, 2024
edited by bedevere-appbot
Loading

  • 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 latter. 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.

@serhiy-storchakaserhiy-storchaka added the needs backport to 3.13bugs and security fixes labelSep 2, 2024
@bedevere-appbedevere-appbot added the docsDocumentation in the Doc dir labelSep 2, 2024
@Eclips4Eclips4 changed the title__ in classesgh-123339: Fix cases of inconsistency of __module__ and __firstlineno__ in classesgh-123339: Fix cases of inconsistency of __module__ and __firstlineno__ in classesSep 2, 2024
@Eclips4
Copy link
Member

Serhiy, it's seems that you forgot to commit the actual fix(and tests) and accidentally added twoNEWS entries

…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.
@serhiy-storchaka
Copy link
MemberAuthor

Thanks for noticing this@Eclips4! I somewhere accidentally used--amend.

Two NEWS entries are intentional, as they belong to different sections (Core and Library).

Eclips4 reacted with thumbs up emoji


:attr:`__firstlineno__`
The line number of the first line of the class definition, including decorators.
Setting:attr:`__module__` removes:attr:`__firstlineno__`.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
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.

serhiy-storchaka reacted with thumbs up emoji
Copy link
MemberAuthor

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.


:attr:`__firstlineno__`
The line number of the first line of the class definition, including decorators.
Setting:attr:`__module__` removes:attr:`__firstlineno__`.
Copy link
MemberAuthor

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.

@rhettingerrhettinger removed their request for reviewSeptember 3, 2024 10:24
@miss-islington-app
Copy link

Thanks@serhiy-storchaka for the PR 🌮🎉.. I'm working now to backport this PR to: 3.13.
🐍🍒⛏🤖

@serhiy-storchakaserhiy-storchaka deleted the firstlineno-with-changed-module branchSeptember 28, 2024 17:51
@miss-islington-app
Copy link

Sorry,@serhiy-storchaka, I could not cleanly backport this to3.13 due to a conflict.
Please backport usingcherry_picker on command line.

cherry_picker 69a4063ca516360b5eb96f5432ad9f9dfc32a72e 3.13

serhiy-storchaka added a commit to serhiy-storchaka/cpython that referenced this pull requestSep 28, 2024
…__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>
@bedevere-app
Copy link

GH-124735 is a backport of this pull request to the3.13 branch.

@bedevere-appbedevere-appbot removed the needs backport to 3.13bugs and security fixes labelSep 28, 2024
@serhiy-storchakaserhiy-storchaka removed their assignmentSep 28, 2024
Yhg1s pushed a commit that referenced this pull requestSep 30, 2024
…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)
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@picnixzpicnixzpicnixz left review comments

@jaracojaracojaraco approved these changes

@markshannonmarkshannonAwaiting requested review from markshannonmarkshannon is a code owner

@willingcwillingcAwaiting requested review from willingcwillingc is a code owner

@rhettingerrhettingerAwaiting requested review from rhettingerrhettinger is a code owner

Assignees

No one assigned

Labels

docsDocumentation in the Doc dir

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

4 participants

@serhiy-storchaka@Eclips4@jaraco@picnixz

[8]ページ先頭

©2009-2025 Movatter.jp