[Python-checkins] r80105 - in python/branches/py3k: Misc/NEWS Modules/posixmodule.c

victor.stinner python-checkins at python.org
Fri Apr 16 13:45:13 CEST 2010


Author: victor.stinner
Date: Fri Apr 16 13:45:13 2010
New Revision: 80105

Log:
Issue #8412: os.system() now accepts bytes, bytearray and str with
surrogates.


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	Fri Apr 16 13:45:13 2010
@@ -312,6 +312,9 @@
 Library
 -------
 
+- Issue #8412: os.system() now accepts bytes, bytearray and str with
+  surrogates.
+
 - Issue #2987: RFC2732 support for urlparse (IPv6 addresses). Patch by Tony
   Locke and Hans Ulrich Niedermann.
 

Modified: python/branches/py3k/Modules/posixmodule.c
==============================================================================
--- python/branches/py3k/Modules/posixmodule.c	(original)
+++ python/branches/py3k/Modules/posixmodule.c	Fri Apr 16 13:45:13 2010
@@ -2688,18 +2688,23 @@
 	wchar_t *command;
 	if (!PyArg_ParseTuple(args, "u:system", &command))
 		return NULL;
+
+	Py_BEGIN_ALLOW_THREADS
+	sts = _wsystem(command);
+	Py_END_ALLOW_THREADS
 #else
+	PyObject *command_obj;
 	char *command;
-	if (!PyArg_ParseTuple(args, "s:system", &command))
+	if (!PyArg_ParseTuple(args, "O&:system",
+	                      PyUnicode_FSConverter, &command_obj))
 		return NULL;
-#endif
+
+	command = bytes2str(command_obj, 1);
 	Py_BEGIN_ALLOW_THREADS
-#ifdef MS_WINDOWS
-	sts = _wsystem(command);
-#else
 	sts = system(command);
-#endif
 	Py_END_ALLOW_THREADS
+	release_bytes(command_obj);
+#endif
 	return PyLong_FromLong(sts);
 }
 #endif


More information about the Python-checkins mailing list