[issue31444] ResourceWarning in Python/traceback.c in case of a bad io.TextIOWrapper

2017-09-13 Thread STINNER Victor
STINNER Victor added the comment: Ok, thanks for the confirmation Serhiy. I close the bug. -- resolution: -> not a bug stage: -> resolved status: open -> closed ___ Python tracker ___

[issue31444] ResourceWarning in Python/traceback.c in case of a bad io.TextIOWrapper

2017-09-13 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: I think it should be closed as "not a bug". If io.TextIOWrapper() is successful, it is responsible for property closing a binary file. The bug is in user code, not in the interpreter code. _Py_DisplaySourceLine() correctly calls binary.close() if io.TextIOWr

[issue31444] ResourceWarning in Python/traceback.c in case of a bad io.TextIOWrapper

2017-09-13 Thread STINNER Victor
STINNER Victor added the comment: > this is because _Py_DisplaySourceLine() (in Python/traceback.c) assumes that > io.TextIOWrapper() returned a stream object, and tries to call its close() > method. in case calling close() fails, _Py_DisplaySourceLine() just calls > PyErr_Clear(). I conside

[issue31444] ResourceWarning in Python/traceback.c in case of a bad io.TextIOWrapper

2017-09-13 Thread Oren Milman
New submission from Oren Milman: the following code causes a ResourceWarning: import io def _bad_TextIOWrapper(*args): return None io.TextIOWrapper = _bad_TextIOWrapper 1/0 this is because _Py_DisplaySourceLine() (in Python/traceback.c) assumes that io.TextIOWrapper() returned a stream obj