]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
[3.12] gh-129843: fix pure Python implementation of `warnings.warn_explicit` (GH...
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Mon, 17 Mar 2025 11:19:09 +0000 (12:19 +0100)
committerGitHub <noreply@github.com>
Mon, 17 Mar 2025 11:19:09 +0000 (12:19 +0100)
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 (తాటిపర్తి శ్రీనివాస్ రెడ్డి) <thatiparthysreenivas@gmail.com>
Lib/warnings.py
Misc/NEWS.d/next/Library/2025-03-17-15-45-36.gh-issue-129843.NPdpXL.rst [new file with mode: 0644]

index fc8c0128e3a1eb04e0ad61fe94e565bf3fee41ca..3bfba9749abe334eae2a4d10257fc26ec601da53 100644 (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)
 
 
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 (file)
index 0000000..c16d615
--- /dev/null
@@ -0,0 +1 @@
+Fix incorrect argument passing in :func:`warnings.warn_explicit`.