summaryrefslogtreecommitdiffstats
path: root/Doc/library/warnings.rst
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@gmail.com>2016-03-19 00:03:51 (GMT)
committerVictor Stinner <victor.stinner@gmail.com>2016-03-19 00:03:51 (GMT)
commit914cde89d4c94b0b9206d0fa22322a1142833a56 (patch)
tree7eed294f0da18437f719df470dbee278cfb40787 /Doc/library/warnings.rst
parent1231a4615fd447f0988a72a134a1fc5e7d4e8d69 (diff)
downloadcpython-914cde89d4c94b0b9206d0fa22322a1142833a56.zip
cpython-914cde89d4c94b0b9206d0fa22322a1142833a56.tar.gz
cpython-914cde89d4c94b0b9206d0fa22322a1142833a56.tar.bz2
On ResourceWarning, log traceback where the object was allocated
Issue #26567: * Add a new function PyErr_ResourceWarning() function to pass the destroyed object * Add a source attribute to warnings.WarningMessage * Add warnings._showwarnmsg() which uses tracemalloc to get the traceback where source object was allocated.
Diffstat (limited to 'Doc/library/warnings.rst')
-rw-r--r--Doc/library/warnings.rst8
1 files changed, 7 insertions, 1 deletions
diff --git a/Doc/library/warnings.rst b/Doc/library/warnings.rst
index 8a538ad..4ce88ab 100644
--- a/Doc/library/warnings.rst
+++ b/Doc/library/warnings.rst
@@ -319,7 +319,7 @@ Available Functions
of the warning message).
-.. function:: warn_explicit(message, category, filename, lineno, module=None, registry=None, module_globals=None)
+.. function:: warn_explicit(message, category, filename, lineno, module=None, registry=None, module_globals=None, source=None)
This is a low-level interface to the functionality of :func:`warn`, passing in
explicitly the message, category, filename and line number, and optionally the
@@ -335,6 +335,12 @@ Available Functions
source for modules found in zipfiles or other non-filesystem import
sources).
+ *source*, if supplied, is the destroyed object which emitted a
+ :exc:`ResourceWarning`.
+
+ .. versionchanged:: 3.6
+ Add the *source* parameter.
+
.. function:: showwarning(message, category, filename, lineno, file=None, line=None)