fix: update versioneer.py for Python 3 compatibility #2604
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
This PR updates
versioneer.pyto make it compatible with Python 3 by replacing deprecated methods that were causing issues during the setup phase of the project.Changes made:
configparser.SafeConfigParser()withconfigparser.ConfigParser()parser.readfp(f)withparser.read_file(f)These methods were deprecated and removed in Python 3.2+ and 3.9 respectively, causing the following errors:
AttributeError: module 'configparser' has no attribute 'SafeConfigParser'AttributeError: 'ConfigParser' object has no attribute 'readfp'Impact:
These changes ensure that contributors and users running the project on Python 3.8 and above won't face installation issues caused by versioneer's setup logic.
This fix does not alter any runtime logic of the application itself — it only affects the project setup process.
Caveats
Testing
I verified the fix locally by running:
python setup.py --version→ This successfully outputs the version number using the updated versioneer logic.toxin Python 3.8 and 3.9 environments, and the setup succeeded without configparser errors.Environment:
Checklist