[New-bugs-announce] [issue24086] Configparser interpolation is unexpected

Trevor Bekolay report at bugs.python.org
Thu Apr 30 21:12:10 CEST 2015

New submission from Trevor Bekolay:

I was having an issue installing a package in Python 3, which installed properly in Python 2. This is the error message I got:

    Complete output from command python setup.py egg_info:
    Traceback (most recent call last):

    ... snip unhelpful traceback ...

      File "/usr/local/Cellar/python3/3.4.3/Frameworks/Python.framework/Versions/3.4/lib/python3.4/configparser.py", line 423, in _interpolate_some

        "found: %r" % (rest,))


    Command "python setup.py egg_info" failed with error code 1 in /private/var/folders/12/p4ngkfbx2pnb1ln81csjb19c0000gn/T/pip-build-6xhgg5x6/nengo

This wasn't a super helpful error message. I managed to figure out that Python 3 (or setuptools?) was attempting to parse my ~/.pypirc file, which raised a configparser.InterpolationSyntaxError because my password contained a percent-sign. Configparser doesn't try to interpolate this string in Python 2, so it worked fine. As a workaround, I've changed my PyPI password, but this failure was quite surprising to me.

As for what I would expect to happen, I would not expect interpolation to happen if I don't want it to happen. All of the examples shown on in the docs use the syntax "%(key)s" or "${key}". If this is the only way to interpolate, then why is "%" ambiguous? Surely we can look forward one character, and if it's not "(" then "%" should be interpreted literally. Instead, configparser requires me to disambiguate with "%%". But, this would cause my string to be parsed incorrectly in Python 2's configparser, so I'm unable to make that change.

components: Library (Lib)
messages: 242283
nosy: tbekolay
priority: normal
severity: normal
status: open
title: Configparser interpolation is unexpected
type: behavior
versions: Python 3.2, Python 3.3, Python 3.4

Python tracker <report at bugs.python.org>

More information about the New-bugs-announce mailing list