Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit d4efbf9

Browse files
committed
use pep 383 decoding for mknod and mkfifo #9570
Patch by David Watson.
1 parent f0f4514 commit d4efbf9

2 files changed

Lines changed: 12 additions & 2 deletions

File tree

Misc/NEWS

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ Core and Builtins
3030
Extensions
3131
----------
3232

33+
- Issue #9570: Use PEP 383 decoding in os.mknod and os.mkfifo.
34+
3335
- Issue #6915: Under Windows, os.listdir() didn't release the Global
3436
Interpreter Lock around all system calls. Original patch by Ryan Kelly.
3537

Modules/posixmodule.c

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5702,14 +5702,18 @@ Create a FIFO (a POSIX named pipe).");
57025702
static PyObject *
57035703
posix_mkfifo(PyObject *self, PyObject *args)
57045704
{
5705+
PyObject *opath;
57055706
char *filename;
57065707
int mode = 0666;
57075708
int res;
5708-
if (!PyArg_ParseTuple(args, "s|i:mkfifo", &filename, &mode))
5709+
if (!PyArg_ParseTuple(args, "O&|i:mkfifo", PyUnicode_FSConverter, &opath,
5710+
&mode))
57095711
return NULL;
5712+
filename = PyBytes_AS_STRING(opath);
57105713
Py_BEGIN_ALLOW_THREADS
57115714
res = mkfifo(filename, mode);
57125715
Py_END_ALLOW_THREADS
5716+
Py_DECREF(opath);
57135717
if (res < 0)
57145718
return posix_error();
57155719
Py_INCREF(Py_None);
@@ -5732,15 +5736,19 @@ os.makedev()), otherwise it is ignored.");
57325736
static PyObject *
57335737
posix_mknod(PyObject *self, PyObject *args)
57345738
{
5739+
PyObject *opath;
57355740
char *filename;
57365741
int mode = 0600;
57375742
int device = 0;
57385743
int res;
5739-
if (!PyArg_ParseTuple(args, "s|ii:mknod", &filename, &mode, &device))
5744+
if (!PyArg_ParseTuple(args, "O&|ii:mknod", PyUnicode_FSConverter, &opath,
5745+
&mode, &device))
57405746
return NULL;
5747+
filename = PyBytes_AS_STRING(opath);
57415748
Py_BEGIN_ALLOW_THREADS
57425749
res = mknod(filename, mode, device);
57435750
Py_END_ALLOW_THREADS
5751+
Py_DECREF(opath);
57445752
if (res < 0)
57455753
return posix_error();
57465754
Py_INCREF(Py_None);

0 commit comments

Comments
 (0)