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.
This commit is contained in:
Victor Stinner 2016-03-19 01:03:51 +01:00
parent 1231a4615f
commit 914cde89d4
11 changed files with 175 additions and 40 deletions

View file

@ -334,6 +334,14 @@ an error value).
.. versionadded:: 3.2
.. c:function:: int PyErr_ResourceWarning(PyObject *source, Py_ssize_t stack_level, const char *format, ...)
Function similar to :c:func:`PyErr_WarnFormat`, but *category* is
:exc:`ResourceWarning` and pass *source* to :func:`warnings.WarningMessage`.
.. versionadded:: 3.6
Querying the error indicator
============================