New submission from STINNER Victor:

Follow-up of the issue #26567 which added PyErr_ResourceWarning() (C API), 
attached patch adds a new source parameter to the warnings.warn() function 
(Python API).

source is the destroyed object which emits a ResourceWarning. The source is 
used to show the traceback where the object was created (allocated) when 
tracemalloc is used.

The patch also changes _pyio, asyncio and asyncore modules to set the source 
parameter.

Note: tempfile doesn't set source because it uses a class method:

    @classmethod
    def _cleanup(cls, name, warn_message):
        _shutil.rmtree(name)
        _warnings.warn(warn_message, ResourceWarning)

----------
files: warnings_warn_source.patch
keywords: patch
messages: 262137
nosy: haypo
priority: normal
severity: normal
status: open
title: Add optional source parameter to warnings.warn()
type: enhancement
versions: Python 3.6
Added file: http://bugs.python.org/file42236/warnings_warn_source.patch

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue26604>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to