On Python 3 stdio objects can be None. That causes crashes. Fix it by opening
devnull automatically.
stdin can be None by using 0<&- in bash, or spawning processes less
carefully, for example, watchman used to cause such None stdin [1] (note:
None is only observable on Python 3).
[1]: https://github.com/facebook/watchman/commit/d241978aaa6b6d7c5b7260bc9e6d699d3a1cea53
The created streams are replaced later by initstdio(), causing them to get garbage-collected without getting closed explicitly.
If you set environment variable PYTHONWARNINGS=always, you’ll get something like