What’s New In Python 3.11¶

submited by
Style Pass
2021-07-19 20:00:07

Prerelease users should be aware that this document is currently in draft form. It will be updated substantially as Python 3.11 moves towards release, so it’s worth checking back even after reading earlier versions.

When printing tracebacks, the interpreter will now point to the exact expression that caused the error instead of just the line. For example:

Previous versions of the interpreter would point to just the line making it ambiguous which object was None. These enhanced errors can also be helpful when dealing with deeply nested dictionary objects and multiple function calls,

This feature requires storing column positions in code objects which may result in a small increase of disk usage of compiled Python files or interpreter memory usage. To avoid storing the extra information and/or deactivate printing the extra traceback information, the -X no_debug_ranges command line flag or the PYTHONNODEBUGRANGES environment variable can be used.

The information used by the enhanced traceback feature is made available as a general API that can be used to correlate bytecode instructions with source code. This information can be retrieved using:

Leave a Comment