[issue37299] RuntimeWarning is NOT raised
Andrew Svetlov
report at bugs.python.org
Mon Jun 17 14:18:26 EDT 2019
Andrew Svetlov <andrew.svetlov at gmail.com> added the comment:
> If a RuntimeWarning is warranted when a temporary variable is used, it's warranted when the value is used directly, without a temporary variable.
No, it's not. If "1/0" is present in never executed code block Python don't raise an exception too. Warnings are not exceptional.
open() raises ResoucesWarning for an unclosed file only if the code is actually running.
If the code branch is not executed the Python runtime doesn't throw errors/warnings about its usage.
I'm sorry, mypy doesn't detect this. Potentially could maybe, though.
----------
_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue37299>
_______________________________________
More information about the Python-bugs-list
mailing list