[New-bugs-announce] [issue26872] Default ConfigParser in python is not able to load values habing percent in them

sorin report at bugs.python.org
Wed Apr 27 16:51:25 EDT 2016

New submission from sorin:

The ConfigParser issue with % (percent) is taking huge proportions because it does have serious implications downstream. One such example is the fact that in breaks virtualenv in such way the if you create a virtual env in a path that contains percent at some point you will endup with a virtualenv where you can install only about 50% of existing python packages (serious ones like numpy or pandas will fail to install or even to perform a simple python setup.py egg_info on them).

This is related to distutils which is trying to use the ConfigParser to load the python PATH (which now contains the percent). 

Switching to RawConfigParser does resolve the problem but this seems like an almost impossible attempt because the huge number of occurrences in the wild.

You will find the that only class that is able to load a value with percent inside is RawConfigParser and I don't think that this is normal.

Here is some code I created to exemplify the defective behaviour:

The code is executed by Travis with multiple version of python, see one result example: https://travis-ci.org/ssbarnea/test-configparser/jobs/126145032

My personal impression is that the decision to process the % (percent) and to change the behaviour between Python 2 and 3 was a very unfortunate one. Ini/Cfg file specification does not specify the percent as an escape character. Introduction of the %(VAR) feature sounds more like bug than a feature in this case.

components: Distutils
messages: 264402
nosy: dstufft, eric.araujo, sorin
priority: normal
severity: normal
status: open
title: Default ConfigParser in python is not able to load values habing percent in them
type: compile error
versions: Python 3.4, Python 3.5

Python tracker <report at bugs.python.org>

More information about the New-bugs-announce mailing list