Title: tmpnam should not be used if tempfile or mkstemp are available
Type: compile error Stage:
Components: Extension Modules Versions: Python 2.7
Status: closed Resolution: duplicate
Dependencies: Superseder:
Assigned To: Nosy List: djc, flox, mark.dickinson
Priority: normal Keywords:

Created on 2009-09-22 09:21 by djc, last changed 2010-01-10 11:46 by flox. This issue is now closed.

Messages (4)
msg92975 - (view) Author: Dirkjan Ochtman (djc) * (Python committer) Date: 2009-09-22 09:21
I have a bug report in the Gentoo tracker

"This is a rather strange request, but please bear me.
While building Posix module, python checks (among others) for
tmpfile, tmpnam and tmpnam_r
however man pages state explicitly, that in case tmpfile is available, other
two should not be used
if libpython2.5.a is built with either of them, linker complains each
time it's

While this doesn't break anything, it's still a bit annoying.
so I propose to remove functionality as an enhancement:
to change in Modules/posixmodule.c
#ifdef HAVE_TMPNAM && !defined(HAVE_TMPFILE)

Your thoughts?"

man 3 tmpnam state "Never use this function.  Use mkstemp(3) or
tmpfile(3) instead.".

Not sure whether this is exposed anywhere, but I figured this bug would
be better handled upstream from Gentoo.
msg97505 - (view) Author: Florent Xicluna (flox) * (Python committer) Date: 2010-01-10 11:05
I get similar warnings while building on Debian AMD64:

libpython2.7.a(posixmodule.o): In function `posix_tmpnam':
./Modules/posixmodule.c:7193: warning: the use of `tmpnam_r' is dangerous, better use `mkstemp'
libpython2.7.a(posixmodule.o): In function `posix_tempnam':
./Modules/posixmodule.c:7148: warning: the use of `tempnam' is dangerous, better use `mkstemp'
msg97508 - (view) Author: Mark Dickinson (mark.dickinson) * (Python committer) Date: 2010-01-10 11:19
The os.tmpnam and os.tempnam functions are already removed from Python 3.x:  see issue 1318 for the discussion leading to that removal.  I don't see a way to remove them from 2.7 without breaking backwards compatibility.
msg97510 - (view) Author: Florent Xicluna (flox) * (Python committer) Date: 2010-01-10 11:46
Then close it as duplicate of issue486434, which was closed for the same reason.
Date User Action Args
2010-01-10 11:46:48floxsetstatus: open -> closed
resolution: duplicate
messages: + msg97510
2010-01-10 11:19:50mark.dickinsonsetnosy: + mark.dickinson
messages: + msg97508
2010-01-10 11:11:40floxsettype: compile error
2010-01-10 11:05:11floxsetnosy: + flox
messages: + msg97505
2009-09-22 09:21:57djccreate