Skip to content

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

Merged
serhiy-storchaka merged 1 commit into
python:mainfrom
serhiy-storchaka:gh-155319-warn-explicit-sourceline
Aug 15, 2026
Merged

gh-155319: Fix the source line of a warning issued with module_globals#155320
serhiy-storchaka merged 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.
@serhiy-storchaka serhiy-storchaka added needs backport to 3.13 bugs and security fixes needs backport to 3.14 bugs and security fixes needs backport to 3.15 pre-release feature fixes, bugs and security fixes labels Aug 15, 2026
@serhiy-storchaka
serhiy-storchaka merged commit c92e2fd into python:main Aug 15, 2026
61 checks passed
@serhiy-storchaka
serhiy-storchaka deleted the gh-155319-warn-explicit-sourceline branch August 15, 2026 06:55
@miss-islington-app

Copy link
Copy Markdown

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

@miss-islington-app

Copy link
Copy Markdown

Sorry, @serhiy-storchaka, I could not cleanly backport this to 3.14 due to a conflict.
Please backport using cherry_picker on command line.

cherry_picker c92e2fd8f9c8af3ea383dec6222cfcca47a405ff 3.14

@bedevere-app

bedevere-app Bot commented Aug 15, 2026

Copy link
Copy Markdown

GH-155824 is a backport of this pull request to the 3.15 branch.

@bedevere-app bedevere-app Bot removed the needs backport to 3.15 pre-release feature fixes, bugs and security fixes label Aug 15, 2026
@miss-islington-app

Copy link
Copy Markdown

Sorry, @serhiy-storchaka, I could not cleanly backport this to 3.13 due to a conflict.
Please backport using cherry_picker on command line.

cherry_picker c92e2fd8f9c8af3ea383dec6222cfcca47a405ff 3.13

@bedevere-app

bedevere-app Bot commented Aug 15, 2026

Copy link
Copy Markdown

GH-155825 is a backport of this pull request to the 3.14 branch.

@bedevere-app bedevere-app Bot removed the needs backport to 3.14 bugs and security fixes label Aug 15, 2026
@bedevere-app

bedevere-app Bot commented Aug 15, 2026

Copy link
Copy Markdown

GH-155826 is a backport of this pull request to the 3.13 branch.

@bedevere-app bedevere-app Bot removed the needs backport to 3.13 bugs and security fixes label Aug 15, 2026
serhiy-storchaka added a commit that referenced this pull request Aug 15, 2026
…_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)
serhiy-storchaka added a commit that referenced this pull request Aug 15, 2026
…_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)
@bedevere-bot

Copy link
Copy Markdown

⚠️⚠️⚠️ Buildbot failure ⚠️⚠️⚠️

Hi! The buildbot ARM64 Windows Non-Debug 3.13 (tier-2) has failed when building commit f61481f.

What do you need to do:

  1. Don't panic.
  2. Check the buildbot page in the devguide if you don't know what the buildbots are or how they work.
  3. Go to the page of the buildbot that failed (https://buildbot.python.org/#/builders/2006/builds/272) and take a look at the build logs.
  4. Check if the failure is related to this commit (f61481f) or if it is a false positive.
  5. If the failure is related to this commit, please, reflect that on the issue and make a new Pull Request with a fix.

You can take a look at the buildbot page here:

https://buildbot.python.org/#/builders/2006/builds/272

Failed tests:

  • test_int

Summary of the results of the build (if available):

==

Click to see traceback logs
Traceback (most recent call last):
  File "C:\Users\buildworker\buildarea\3.13.ware-win11-arm64.nondebug\build\Lib\test\test_int.py", line 740, in test_denial_of_service_prevented_str_to_int
    self.assertLessEqual(sw_fail_extra_huge.seconds, sw_convert.seconds/2)
    ~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AssertionError: 0.015625 not less than or equal to 0.0078125

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants