jaraco/configparser

configparser imports wrong backports.configparser

jschwartzentruber opened this issue · 1 comments

configparser uses absolute imports to import from backports.configparser, when the globally installed version may not be compatible with what is running.

This is an import search order problem and I'm not sure who to blame or how to fix it properly.

A docker session that demonstrates this:

$ docker run --rm -it debian:sid /bin/bash
# apt update && apt install python-pip python-configparser
 -- snip --
Setting up python-configparser (3.5.0b2-3) ...
 -- snip --
# pip install --user -U configparser
Collecting configparser
  Downloading https://files.pythonhosted.org/packages/7a/2a/95ed0501cf5d8709490b1d3a3f9b5cf340da6c433f896bbe9ce08dbe6785/configparser-4.0.2-py2.py3-none-any.whl
Installing collected packages: configparser
Successfully installed configparser-4.0.2
# python -c "import configparser"
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/root/.local/lib/python2.7/site-packages/configparser.py", line 11, in <module>
    from backports.configparser import (
ImportError: cannot import name ConverterMapping
#

sys.path looks correct:

[
  '',
  '/usr/lib/python2.7',
  '/usr/lib/python2.7/plat-x86_64-linux-gnu',
  '/usr/lib/python2.7/lib-tk',
  '/usr/lib/python2.7/lib-old',
  '/usr/lib/python2.7/lib-dynload',
  '/root/.local/lib/python2.7/site-packages',
  '/usr/local/lib/python2.7/dist-packages',
  '/usr/lib/python2.7/dist-packages'
]

The user site-packages comes before global dist-packages, so I'm not sure why it's importing from the latter first.

This was reported here: MozillaSecurity/fuzzfetch#50

Nevermind. I see this was fixed by 76d2889, and Debian just hasn't updated their package.