Python developer mode
The Python Development Mode introduces additional runtime checks that are too expensive to be enabled by default. It should not be more verbose than the default if the code is correct; new warnings are only emitted when an issue is detected.
It can be enabled using the
-X dev
command line option or by setting thePYTHONDEVMODE
environment variable to1
.
Some of the more useful things this does for typical Python development includes the following:
Add
default
warning filter.
- The following warnings are shown:
- Normally, the above warnings are filtered by the default warning filters.
- It behaves as if the
-W default
command line option is used.- Use the
-W error
command line option or set thePYTHONWARNINGS
environment variable toerror
to treat warnings as errors.Enable asyncio debug mode. For example,
asyncio
checks for coroutines that were not awaited and logs them.
- It behaves as if the
PYTHONASYNCIODEBUG
environment variable is set to1
.Check the encoding and errors arguments for string encoding and decoding operations. Examples:
open()
,str.encode()
andbytes.decode()
.
- By default, for best performance, the errors argument is only checked at the first encoding/decoding error and the encoding argument is sometimes ignored for empty strings.