From 80e00ecc399db8aeaa9f3a1c87a2cfb34517d7be Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Srinivas=20Reddy=20Thatiparthy=20=28=E0=B0=A4=E0=B0=BE?= =?UTF-8?q?=E0=B0=9F=E0=B0=BF=E0=B0=AA=E0=B0=B0=E0=B1=8D=E0=B0=A4=E0=B0=BF?= =?UTF-8?q?=20=E0=B0=B6=E0=B1=8D=E0=B0=B0=E0=B1=80=E0=B0=A8=E0=B0=BF?= =?UTF-8?q?=E0=B0=B5=E0=B0=BE=E0=B0=B8=E0=B1=8D=20=20=E0=B0=B0=E0=B1=86?= =?UTF-8?q?=E0=B0=A1=E0=B1=8D=E0=B0=A1=E0=B0=BF=29?= Date: Mon, 17 Mar 2025 16:19:53 +0530 Subject: gh-129843: fix pure Python implementation of `warnings.warn_explicit` (#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`). --- Lib/warnings.py | 2 +- Misc/NEWS.d/next/Library/2025-03-17-15-45-36.gh-issue-129843.NPdpXL.rst | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) create mode 100644 Misc/NEWS.d/next/Library/2025-03-17-15-45-36.gh-issue-129843.NPdpXL.rst diff --git a/Lib/warnings.py b/Lib/warnings.py index 13ad6c8..df84425 100644 --- a/Lib/warnings.py +++ b/Lib/warnings.py @@ -422,7 +422,7 @@ def warn_explicit(message, category, filename, lineno, linecache.getlines(filename, module_globals) # 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 0000000..c16d615 --- /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`. -- cgit v0.12