[New-bugs-announce] [issue37350] print ResourceWarning object traceback when raise as error with -W error
Thomas Grainger
report at bugs.python.org
Thu Jun 20 12:16:27 EDT 2019
New submission from Thomas Grainger <tagrain at gmail.com>:
Current behaviour
$ cat foo.py
def foo():
open('foo', 'wb')
foo()
$ python3.8 -W all::ResourceWarning -X tracemalloc=5 foo.py
foo.py:2: ResourceWarning: unclosed file <_io.BufferedWriter name='foo'>
open('foo', 'wb')
Object allocated at (most recent call last):
File "foo.py", lineno 5
foo()
File "foo.py", lineno 2
open('foo', 'wb')
$ python3.8 -W error -X tracemalloc=5 foo.py
Exception ignored in: <_io.FileIO name='foo' mode='wb' closefd=True>
ResourceWarning: unclosed file <_io.BufferedWriter name='foo'>
Expected behaviour
# Pastebin Eu0gvZ5Z
$ cat foo.py
def foo():
open('foo', 'wb')
foo()
$ python3.8 -W all::ResourceWarning -X tracemalloc=5 foo.py
foo.py:2: ResourceWarning: unclosed file <_io.BufferedWriter name='foo'>
open('foo', 'wb')
Object allocated at (most recent call last):
File "foo.py", lineno 5
foo()
File "foo.py", lineno 2
open('foo', 'wb')
$ python3.8 -W error -X tracemalloc=5 foo.py
Exception ignored in: <_io.FileIO name='foo' mode='wb' closefd=True>
ResourceWarning: unclosed file <_io.BufferedWriter name='foo'>
open('foo', 'wb')
Object allocated at (most recent call last):
File "foo.py", lineno 5
foo()
File "foo.py", lineno 2
open('foo', 'wb')
----------
messages: 346129
nosy: graingert
priority: normal
severity: normal
status: open
title: print ResourceWarning object traceback when raise as error with -W error
_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue37350>
_______________________________________
More information about the New-bugs-announce
mailing list