classification
Title: distutils.command.config uses fragile constant temporary file name
Type: Stage: needs patch
Components: Distutils Versions: Python 3.10, Python 3.9, Python 3.8
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: Amir, Arfrever, eric.araujo, mgorny, tarek
Priority: normal Keywords: easy

Created on 2013-01-06 12:44 by mgorny, last changed 2020-11-12 09:39 by Amir.

Messages (4)
msg179179 - (view) Author: Michał Górny (mgorny) * Date: 2013-01-06 12:44
The distutils.command.config module reads:

    def _gen_temp_sourcefile(self, body, headers, lang):
        filename = "_configtest" + LANG_EXT[lang]

which means that every time one of the functions is used, a temporary file with the same name will be created. This is really fragile and fails terribly whenever more than one process tries to use the relevant functions in the same working directory.

I believe this code should use the tempfile module to generate unique temporary files names instead.
msg179706 - (view) Author: Éric Araujo (eric.araujo) * (Python committer) Date: 2013-01-11 17:14
Thanks for the report.  Did you find this by looking at the code or while using distutils?  In other words, if this is just a theoretical issue / code quality problem, it won’t be changed.  (distutils is not improved anymore.)
msg179721 - (view) Author: Michał Górny (mgorny) * Date: 2013-01-11 19:24
While using. We run parallel merges with out-of-source builds in Gentoo, and I found this to result in a failure when building the 'egenix-mx-base' package [1] which uses the 'config' command.

[1]:http://pypi.python.org/pypi/egenix-mx-base
msg380808 - (view) Author: Amir Mohamadi (Amir) * Date: 2020-11-12 09:39
Can I open a PR for it?
History
Date User Action Args
2020-11-12 09:39:18Amirsetnosy: + Amir
messages: + msg380808
2020-11-09 00:00:57eric.araujosetassignee: eric.araujo ->
stage: needs patch
2020-11-09 00:00:21iritkatrielsetkeywords: + easy
2020-11-08 23:59:37iritkatrielsetversions: + Python 3.8, Python 3.9, Python 3.10, - Python 2.6, Python 2.7, Python 3.2, Python 3.3, Python 3.4
2013-01-13 08:36:51Arfreversetnosy: + Arfrever
2013-01-11 19:24:36mgornysetmessages: + msg179721
2013-01-11 17:14:55eric.araujosetmessages: + msg179706
versions: + Python 3.4, - Python 3.1
2013-01-06 12:44:37mgornycreate