classification
Title: Recursive variable definition causes sysconfig infinite loop
Type: behavior Stage: patch review
Components: Distutils Versions: Python 3.2, Python 3.1, Python 2.7
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: tarek Nosy List: eric.araujo, georg.brandl, lyren, schmir, tarek
Priority: normal Keywords:

Created on 2004-03-19 03:15 by lyren, last changed 2010-09-07 13:31 by eric.araujo.

Files
File name Uploaded Description Edit
backtrace.txt lyren, 2004-03-19 03:15 Backtrace after Control-C
issue919238_sysconfig_recursive_definition.txt schmir, 2008-01-12 23:13 patch against trunk which fixes this issue
issue919238_sysconfig_recursive_definition.txt schmir, 2008-01-13 00:03 patch against trunk which fixes this issue + test case
Messages (5)
msg20269 - (view) Author: Lyren Brown (lyren) Date: 2004-03-19 03:15
If you put the following line in Modules/Setup:

  SELF=$(SELF)

and then type "make", sysconfig.py's parse_makefile
function gets into an infinite loop.  Attached is a
backtrace after typing Control-C during the infinite loop.

Here is the (honest?) mistake that I made in Setup that
triggered this (Notice the extra "\"):

PURE_STUBLIBS=-lpurify_stubs -lquantify_stubs \
	-L/foo/lib \
	-R/foo/lib \
pure puremodule.c $(WHICH_PURE_PRODUCTS) $(PURE_INCLS)
$(PURE_STUBLIBS)
msg59843 - (view) Author: Ralf Schmitt (schmir) Date: 2008-01-12 23:12
This is still applies for trunk.

I've added the following lines to Makefile (in the top level directory).

SELF=$(SELFA)
SELFA=$(SELF)

Running make then hangs.
I'm attaching a patch, which fixes this issue (against trunk). Running
make now prints:

~/python-trunk/ make                                             
ralf@rat64 ok
sysconfig.py: warning: could not resolve names from makefile (recursive
definition?): {'SELFA': '$(SELF)', 'SELF': '$(SELFA)'}
running build
running build_ext
INFO: Can't locate Tcl/Tk libs and/or headers

Failed to find the necessary bits to build these modules:
_bsddb            _tkinter          bsddb185       
dbm               dl                gdbm           
imageop           sunaudiodev                      
To find the necessary bits, look in setup.py in detect_modules() for the
module's name.

running build_scripts
msg62825 - (view) Author: Georg Brandl (georg.brandl) * (Python committer) Date: 2008-02-23 22:38
Is a "print" really the right way to emit this warning?
msg62980 - (view) Author: Ralf Schmitt (schmir) Date: 2008-02-25 12:40
distutils.extension has:

            if warnings is not None:
                warnings.warn(msg)
            else:
                sys.stderr.write(msg + '\n')
msg115758 - (view) Author: Éric Araujo (eric.araujo) * (Python committer) Date: 2010-09-07 13:31
Thank you for the patch. Review:

1) Why not raise an exception? A recursive variable definition is an error. Tarek, is this behavior change OK?

2) Does this apply to the new top-level sysconfig module and/or distutils.sysconfig?

3) I’d use a more specific name for the test method: test_bogus_variable instead of test_parse_makefile. I would also add a test for SELF=$(SELF) (currently there is only a test for cyclic definition, not recursive).

4) os.unlink(makefile) is not guaranteed to run, for example if the test is stopped or crashes. Put self.addCleanup(os.unlink, makefile) after the mkstemp call instead.

5) I didn’t know there was no “if __name__ == '__main__'” block in this test file, nice catch. There is no need for the intermediate test_main function, though: unittest.main() should be enough.

6) Minor style issues: You can use textwrap.dedent to keep the file contents in the os.write call indented; s/you're/your/; no need to del fd; put spaces around operators (here == and =); don’t add tree blank lines. See PEP 8 for more info.
History
Date User Action Args
2010-09-07 13:31:53eric.araujosetassignee: tarek

messages: + msg115758
nosy: + eric.araujo
2010-08-19 07:04:58BreamoreBoysetstage: patch review
versions: + Python 3.2, - Python 2.6
2009-02-16 16:32:10akitadasetnosy: + tarek
type: behavior
versions: + Python 3.1, Python 2.7, - Python 2.5, Python 2.4, Python 2.3
2008-02-25 12:40:04schmirsetmessages: + msg62980
2008-02-23 22:38:46georg.brandlsetnosy: + georg.brandl
messages: + msg62825
2008-01-13 00:03:06schmirsetfiles: + issue919238_sysconfig_recursive_definition.txt
2008-01-12 23:13:50schmirsetfiles: + issue919238_sysconfig_recursive_definition.txt
2008-01-12 23:12:58schmirsetnosy: + schmir
messages: + msg59843
versions: + Python 2.6, Python 2.5, Python 2.4
2004-03-19 03:15:15lyrencreate