New submission from Thomas Grainger <tagr...@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 <rep...@bugs.python.org> <https://bugs.python.org/issue37350> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com