Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace deprecated SafeConfigParser with ConfigParser #211

Open
alexandre-perrin opened this issue Jan 16, 2025 · 1 comment
Open

Replace deprecated SafeConfigParser with ConfigParser #211

alexandre-perrin opened this issue Jan 16, 2025 · 1 comment

Comments

@alexandre-perrin
Copy link

Situation

Currently, with python <= 3.11, a deprecation warning is issued when instantiating SafeConfigParser object.

 SafeConfigParser class has been renamed to ConfigParser in Python 3.2. This alias will be removed in future versions. Use ConfigParser directly instead.

In python 3.12+, it now fails as it has been removed and this library can no longer work on Ubuntu 24.04 as it uses python3.12:

$ python setup.py --command-packages=stdeb.command bdist_deb
Traceback (most recent call last):
  File "<...>/setup.py", line 5, in <module>
    from setuptools import setup, Extension
ModuleNotFoundError: No module named 'setuptools'
(.venv) alexandre@alexandre-ThinkPad-X1-Carbon-Gen-9:~/ws/wedge-agent-oss-playground/src/python-wedge-sdk$ pip install setuptools
Collecting setuptools
  Using cached setuptools-75.8.0-py3-none-any.whl.metadata (6.7 kB)
Using cached setuptools-75.8.0-py3-none-any.whl (1.2 MB)
Installing collected packages: setuptools
Successfully installed setuptools-75.8.0
(.venv) alexandre@alexandre-ThinkPad-X1-Carbon-Gen-9:~/ws/wedge-agent-oss-playground/src/python-wedge-sdk$ python setup.py --command-packages=stdeb.command bdist_deb
running bdist_deb
running sdist_dsc
running egg_info
writing wedge.egg-info/PKG-INFO
writing dependency_links to wedge.egg-info/dependency_links.txt
writing top-level names to wedge.egg-info/top_level.txt
reading manifest file 'wedge.egg-info/SOURCES.txt'
reading manifest template 'MANIFEST.in'
writing manifest file 'wedge.egg-info/SOURCES.txt'
Traceback (most recent call last):
  File "<...>/setup.py", line 44, in <module>
    setup(
  File "<...>/.venv/lib/python3.12/site-packages/setuptools/__init__.py", line 117, in setup
    return distutils.core.setup(**attrs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "<...>/.venv/lib/python3.12/site-packages/setuptools/_distutils/core.py", line 186, in setup
    return run_commands(dist)
           ^^^^^^^^^^^^^^^^^^
  File "<...>/.venv/lib/python3.12/site-packages/setuptools/_distutils/core.py", line 202, in run_commands
    dist.run_commands()
  File "<...>/.venv/lib/python3.12/site-packages/setuptools/_distutils/dist.py", line 983, in run_commands
    self.run_command(cmd)
  File "<...>/.venv/lib/python3.12/site-packages/setuptools/dist.py", line 999, in run_command
    super().run_command(command)
  File "<...>/.venv/lib/python3.12/site-packages/setuptools/_distutils/dist.py", line 1002, in run_command
    cmd_obj.run()
  File "<...>/.venv/lib/python3.12/site-packages/stdeb/command/bdist_deb.py", line 34, in run
    self.run_command('sdist_dsc')
  File "<...>/.venv/lib/python3.12/site-packages/setuptools/_distutils/cmd.py", line 339, in run_command
    self.distribution.run_command(command)
  File "<...>/.venv/lib/python3.12/site-packages/setuptools/dist.py", line 999, in run_command
    super().run_command(command)
  File "<...>/.venv/lib/python3.12/site-packages/setuptools/_distutils/dist.py", line 1002, in run_command
    cmd_obj.run()
  File "<...>/.venv/lib/python3.12/site-packages/stdeb/command/sdist_dsc.py", line 30, in run
    debinfo = self.get_debinfo()
              ^^^^^^^^^^^^^^^^^^
  File "<...>/.venv/lib/python3.12/site-packages/stdeb/command/common.py", line 197, in get_debinfo
    debinfo = DebianInfo(
              ^^^^^^^^^^^
  File "<...>/.venv/lib/python3.12/site-packages/stdeb/util.py", line 804, in __init__
    cfg = ConfigParser.SafeConfigParser(cfg_defaults)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: module 'configparser' has no attribute 'SafeConfigParser'. Did you mean: 'RawConfigParser'?

Resolution

Replace SafeConfigParser with ConfigParser or handle pre python3.2 configparser version.

@alexandre-perrin
Copy link
Author

Ok after cloning current main branch, I see this has already been done.
However, it seems that it hasn't been released yet.
Am I wrong?

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

No branches or pull requests

1 participant