Python etc / Development Mode

Development Mode

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:

  • Unclosed files.
  • Unawaited coroutines.
  • Unknown encoding for str.encode (by default, it is unchecked for empty strings).
  • Memory allocation issues.
$ echo 'open("/dev/null")' >
$ python3 -X dev ResourceWarning: unclosed file <_io.TextIOWrapper name='/dev/null' mode='r' encoding='UTF-8'>
ResourceWarning: Enable tracemalloc to get the object allocation traceback