[Python-checkins] r83951 - in python/branches/py3k: Misc/NEWS Modules/posixmodule.c
benjamin.peterson
python-checkins at python.org
Wed Aug 11 21:20:43 CEST 2010
Author: benjamin.peterson
Date: Wed Aug 11 21:20:42 2010
New Revision: 83951
Log:
use pep 383 decoding for mknod and mkfifo #9570
Patch by David Watson.
Modified:
python/branches/py3k/Misc/NEWS
python/branches/py3k/Modules/posixmodule.c
Modified: python/branches/py3k/Misc/NEWS
==============================================================================
--- python/branches/py3k/Misc/NEWS (original)
+++ python/branches/py3k/Misc/NEWS Wed Aug 11 21:20:42 2010
@@ -30,6 +30,8 @@
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.
Modified: python/branches/py3k/Modules/posixmodule.c
==============================================================================
--- python/branches/py3k/Modules/posixmodule.c (original)
+++ python/branches/py3k/Modules/posixmodule.c Wed Aug 11 21:20:42 2010
@@ -5702,14 +5702,18 @@
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 @@
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);
More information about the Python-checkins
mailing list