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 <[EMAIL PROTECTED]>
<http://bugs.python.org/issue2232>
__________________________________
_______________________________________________
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to