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.

Author trent
Recipients benjamin.peterson, christian.heimes, trent
Date 2008-03-05.14:49:00
SpamBayes Score 0.005188896
Marked as misclassified No
Message-id <1204728542.16.0.991751228498.issue2232@psf.upfronthosting.co.za>
In-reply-to
Content
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?)
History
Date User Action Args
2008-03-05 14:49:02trentsetspambayes_score: 0.0051889 -> 0.005188896
recipients: + trent, christian.heimes, benjamin.peterson
2008-03-05 14:49:02trentsetspambayes_score: 0.0051889 -> 0.0051889
messageid: <1204728542.16.0.991751228498.issue2232@psf.upfronthosting.co.za>
2008-03-05 14:49:01trentlinkissue2232 messages
2008-03-05 14:49:00trentcreate