]> granicus.if.org Git - python/commitdiff
Merged revisions 83951 via svnmerge from
authorBenjamin Peterson <benjamin@python.org>
Wed, 11 Aug 2010 19:24:27 +0000 (19:24 +0000)
committerBenjamin Peterson <benjamin@python.org>
Wed, 11 Aug 2010 19:24:27 +0000 (19:24 +0000)
svn+ssh://pythondev@svn.python.org/python/branches/py3k

........
  r83951 | benjamin.peterson | 2010-08-11 14:20:42 -0500 (Wed, 11 Aug 2010) | 4 lines

  use pep 383 decoding for mknod and mkfifo #9570

  Patch by David Watson.
........

Misc/NEWS
Modules/posixmodule.c

index 7ce826dd421f97b0598a9e7e5e4be4d0743ded9b..fd309748c90188492fffc237f5c92d01c9078942 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -417,6 +417,8 @@ Library
 Extension Modules
 -----------------
 
+- Issue #9570: Use PEP 383 decoding in os.mknod and os.mkfifo.
+
 - Issue #9324: Add parameter validation to signal.signal on Windows in order
   to prevent crashes.
 
index d6e491cc969d97bf596f3b74469b6ee0139dce54..951323bc91a05300c4db262362073ba2256fc1a8 100644 (file)
@@ -5272,14 +5272,18 @@ Create a FIFO (a POSIX named pipe).");
 static PyObject *
 posix_mkfifo(PyObject *self, PyObject *args)
 {
+    PyObject *opath;
     char *filename;
     int mode = 0666;
     int res;
-    if (!PyArg_ParseTuple(args, "s|i:mkfifo", &filename, &mode))
+    if (!PyArg_ParseTuple(args, "O&|i:mkfifo", PyUnicode_FSConverter, &opath,
+                          &mode))
         return NULL;
+    filename = PyBytes_AS_STRING(opath);
     Py_BEGIN_ALLOW_THREADS
     res = mkfifo(filename, mode);
     Py_END_ALLOW_THREADS
+    Py_DECREF(opath);
     if (res < 0)
         return posix_error();
     Py_INCREF(Py_None);
@@ -5302,15 +5306,19 @@ os.makedev()), otherwise it is ignored.");
 static PyObject *
 posix_mknod(PyObject *self, PyObject *args)
 {
+    PyObject *opath;
     char *filename;
     int mode = 0600;
     int device = 0;
     int res;
-    if (!PyArg_ParseTuple(args, "s|ii:mknod", &filename, &mode, &device))
+    if (!PyArg_ParseTuple(args, "O&|ii:mknod", PyUnicode_FSConverter, &opath,
+                          &mode, &device))
         return NULL;
+    filename = PyBytes_AS_STRING(opath);
     Py_BEGIN_ALLOW_THREADS
     res = mknod(filename, mode, device);
     Py_END_ALLOW_THREADS
+    Py_DECREF(opath);
     if (res < 0)
         return posix_error();
     Py_INCREF(Py_None);