[3.12] gh-129843: fix pure Python implementation of warnings.warn_explicit (GH-129848) (#131350)

gh-129843: fix pure Python implementation of `warnings.warn_explicit` (GH-129848)

The pure Python implementation of `warnings.warn_explicit` constructs a `WarningMessage`
with an incorrect source (it incorrectly sets the WarningMessage's line to the given `source`).
(cherry picked from commit 80e00ecc39)

Co-authored-by: Srinivas Reddy Thatiparthy (తాటిపర్తి శ్రీనివాస్  రెడ్డి) <thatiparthysreenivas@gmail.com>
This commit is contained in:
Miss Islington (bot) 2025-03-17 12:19:09 +01:00 committed by GitHub
parent baea0e2b05
commit e5e8b8ab44
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 2 additions and 1 deletions

View file

@ -409,7 +409,7 @@ def warn_explicit(message, category, filename, lineno,
"Unrecognized action (%r) in warnings.filters:\n %s" %
(action, item))
# Print message and context
msg = WarningMessage(message, category, filename, lineno, source)
msg = WarningMessage(message, category, filename, lineno, source=source)
_showwarnmsg(msg)

View file

@ -0,0 +1 @@
Fix incorrect argument passing in :func:`warnings.warn_explicit`.