Skip to content

gh-137477: Extend regex pattern check in inspect.findsource #137479

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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

George-Ogden
Copy link

@George-Ogden George-Ogden commented Aug 6, 2025

This reintroduces the regex removed in #117025 with an additional case for classes.
While this is still a more hacky solution than AST parsing, etc, it handles class definitions and edge cases where the source code line is incorrect (generator bytecode).

@python-cla-bot
Copy link

python-cla-bot bot commented Aug 6, 2025

All commit authors signed the Contributor License Agreement.

CLA signed

@bedevere-app
Copy link

bedevere-app bot commented Aug 6, 2025

Most changes to Python require a NEWS entry. Add one using the blurb_it web app or the blurb command-line tool.

If this change has little impact on Python users, wait for a maintainer to apply the skip news label instead.

@George-Ogden George-Ogden force-pushed the fix-issue-137477-main branch from c336755 to 05abdb9 Compare August 6, 2025 17:48
@bedevere-app
Copy link

bedevere-app bot commented Aug 6, 2025

Most changes to Python require a NEWS entry. Add one using the blurb_it web app or the blurb command-line tool.

If this change has little impact on Python users, wait for a maintainer to apply the skip news label instead.

@StanFromIreland StanFromIreland changed the title gh-137477 Extend regex pattern check in inspect.findsource gh-137477: Extend regex pattern check in inspect.findsource Aug 6, 2025
@serhiy-storchaka
Copy link
Member

Thank you for your report and PR, @George-Ogden, but I think that #137488 is more correct solution.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants