Published: 26 August 2021, 18:00
Python 3.7 introduced Development Mode. The mode can be activated with the -X dev
argument and it makes the interpreter produce some helpful warnings. For instance:
str.encode
(by default, it is unchecked for empty strings).$ echo 'open("/dev/null")' > tmp.py
$ python3 -X dev tmp.py
tmp.py:1: ResourceWarning: unclosed file <_io.TextIOWrapper name='/dev/null' mode='r' encoding='UTF-8'>
open("/dev/null")
ResourceWarning: Enable tracemalloc to get the object allocation traceback