https://github.com/python/cpython/commit/83cfd4649e1c4514e0082c1949fd3c09ea3c3056
commit: 83cfd4649e1c4514e0082c1949fd3c09ea3c3056
branch: 3.13
author: Miss Islington (bot) <31488909+miss-isling...@users.noreply.github.com>
committer: picnixz <10796600+picn...@users.noreply.github.com>
date: 2025-03-17T12:18:42+01:00
summary:

[3.13] gh-129843: fix pure Python implementation of `warnings.warn_explicit` 
(GH-129848) (#131349)

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 80e00ecc399db8aeaa9f3a1c87a2cfb34517d7be)

Co-authored-by: Srinivas Reddy Thatiparthy (తాటిపర్తి శ్రీనివాస్  రెడ్డి) 
<thatiparthysreeni...@gmail.com>

files:
A Misc/NEWS.d/next/Library/2025-03-17-15-45-36.gh-issue-129843.NPdpXL.rst
M Lib/warnings.py

diff --git a/Lib/warnings.py b/Lib/warnings.py
index 430e4748b973da..8d340b5b578992 100644
--- a/Lib/warnings.py
+++ b/Lib/warnings.py
@@ -413,7 +413,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)
 
 
diff --git 
a/Misc/NEWS.d/next/Library/2025-03-17-15-45-36.gh-issue-129843.NPdpXL.rst 
b/Misc/NEWS.d/next/Library/2025-03-17-15-45-36.gh-issue-129843.NPdpXL.rst
new file mode 100644
index 00000000000000..c16d61540edf39
--- /dev/null
+++ b/Misc/NEWS.d/next/Library/2025-03-17-15-45-36.gh-issue-129843.NPdpXL.rst
@@ -0,0 +1 @@
+Fix incorrect argument passing in :func:`warnings.warn_explicit`.

_______________________________________________
Python-checkins mailing list -- python-checkins@python.org
To unsubscribe send an email to python-checkins-le...@python.org
https://mail.python.org/mailman3/lists/python-checkins.python.org/
Member address: arch...@mail-archive.com

Reply via email to