[issue2232] Current os.tmpfile() implementation requires admin privs on Vista/2k8.
Trent Nelson
report at bugs.python.org
Wed Mar 5 15:49:02 CET 2008
Trent Nelson added the comment:
With Chris and Ben's comments taken into account, what's the best way to
handle this?
1. Change the test: if the user is not admin, assert os.tmpfile()
returns a permission denied OSError, otherwise, assert return value is
a current file.
2. Alter posix_tmpfile() to warn the user of the situation if the call
fails and we're on Windows:
Index: posixmodule.c
===================================================================
--- posixmodule.c (revision 61233)
+++ posixmodule.c (working copy)
@@ -7029,8 +7029,15 @@
FILE *fp;
fp = tmpfile();
- if (fp == NULL)
+ if (fp == NULL) {
+#ifdef MS_WINDOWS
+ PyErr_Warn(PyExc_RuntimeWarning,
+ "tmpfile creates a file in the root directory and " \
+ "requires administrative privileges, consider using " \
+ "tempfile.mkstemp() instead");
+#endif
return posix_error();
+ }
return PyFile_FromFile(fp, "<tmpfile>", "w+b", fclose);
}
#endif
3. Alter posix_tmpfile() to use _tempnam() on Windows instead, such
admin privileges are no longer required. (Possibly adding a similar
warning that tempfile.mkstemp should be used instead though, as above?)
__________________________________
Tracker <report at bugs.python.org>
<http://bugs.python.org/issue2232>
__________________________________
More information about the Python-bugs-list
mailing list