chore: Remove obsolete Python 2 compatibility code#306
chore: Remove obsolete Python 2 compatibility code#306mrbean-bremen merged 2 commits intoMeVisLab:masterfrom
Conversation
Remove all `#ifndef PY3K` conditionals and related branches, consolidating on Python 3 APIs. This drops redundant code paths and consistently renames `nb_nonzero` helpers to `nb_bool`. Remove the comment related to the use of `Py_FlushLine` in `custom_system_exit_exception_handle` in `PythonQt.cpp`, which is not needed in Python 3.x. See python/cpython@79139b247b0 ("Kill off softspace completely (except in formatter.py which seems to have a different feature with the same name). The change to test_doctest.txt reduces the doctest failures to 3.", 2007-02-09) Co-authored-by: Jean-Christophe Fillion-Robin <jchris.fillionr@kitware.com>
This changes simplify the code by removing legacy preprocessor conditionals for Python versions < 2.4. It ensures the consistent use of the `PyMarshal_Write*` API with `Py_MARSHAL_VERSION`.
mrbean-bremen
left a comment
There was a problem hiding this comment.
Thanks - it's time to really declare Python 2 dead...
|
Ditto. Have a few more related PRs coming up 🚀 |
|
You should probably mark a final version as compatible with Python 2.7 so those who need Python 2 support know what to use - and then do a significant version bump to signal Python 3 only support. Note that Python 2.7 is still the default version and supported on RHEL 7.9 which is in Extended Life Cycle Support phase until 30 June 2028. Thus in industrial/production environments it will be used until it can be pried out of the cold (dead) hands of the customer on 1 July 2028. |
|
I think all the latest changes have been for Qt 5.15 and 6, which is not what is used on these systems. So basically, all changes since version 3.5 are basically targeted to Qt 5.15 and later, and Python 3. That being said, I agree that a major version update makes sense after the synchronization with the commontk version is finished, with a note that Python 2 is no longer supported, and versions before Qt 5.15 are no longer guaranteed to work. |
This pull request removes obsolete compatibility code for Python 2 and outdated
preprocessor conditionals for Python versions < 2.4.
Remove all
#ifndef PY3Kconditionals and related branches, consolidating on Python 3 APIs. This drops redundant code paths and consistently renamesnb_nonzerohelpers tonb_bool.Remove the comment related to the use of
Py_FlushLineincustom_system_exit_exception_handleinPythonQt.cpp, which is not needed in Python 3.x. See python/cpython@79139b247b0 ("Kill off softspace completely (except in formatter.py which seems to have a different feature with the same name). The change to test_doctest.txt reduces the doctest failures to 3.", 2007-02-09)Remove outdated
PY_VERSION_HEXconditional branches.