Documentation for a newer release is available. View Latest

Python

Python 3.11

Fedora 37 provides the Python stack in version 3.11, up from version 3.10 in the previous release. Notable changes include:

  • Exception Groups and except*

  • Enhanced error locations in tracebacks

  • Support for parsing TOML in the standard library

  • A massive speed improvement compared to Python 3.10

Typing features:

  • Variadic generics

  • Marking individual TypedDict items as required or potentially-missing

  • Self type

  • Arbitrary literal string type

  • Dataclass transforms

For a full list of changes, see the What’s New In Python 3.11 upstream document. Also see Porting to Python 3.11 if you have Python programs running on an older version.

Add -P to default shebangs

All Python 3 shebang RPM macros in Fedora 37 have been changed to contain one more flag: -P. Previously, they contained -s, now they contain -sP. The -P flag was introduced in Python 3.11.

The new flag stops Python from prepending a potentially unsafe path to sys.path. This causes Python programs in /usr/bin to be less fragile towards random files present in the same directory, making debugging certain types of issues easier and enhancing security.

The following RPM macros are affected by this change:

  • %{py3_shbang_opts}

  • %{py3_shbang_opts_nodash}

  • %{py3_shebang_flags}

  • %{py_shbang_opts}

  • %{py_shbang_opts_nodash}

  • %{py_shebang_flags}

For a detailed explanation of what this change means, a list of affected packages, and information on how to opt out of this change (or explicitly opt in) if needed, see the Fedora Wiki.