classification
Title: sysconfig._parse_makefile doesn't expand ${} vars appearing before $() vars
Type: behavior Stage: resolved
Components: Library (Lib) Versions: Python 3.6, Python 3.5
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: doko Nosy List: berker.peksag, doko, python-dev, serhiy.storchaka, tarek
Priority: normal Keywords:

Created on 2015-07-24 12:13 by doko, last changed 2016-01-28 14:59 by berker.peksag. This issue is now closed.

Messages (7)
msg247272 - (view) Author: Matthias Klose (doko) * (Python committer) Date: 2015-07-24 12:13
LIPL has the value

  ${prefix}/lib/python3.5/config-$(VERSION)$(ABIFLAGS)-x86_64-linux-gnu

and the code relies to substitute parameters from the left to the right, but it prefers $() variables. the attached patch substitutes all variables from the left to the right.

diff -r d8229c26dd92 Lib/sysconfig.py
--- a/Lib/sysconfig.py	Fri Jul 24 09:05:59 2015 +0300
+++ b/Lib/sysconfig.py	Fri Jul 24 14:04:57 2015 +0200
@@ -260,7 +260,12 @@
     while len(variables) > 0:
         for name in tuple(variables):
             value = notdone[name]
-            m = _findvar1_rx.search(value) or _findvar2_rx.search(value)
+            m1 = _findvar1_rx.search(value)
+            m2 = _findvar2_rx.search(value)
+            if m1 and m2:
+                m = m1 if m1.start() < m2.start() else m2
+	    else:
+                m = m1 if m1 else m2
             if m is not None:
                 n = m.group(1)
                 found = True
msg247273 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2015-07-24 13:14
Could you please provide an example where unpatched code fails but patched code work?
msg247274 - (view) Author: Matthias Klose (doko) * (Python committer) Date: 2015-07-24 13:27
On 07/24/2015 03:14 PM, Serhiy Storchaka wrote:
>
> Serhiy Storchaka added the comment:
>
> Could you please provide an example where unpatched code fails but patched code work?

yes, see the substitution for the LIBPL macro, which leaves ${prefix} unexpanded.
msg247275 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2015-07-24 13:43
Sorry, I don't understand your example. Could you please provide reproducible Python code? Or better a patch for Lib/test/test_sysconfig.py?
msg258012 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2016-01-11 20:43
New changeset ef84d21f5292 by doko in branch '3.5':
- Issue #24705: Fix sysconfig._parse_makefile not expanding ${} vars
https://hg.python.org/cpython/rev/ef84d21f5292
msg259139 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2016-01-28 14:58
New changeset dec734dfe2fe by Berker Peksag in branch '3.5':
Issue #24705: Add a test case for ef84d21f5292
https://hg.python.org/cpython/rev/dec734dfe2fe

New changeset f9a18032cc22 by Berker Peksag in branch 'default':
Issue #24705: Add a test case for ef84d21f5292
https://hg.python.org/cpython/rev/f9a18032cc22
msg259140 - (view) Author: Berker Peksag (berker.peksag) * (Python committer) Date: 2016-01-28 14:59
I've added a test case for ef84d21f5292. I think this can be closed now. Please reopen if not.
History
Date User Action Args
2016-01-28 14:59:40berker.peksagsetstatus: open -> closed

nosy: + berker.peksag
messages: + msg259140

resolution: fixed
stage: test needed -> resolved
2016-01-28 14:58:29python-devsetmessages: + msg259139
2016-01-11 20:43:37python-devsetnosy: + python-dev
messages: + msg258012
2015-07-24 13:43:54serhiy.storchakasetmessages: + msg247275
2015-07-24 13:27:38dokosetmessages: + msg247274
2015-07-24 13:14:47serhiy.storchakasetnosy: + tarek, serhiy.storchaka
messages: + msg247273

type: behavior
stage: test needed
2015-07-24 12:13:00dokocreate