Skip to content

Commit 80e00ec

Browse files
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`).
1 parent ac50ece commit 80e00ec

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-1
lines changed

Lib/warnings.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -422,7 +422,7 @@ def warn_explicit(message, category, filename, lineno,
422422
linecache.getlines(filename, module_globals)
423423

424424
# Print message and context
425-
msg = WarningMessage(message, category, filename, lineno, source)
425+
msg = WarningMessage(message, category, filename, lineno, source=source)
426426
_showwarnmsg(msg)
427427

428428

Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Fix incorrect argument passing in :func:`warnings.warn_explicit`.

0 commit comments

Comments
 (0)