Issue #5 resolved

Installing configparser on Python 3.x is dangerous

Barry Warsaw
created an issue

Over in Ubuntu, we inherit Debian's python-configparser package, which currently provides configparser 3.3.0r2. Normally, this package isn't hugely depended on by other packages, so it doesn't get installed very often. Recently one of our main packages created a dependency on configparser and when it got installed lots of things broke. We ended up having to rewrite the code to not depend on configparser, and thus relegating it back away from our main repository. We must actively recommend against installing it.

Here are examples of things it broke. Some have been fixed in the broken package, but a few (e.g. the virtualenv problem) is currently fixable only by de-installing configparser.

https://bugs.launchpad.net/ubuntu/+source/python-virtualenv/+bug/1156704 https://bugs.launchpad.net/software-center/+bug/1038429 https://bugs.launchpad.net/ubuntu/+source/ubuntuone-client/+bug/1198480

Unfortunately, I don't have a lot of time right now for further investigation, but I wanted to file the bug upstream for tracking purposes.

Comments (5)

  1. Łukasz Langa repo owner

    Barry, this library is a backport of configparser from 3.2+ to Python 2.6 and 2.7 only. It won't work on Python 3.x. On Python 3.2+ you should simply use configparser as provided by the standard library.

  2. Barry Warsaw reporter

    Lukasz, you're right, but the problem is that installing configparser for Python 2 breaks virtualenv when creating a Python 3 virtualenv. We don't have a Python 3 version of python-configparser in the distro. Steps to reproduce on Debian:

    $ sudo apt-get install python-configparser
    $ virtualenv --system-site-packages -p python3 /tmp/ve1
    [traceback]
    $ sudo apt-get purge python-configparser
    $ virtualenv --system-site-packages -p python3 /tmp/ve2
    [happy!]
    
  3. Marc Abramowitz

    Wondering if you can release 3.5.0 to PyPI?

    https://pypi.python.org/pypi/configparser/ has 3.5.0b2 as the latest version, which is a pre-release.

    As a result when I do pip install -v configparser, I get:

    $ pip install -v configparser
    Downloading/unpacking configparser
      Ignoring link https://pypi.python.org/packages/source/c/configparser/configparser-3.5.0b1.tar.gz#md5=d60ca2c714acb4adaf5818c6a1ffd78b (from https://pypi.python.org/simple/configparser/), version 3.5.0b1 is a pre-release (use --pre to allow).
      Ignoring link https://pypi.python.org/packages/source/c/configparser/configparser-3.5.0b2.tar.gz#md5=ad2a71db8bd9a017ed4735eac7acfa07 (from https://pypi.python.org/simple/configparser/), version 3.5.0b2 is a pre-release (use --pre to allow).
      Using version 3.3.0r2 (newest of versions: 3.3.0r2, 3.3.0r1, 3.2.0r3, 3.2.0r2, 3.2.0r1)
      Downloading configparser-3.3.0r2.tar.gz
    ...
    
    $ pip freeze | grep -i configparser
    configparser==3.3.0r2
    
    $ virtualenv --python python3.3 py33
    Running virtualenv with interpreter /Library/Frameworks/Python.framework/Versions/3.3/bin/python3.3
    Traceback (most recent call last):
      File "/Users/marca/python/virtualenvs/configparser/lib/python2.7/site-packages/virtualenv.py", line 41, in <module>
        import ConfigParser
    ImportError: No module named 'ConfigParser'
    
    During handling of the above exception, another exception occurred:
    
    Traceback (most recent call last):
      File "/Users/marca/python/virtualenvs/configparser/lib/python2.7/site-packages/virtualenv.py", line 43, in <module>
        import configparser as ConfigParser
      File "/Users/marca/python/virtualenvs/configparser/lib/python2.7/site-packages/configparser.py", line 397
        _KEYCRE = re.compile(ur"%\(([^)]+)\)s")
                                             ^
    SyntaxError: invalid syntax
    
  4. Log in to comment