I removed many deprecated functions of the Python API and C API in Python 3.12. I prefer to do it as soon as possible at the beginning of the Python 3.12 release cycle. This way, we can collect more feedback and earlier, have more time to update affected projects, and also have more time to decide if some changes should be reverted or not. See What’s New In Python 3.12 — Python 3.12.0a1 documentation for all changes. Examples:
- Remove the infamous distutils package: install
setuptools to get setuptools’ favor of distutils (and enjoy subtle differences with the removed flavor!)
ssl.SSLContext.wrap_socket() instead, it’s more secure.
"\477" and other invalid escape sequence now emit
SyntaxWarning instead of
pycodestyle --select W605 $(find project/ -name "*.py") to find affected strings of your
I created this thread to collaborate on handling Python 3.12 incompatible changes. If you are affected or if you want to help, you’re welcome here! If you dislike these changes, that’s also the right place to give your feedback.
the setuptools vendored distutils has diverged somewhat from the stdlib version
here’s some of the issues that’ve personally affected me though I suspect there’s more that I’m not remembering:
I suspect the migration is going to be a bit rocky due to this
If setuptools 60 or newer is installed, distutils is provided by setuptools. It’s the
setuptools/_distutils/ module. Example:
Python 3.12.0a1+ (heads/main:f09da28768, Nov 4 2022, 17:46:22) [GCC 12.2.1 20220819 (Red Hat 12.2.1-2)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import distutils
<module 'distutils' (/opt/py312/lib/python3.12/site-packages/setuptools/_distutils/__init__.py)>
It is made possible thanks to
distutils-precedence.pth file installed by setuptools.
There is a bug on Python 3.12 (without distutils): if pip is imported first,
import setuptools and
import distutils fails since _distutils_hack looks for the stdlib distutils instead. I reported the bug #3661 to setuptools.
Another Python 3.12 incompatible change: asyncore, asynchat and smtpd modules, deprecated since Python 3.6, are removed in Python 3.12: issue #72719.
There are also quite a lot of things removed (and in-the-process of removal) in
imp modules. See: