summaryrefslogtreecommitdiffstats
path: root/Modules/clinic/posixmodule.c.h
diff options
context:
space:
mode:
authorBenjamin Peterson <benjamin@python.org>2017-12-29 21:13:06 (GMT)
committerGitHub <noreply@github.com>2017-12-29 21:13:06 (GMT)
commitbbdb17d19bb1d5443ca4417254e014ad64c04540 (patch)
treefc518799f5fedc84812666d3994fa19aec5f2f8d /Modules/clinic/posixmodule.c.h
parent03220fdb26c0b6a50ce5ed1fdfbf232094b66db6 (diff)
downloadcpython-bbdb17d19bb1d5443ca4417254e014ad64c04540.zip
cpython-bbdb17d19bb1d5443ca4417254e014ad64c04540.tar.gz
cpython-bbdb17d19bb1d5443ca4417254e014ad64c04540.tar.bz2
return the new file descriptor from os.dup2 (closes bpo-32441) (#5041)
Diffstat (limited to 'Modules/clinic/posixmodule.c.h')
-rw-r--r--Modules/clinic/posixmodule.c.h11
1 files changed, 8 insertions, 3 deletions
diff --git a/Modules/clinic/posixmodule.c.h b/Modules/clinic/posixmodule.c.h
index 9decf7a..6f4c028 100644
--- a/Modules/clinic/posixmodule.c.h
+++ b/Modules/clinic/posixmodule.c.h
@@ -3486,7 +3486,7 @@ PyDoc_STRVAR(os_dup2__doc__,
#define OS_DUP2_METHODDEF \
{"dup2", (PyCFunction)os_dup2, METH_FASTCALL|METH_KEYWORDS, os_dup2__doc__},
-static PyObject *
+static int
os_dup2_impl(PyObject *module, int fd, int fd2, int inheritable);
static PyObject *
@@ -3498,12 +3498,17 @@ os_dup2(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwn
int fd;
int fd2;
int inheritable = 1;
+ int _return_value;
if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser,
&fd, &fd2, &inheritable)) {
goto exit;
}
- return_value = os_dup2_impl(module, fd, fd2, inheritable);
+ _return_value = os_dup2_impl(module, fd, fd2, inheritable);
+ if ((_return_value == -1) && PyErr_Occurred()) {
+ goto exit;
+ }
+ return_value = PyLong_FromLong((long)_return_value);
exit:
return return_value;
@@ -6405,4 +6410,4 @@ exit:
#ifndef OS_GETRANDOM_METHODDEF
#define OS_GETRANDOM_METHODDEF
#endif /* !defined(OS_GETRANDOM_METHODDEF) */
-/*[clinic end generated code: output=b6ade5f170d5a431 input=a9049054013a1b77]*/
+/*[clinic end generated code: output=6345053cd5992caf input=a9049054013a1b77]*/