Skip to content

Conversation

@asyncArijit
Copy link
Contributor

@asyncArijit asyncArijit commented Apr 11, 2025

Description

This PR updates versioneer.py to make it compatible with Python 3 by replacing deprecated methods that were causing issues during the setup phase of the project.

Changes made:

  • Replaced configparser.SafeConfigParser() with configparser.ConfigParser()
  • Replaced parser.readfp(f) with parser.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

  • Not a breaking change
  • No changes to documentation needed
  • No new dependencies introduced

Testing

I verified the fix locally by running:

  • python setup.py --version → This successfully outputs the version number using the updated versioneer logic.
  • Ran tox in Python 3.8 and 3.9 environments, and the setup succeeded without configparser errors.

Environment:

  • OS: Linux Mint 21.3
  • Python: 3.8.18

Checklist

  • My code passes the tox check
  • My changes generate no new warnings
  • I have commented my code, particularly in hard-to-understand areas
  • I have not used code from external sources without attribution
  • There are no remaining debug statements
  • I have considered accessibility (N/A for backend config)

Removed  commnetedout  
  .parser = configparser.SafeConfigParser()
  .parser.readfp(f)
@egonw egonw requested a review from fnielsen April 18, 2025 06:54
@fnielsen
Copy link
Collaborator

There is a Codacy static code analysis error that I do not understand https://app.codacy.com/gh/WDscholia/scholia/pull-requests/2604/issues#issue-bba62b754626c03c28a4111115f4b263

@WolfgangFahl
Copy link
Collaborator

just a superfluous space that breaks python indentation rules

setup_cfg = os.path.join(root, "setup.cfg")
parser = configparser.ConfigParser()

with open(setup_cfg, "r") as f:
    parser.read_file(f)

@fnielsen
Copy link
Collaborator

fnielsen commented May 1, 2025

Codacy claims a superfluous space, but where is it? When I look in line 341 and 342, it does not appear to me

fnielsen added a commit that referenced this pull request Jun 20, 2025
@fnielsen fnielsen mentioned this pull request Jun 20, 2025
10 tasks
fnielsen added a commit that referenced this pull request Jun 20, 2025
fnielsen added a commit that referenced this pull request Jun 20, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants