This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Title: distutils use ConfigParser in Python 3.x and fails to parse setup.cfg with percent sign
Type: behavior Stage: resolved
Components: Distutils Versions: Python 3.7, Python 3.6, Python 3.5
Status: closed Resolution: duplicate
Dependencies: Superseder: Distribution.parse_config_files uses interpolation
View: 20754
Assigned To: Nosy List: berker.peksag, dstufft, eric.araujo, jaraco, noirbizarre
Priority: normal Keywords: patch

Created on 2016-12-10 19:12 by noirbizarre, last changed 2022-04-11 14:58 by admin. This issue is now closed.

File name Uploaded Description Edit
disable-distutils-string-interpolation.patch noirbizarre, 2016-12-10 19:12 Disable string interpolation in distutils config parsing review
Messages (6)
msg282865 - (view) Author: Axel Haustant (noirbizarre) * Date: 2016-12-10 19:12
Because of the Python 3.2 configparser renaming/refactoring, string interpolation has been enabled into distutils config parsing and so fails to read any setup.cfg with percent signs (try to perform string interpolation and fails).

To reproduce: create a project with a percent sign anywhere in the setup.cfg file and execute python egg_info.
It will pass on Python 2.x and fails on Python 3.x.

The attached patch suimply disable string interpolation in distutils config parsing.

That would be awesome to have this applied on any 3.x version (because project using tox to test against different Python versions also fails with the same issue Python 3.x and PyPI 3.x)
msg282992 - (view) Author: Berker Peksag (berker.peksag) * (Python committer) Date: 2016-12-12 13:00
Thanks for the report! This looks similar to issue 20754.

Disabling string interpolation would break existing code (but probably just Python 3 only code)

Would using %% instead of % be possible for you?

(3.3 and 3.4 are in security-fix-only mode so I removed them from the versions field.)
msg282996 - (view) Author: Axel Haustant (noirbizarre) * Date: 2016-12-12 13:37
You're welcome.

I understand the backward compatibility point. But I think that the current state is breaking existing code as it's not documented anywhere and it's a side-effect of another change, not something intentionnal.
(this is why I submitted this issue because I'm developing a tool which use the setup.cfg file to store data and it is broken in Python 3. I saw a lot of bug reports on different tools with the same issue (ex: nosetest configuration)

I cannot use %% for many reason:
- it will not work with Python 2.x (problematic for 2/3 cross compatibility)
- it needs every tools to know that in Python 3, they have to change their parser

Right now, I'm supporting configuration into an external file for Python 3.x

Thanks for your response ! I hope that it can be integrated into future releases (noted the point on 3.3/3.4).
msg283005 - (view) Author: Jason R. Coombs (jaraco) * (Python committer) Date: 2016-12-12 14:29
This looks to be another manifestation of issue20120 and is a duplicate of issue20754.
msg283012 - (view) Author: Axel Haustant (noirbizarre) * Date: 2016-12-12 15:42
No it's not. Same problem but on a different part: the two cited issues are about the .pypirc file not the setup.cfg.
The parsing does not occurs at the same place and the fix does not works for setup.cfg (I tried before submitting this issue).

In this specific case, setuptools calls distutils to parse the file so the fix has to be in distutils not setuptools (whereas for .pypirc, this is setuptools which is parsing the file)
msg283013 - (view) Author: Axel Haustant (noirbizarre) * Date: 2016-12-12 15:46
Sorry, it is effectively a duplicate of the second one.
But I submitted a patch which is not present in the other.
What should I do ? (I'll attach the patch to the other one instead)
Date User Action Args
2022-04-11 14:58:40adminsetgithub: 73121
2016-12-12 16:34:26berker.peksagsetsuperseder: Distribution.parse_config_files uses interpolation
stage: resolved
2016-12-12 15:46:11noirbizarresetmessages: + msg283013
2016-12-12 15:42:27noirbizarresetmessages: + msg283012
2016-12-12 14:29:34jaracosetstatus: open -> closed
resolution: duplicate
messages: + msg283005
2016-12-12 13:37:35noirbizarresetmessages: + msg282996
2016-12-12 13:00:56berker.peksagsetversions: - Python 3.3, Python 3.4
nosy: + jaraco, berker.peksag

messages: + msg282992

type: crash -> behavior
2016-12-10 19:12:20noirbizarrecreate