mirror of https://github.com/python/cpython
Issue #8393: subprocess accepts bytes, bytearray and str with surrogates for
the current working directory. Remove also a trailing space, and replace tabulation indentation by spaces.
This commit is contained in:
parent
9c0e94f95c
commit
0e59cc3fc3
|
@ -315,6 +315,9 @@ C-API
|
||||||
Library
|
Library
|
||||||
-------
|
-------
|
||||||
|
|
||||||
|
- Issue #8393: subprocess accepts bytes, bytearray and str with surrogates for
|
||||||
|
the current working directory.
|
||||||
|
|
||||||
- Issue #7606: XML-RPC traceback stored in X-traceback is now encoded to ASCII
|
- Issue #7606: XML-RPC traceback stored in X-traceback is now encoded to ASCII
|
||||||
using backslashreplace error handler
|
using backslashreplace error handler
|
||||||
|
|
||||||
|
|
|
@ -177,6 +177,7 @@ subprocess_fork_exec(PyObject* self, PyObject *args)
|
||||||
int p2cread, p2cwrite, c2pread, c2pwrite, errread, errwrite;
|
int p2cread, p2cwrite, c2pread, c2pwrite, errread, errwrite;
|
||||||
int errpipe_read, errpipe_write, close_fds, restore_signals;
|
int errpipe_read, errpipe_write, close_fds, restore_signals;
|
||||||
int call_setsid;
|
int call_setsid;
|
||||||
|
PyObject *cwd_obj, *cwd_obj2;
|
||||||
const char *cwd;
|
const char *cwd;
|
||||||
pid_t pid;
|
pid_t pid;
|
||||||
int need_to_reenable_gc = 0;
|
int need_to_reenable_gc = 0;
|
||||||
|
@ -184,8 +185,9 @@ subprocess_fork_exec(PyObject* self, PyObject *args)
|
||||||
Py_ssize_t arg_num;
|
Py_ssize_t arg_num;
|
||||||
|
|
||||||
if (!PyArg_ParseTuple(
|
if (!PyArg_ParseTuple(
|
||||||
args, "OOOzOiiiiiiiiiiO:fork_exec",
|
args, "OOOOOiiiiiiiiiiO:fork_exec",
|
||||||
&process_args, &executable_list, &py_close_fds, &cwd, &env_list,
|
&process_args, &executable_list, &py_close_fds,
|
||||||
|
&cwd_obj, &env_list,
|
||||||
&p2cread, &p2cwrite, &c2pread, &c2pwrite,
|
&p2cread, &p2cwrite, &c2pread, &c2pwrite,
|
||||||
&errread, &errwrite, &errpipe_read, &errpipe_write,
|
&errread, &errwrite, &errpipe_read, &errpipe_write,
|
||||||
&restore_signals, &call_setsid, &preexec_fn))
|
&restore_signals, &call_setsid, &preexec_fn))
|
||||||
|
@ -263,7 +265,19 @@ subprocess_fork_exec(PyObject* self, PyObject *args)
|
||||||
preexec_fn_args_tuple = PyTuple_New(0);
|
preexec_fn_args_tuple = PyTuple_New(0);
|
||||||
if (!preexec_fn_args_tuple)
|
if (!preexec_fn_args_tuple)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
_PyImport_AcquireLock();
|
_PyImport_AcquireLock();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (cwd_obj != Py_None) {
|
||||||
|
if (PyUnicode_FSConverter(cwd_obj, &cwd_obj2) == 0)
|
||||||
|
goto cleanup;
|
||||||
|
if (PyBytes_Check(cwd_obj2))
|
||||||
|
cwd = PyBytes_AS_STRING(cwd_obj2);
|
||||||
|
else
|
||||||
|
cwd = PyByteArray_AS_STRING(cwd_obj2);
|
||||||
|
} else {
|
||||||
|
cwd = NULL;
|
||||||
|
cwd_obj2 = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
pid = fork();
|
pid = fork();
|
||||||
|
@ -291,6 +305,8 @@ subprocess_fork_exec(PyObject* self, PyObject *args)
|
||||||
_exit(255);
|
_exit(255);
|
||||||
return NULL; /* Dead code to avoid a potential compiler warning. */
|
return NULL; /* Dead code to avoid a potential compiler warning. */
|
||||||
}
|
}
|
||||||
|
Py_XDECREF(cwd_obj2);
|
||||||
|
|
||||||
if (pid == -1) {
|
if (pid == -1) {
|
||||||
/* Capture the errno exception before errno can be clobbered. */
|
/* Capture the errno exception before errno can be clobbered. */
|
||||||
PyErr_SetFromErrno(PyExc_OSError);
|
PyErr_SetFromErrno(PyExc_OSError);
|
||||||
|
|
Loading…
Reference in New Issue