summaryrefslogtreecommitdiffstats
path: root/Modules/posixmodule.c
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@gmail.com>2015-03-17 23:22:14 (GMT)
committerVictor Stinner <victor.stinner@gmail.com>2015-03-17 23:22:14 (GMT)
commita555cfcb73cf677a99d29af6fa0bcfe4c35a2aeb (patch)
treefa88ce2ae8c7d2213dc3e80845405d0d8719308a /Modules/posixmodule.c
parent6562b29e13f4da98558636c43a1b242698c8f8d9 (diff)
downloadcpython-a555cfcb73cf677a99d29af6fa0bcfe4c35a2aeb.zip
cpython-a555cfcb73cf677a99d29af6fa0bcfe4c35a2aeb.tar.gz
cpython-a555cfcb73cf677a99d29af6fa0bcfe4c35a2aeb.tar.bz2
Issue #23694: Enhance _Py_open(), it now raises exceptions
* _Py_open() now raises exceptions on error. If open() fails, it raises an OSError with the filename. * _Py_open() now releases the GIL while calling open() * Add _Py_open_noraise() when _Py_open() cannot be used because the GIL is not held
Diffstat (limited to 'Modules/posixmodule.c')
-rw-r--r--Modules/posixmodule.c8
1 files changed, 3 insertions, 5 deletions
diff --git a/Modules/posixmodule.c b/Modules/posixmodule.c
index e47bd84..b8151c3 100644
--- a/Modules/posixmodule.c
+++ b/Modules/posixmodule.c
@@ -7930,7 +7930,7 @@ os_openpty_impl(PyModuleDef *module)
slave_fd = _Py_open(slave_name, O_RDWR);
if (slave_fd < 0)
- goto posix_error;
+ goto error;
#else
master_fd = open(DEV_PTY_FILE, O_RDWR | O_NOCTTY); /* open master */
@@ -7958,8 +7958,8 @@ os_openpty_impl(PyModuleDef *module)
goto posix_error;
slave_fd = _Py_open(slave_name, O_RDWR | O_NOCTTY); /* open slave */
- if (slave_fd < 0)
- goto posix_error;
+ if (slave_fd == -1)
+ goto error;
if (_Py_set_inheritable(master_fd, 0, NULL) < 0)
goto posix_error;
@@ -7977,9 +7977,7 @@ os_openpty_impl(PyModuleDef *module)
posix_error:
posix_error();
-#if defined(HAVE_OPENPTY) || defined(HAVE__GETPTY)
error:
-#endif
if (master_fd != -1)
close(master_fd);
if (slave_fd != -1)