[Python-Dev] tempfile.mktemp and os.path.exists

Iustin Pop iusty at k1024.org
Sun Nov 9 17:44:45 EST 2003


The tempfile.mktemp function uses os.path.exists to test whether a file
already exists. Since this returns false for broken symbolic links,
wouldn't it be better if the function would actually do an os.lstat on
the filename?

I know the function is not safe by definition, but this issue could
(with a low probability) cause the file to actually be created in
another directory, as the non-existent target of the symlink, instead of
in the given directory (the one in which the symlink resides).

Iustin Pop

More information about the Python-Dev mailing list