summaryrefslogtreecommitdiffstats
path: root/Include/warnings.h
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 /Include/warnings.h
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 'Include/warnings.h')
-rw-r--r--Include/warnings.h7
1 files changed, 7 insertions, 0 deletions
diff --git a/Include/warnings.h b/Include/warnings.h
index effb9fad..c1c6992 100644
--- a/Include/warnings.h
+++ b/Include/warnings.h
@@ -17,6 +17,13 @@ PyAPI_FUNC(int) PyErr_WarnFormat(
Py_ssize_t stack_level,
const char *format, /* ASCII-encoded string */
...);
+
+/* Emit a ResourceWarning warning */
+PyAPI_FUNC(int) PyErr_ResourceWarning(
+ PyObject *source,
+ Py_ssize_t stack_level,
+ const char *format, /* ASCII-encoded string */
+ ...);
#ifndef Py_LIMITED_API
PyAPI_FUNC(int) PyErr_WarnExplicitObject(
PyObject *category,