Skip to content

Commit

Permalink
chore: fix compatibility with python3.12+
Browse files Browse the repository at this point in the history
configparser.SafeConfigParser is deprecated since Python3.2
(python/cpython#89336). Compatibility with older version is kept using
try/catch.
  • Loading branch information
jbgalet committed Dec 7, 2023
1 parent 098a856 commit 821496d
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions versioneer.py
Original file line number Diff line number Diff line change
Expand Up @@ -339,9 +339,14 @@ def get_config_from_root(root):
# configparser.NoOptionError (if it lacks "VCS="). See the docstring at
# the top of versioneer.py for instructions on writing your setup.cfg .
setup_cfg = os.path.join(root, "setup.cfg")
parser = configparser.SafeConfigParser()
with open(setup_cfg, "r") as f:
parser.readfp(f)
try:
parser = configparser.SafeConfigParser()
with open(setup_cfg, "r") as f:
parser.readfp(f)
except AttributeError:
parser = configparser.ConfigParser()
with open(setup_cfg, "r") as f:
parser.read_file(f)
VCS = parser.get("versioneer", "VCS") # mandatory

def get(parser, name):
Expand Down

0 comments on commit 821496d

Please sign in to comment.