gh-155319: Fix the source line of a warning issued with module_globals - #155320
Conversation
…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.
|
Thanks @serhiy-storchaka for the PR 🌮🎉.. I'm working now to backport this PR to: 3.13, 3.14, 3.15. |
|
Sorry, @serhiy-storchaka, I could not cleanly backport this to |
|
GH-155824 is a backport of this pull request to the 3.15 branch. |
|
Sorry, @serhiy-storchaka, I could not cleanly backport this to |
|
GH-155825 is a backport of this pull request to the 3.14 branch. |
|
GH-155826 is a backport of this pull request to the 3.13 branch. |
…_globals (GH-155320) (GH-155826) 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. (cherry picked from commit c92e2fd)
…_globals (GH-155320) (GH-155825) 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. (cherry picked from commit c92e2fd)
|
call_show_warning()passedNonein thelineslot ofWarningMessage, so the source line computed from module_globals was discarded.get_source_line()also raisedIndexErrorif 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.