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.

classification
Title: os.tempnam behavior in Windows
Type: Stage:
Components: Extension Modules Versions: Python 2.3
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: fdrake Nosy List: fdrake, rluble, tim.peters
Priority: normal Keywords: patch

Created on 2002-11-08 19:34 by rluble, last changed 2022-04-10 16:05 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
posixmodule.diff rluble, 2002-11-08 19:34 diff for posixmodule.c version 2.3 (file rev 2.271)
Messages (4)
msg41589 - (view) Author: Roberto Lublinerman (rluble) Date: 2002-11-08 19:34
os.tempnam behaviour under windows does no agree 
with the documentation.

Under Windows Temporary location takes precedence 
over specified directory, so tempnam("mydir") returns a 
filename on the temporary location instead of "mydir"

Reason: tempnam is implemented under Windows as a 
call to _tempname which behaves as described above 
acording to MS documentation.

Change: use GetTempFileName to get the desired 
behaviour.

File Modified: Modules/posixmodule.c

Error detected in: python v2.2
Corrected for Python v: 2.3

File revision: 2.271
msg41590 - (view) Author: Tim Peters (tim.peters) * (Python committer) Date: 2002-11-08 20:32
Logged In: YES 
user_id=31435

Assigned to me.
msg41591 - (view) Author: Tim Peters (tim.peters) * (Python committer) Date: 2002-11-08 20:54
Logged In: YES 
user_id=31435

Reassigned to Fred for pondering.  As far as I can tell, the 
Windows _tempnam is trying to emulate more-or-less 
standard Unix tempnam:  the first six man pages I found for 
tempnam on the web say that the envar TMPDIR takes 
precedence over the dir argument, if TMPDIR is writable.  
That's what Windows does too, except the name of the 
envar is TMP on Windows.

If that's so, the implementation of os.tempnam is entirely 
unsurprising, but the Python docs need more words, to 
clarify that the behavior depends on the platform C library.

Roberto, in no case do I expect to apply the patch:  
changing *behavior* here is dangerous to working code, 
and all signs say the function is working as intended, 
although not as documented.  Years of reality take 
precedence over missing docs.  If you need to force a 
particular directoy, see the docs for the tempfile module 
and its tempdir variable.
msg41592 - (view) Author: Fred Drake (fdrake) (Python committer) Date: 2002-11-12 22:08
Logged In: YES 
user_id=3066

Documentation was fixed in Doc/lib/libos.tex revisions 1.103
and 1.74.2.1.2.8.
History
Date User Action Args
2022-04-10 16:05:51adminsetgithub: 37442
2002-11-08 19:34:43rlublecreate