summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBenjamin Peterson <benjamin@python.org>2010-08-11 19:20:42 (GMT)
committerBenjamin Peterson <benjamin@python.org>2010-08-11 19:20:42 (GMT)
commitd4efbf90d24405f89df07f6e575e3572a0516e85 (patch)
treec8a97f4ce4384e82e598563f27bf7ff317862706
parentf0f45142d52436d26ce8ed888c73496949caae90 (diff)
downloadcpython-d4efbf90d24405f89df07f6e575e3572a0516e85.zip
cpython-d4efbf90d24405f89df07f6e575e3572a0516e85.tar.gz
cpython-d4efbf90d24405f89df07f6e575e3572a0516e85.tar.bz2
use pep 383 decoding for mknod and mkfifo #9570
Patch by David Watson.
-rw-r--r--Misc/NEWS2
-rw-r--r--Modules/posixmodule.c12
2 files changed, 12 insertions, 2 deletions
diff --git a/Misc/NEWS b/Misc/NEWS
index 24f9684..418f8dd 100644
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -30,6 +30,8 @@ Core and Builtins
Extensions
----------
+- Issue #9570: Use PEP 383 decoding in os.mknod and os.mkfifo.
+
- Issue #6915: Under Windows, os.listdir() didn't release the Global
Interpreter Lock around all system calls. Original patch by Ryan Kelly.
diff --git a/Modules/posixmodule.c b/Modules/posixmodule.c
index 449093a..087457e 100644
--- a/Modules/posixmodule.c
+++ b/Modules/posixmodule.c
@@ -5702,14 +5702,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);
@@ -5732,15 +5736,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);