Skip to content

gh-155319: Fix the source line of a warning issued with module_globals - #155320

Open
serhiy-storchaka wants to merge 1 commit into
python:mainfrom
serhiy-storchaka:gh-155319-warn-explicit-sourceline
Open

gh-155319: Fix the source line of a warning issued with module_globals#155320
serhiy-storchaka wants to merge 1 commit into
python:mainfrom
serhiy-storchaka:gh-155319-warn-explicit-sourceline

Conversation

@serhiy-storchaka

Copy link
Copy Markdown
Member

call_show_warning() passed None in the line slot of WarningMessage, so the source line computed from module_globals was discarded.

get_source_line() also raised IndexError if lineno was out of the range of the module source. It was not visible before, because the result was not used.

The pure Python implementation, which seeds linecache, was not affected.

…globals

warn_explicit() computed the source line from the loader of the module
whose globals were passed as module_globals, but did not pass it to
WarningMessage.  It also raised IndexError if lineno was out of the range
of the module source.
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.

1 participant