@@ -1280,10 +1280,6 @@ fildes_converter(PyObject *o, void *p)
12801280 fd = PyObject_AsFileDescriptor (o );
12811281 if (fd < 0 )
12821282 return 0 ;
1283- if (!_PyVerify_fd (fd )) {
1284- posix_error ();
1285- return 0 ;
1286- }
12871283 * pointer = fd ;
12881284 return 1 ;
12891285}
@@ -1294,9 +1290,14 @@ posix_fildes_fd(int fd, int (*func)(int))
12941290 int res ;
12951291 int async_err = 0 ;
12961292
1293+ if (!_PyVerify_fd (fd ))
1294+ return posix_error ();
1295+
12971296 do {
12981297 Py_BEGIN_ALLOW_THREADS
1298+ _Py_BEGIN_SUPPRESS_IPH
12991299 res = (* func )(fd );
1300+ _Py_END_SUPPRESS_IPH
13001301 Py_END_ALLOW_THREADS
13011302 } while (res != 0 && errno == EINTR && !(async_err = PyErr_CheckSignals ()));
13021303 if (res != 0 )
@@ -4359,6 +4360,7 @@ os_unlink_impl(PyModuleDef *module, path_t *path, int dir_fd)
43594360 int result ;
43604361
43614362 Py_BEGIN_ALLOW_THREADS
4363+ _Py_BEGIN_SUPPRESS_IPH
43624364#ifdef MS_WINDOWS
43634365 if (path -> wide )
43644366 result = Py_DeleteFileW (path -> wide );
@@ -4373,6 +4375,7 @@ os_unlink_impl(PyModuleDef *module, path_t *path, int dir_fd)
43734375#endif /* HAVE_UNLINKAT */
43744376 result = unlink (path -> narrow );
43754377#endif
4378+ _Py_END_SUPPRESS_IPH
43764379 Py_END_ALLOW_THREADS
43774380
43784381 if (result )
@@ -7692,6 +7695,7 @@ os_open_impl(PyModuleDef *module, path_t *path, int flags, int mode, int dir_fd)
76927695 flags |= O_CLOEXEC ;
76937696#endif
76947697
7698+ _Py_BEGIN_SUPPRESS_IPH
76957699 do {
76967700 Py_BEGIN_ALLOW_THREADS
76977701#ifdef MS_WINDOWS
@@ -7707,6 +7711,7 @@ os_open_impl(PyModuleDef *module, path_t *path, int flags, int mode, int dir_fd)
77077711 fd = open (path -> narrow , flags , mode );
77087712 Py_END_ALLOW_THREADS
77097713 } while (fd < 0 && errno == EINTR && !(async_err = PyErr_CheckSignals ()));
7714+ _Py_END_SUPPRESS_IPH
77107715
77117716 if (fd == -1 ) {
77127717 if (!async_err )
@@ -7745,7 +7750,9 @@ os_close_impl(PyModuleDef *module, int fd)
77457750 * for more details.
77467751 */
77477752 Py_BEGIN_ALLOW_THREADS
7753+ _Py_BEGIN_SUPPRESS_IPH
77487754 res = close (fd );
7755+ _Py_END_SUPPRESS_IPH
77497756 Py_END_ALLOW_THREADS
77507757 if (res < 0 )
77517758 return posix_error ();
@@ -7769,9 +7776,11 @@ os_closerange_impl(PyModuleDef *module, int fd_low, int fd_high)
77697776{
77707777 int i ;
77717778 Py_BEGIN_ALLOW_THREADS
7779+ _Py_BEGIN_SUPPRESS_IPH
77727780 for (i = fd_low ; i < fd_high ; i ++ )
77737781 if (_PyVerify_fd (i ))
77747782 close (i );
7783+ _Py_END_SUPPRESS_IPH
77757784 Py_END_ALLOW_THREADS
77767785 Py_RETURN_NONE ;
77777786}
@@ -7823,7 +7832,9 @@ os_dup2_impl(PyModuleDef *module, int fd, int fd2, int inheritable)
78237832 */
78247833#ifdef MS_WINDOWS
78257834 Py_BEGIN_ALLOW_THREADS
7835+ _Py_BEGIN_SUPPRESS_IPH
78267836 res = dup2 (fd , fd2 );
7837+ _Py_END_SUPPRESS_IPH
78277838 Py_END_ALLOW_THREADS
78287839 if (res < 0 )
78297840 return posix_error ();
@@ -7957,11 +7968,13 @@ os_lseek_impl(PyModuleDef *module, int fd, Py_off_t position, int how)
79577968 return -1 ;
79587969 }
79597970 Py_BEGIN_ALLOW_THREADS
7971+ _Py_BEGIN_SUPPRESS_IPH
79607972#ifdef MS_WINDOWS
79617973 result = _lseeki64 (fd , position , how );
79627974#else
79637975 result = lseek (fd , position , how );
79647976#endif
7977+ _Py_END_SUPPRESS_IPH
79657978 Py_END_ALLOW_THREADS
79667979 if (result < 0 )
79677980 posix_error ();
@@ -8168,7 +8181,9 @@ os_pread_impl(PyModuleDef *module, int fd, int length, Py_off_t offset)
81688181
81698182 do {
81708183 Py_BEGIN_ALLOW_THREADS
8184+ _Py_BEGIN_SUPPRESS_IPH
81718185 n = pread (fd , PyBytes_AS_STRING (buffer ), length , offset );
8186+ _Py_END_SUPPRESS_IPH
81728187 Py_END_ALLOW_THREADS
81738188 } while (n < 0 && errno == EINTR && !(async_err = PyErr_CheckSignals ()));
81748189
@@ -8276,6 +8291,7 @@ posix_sendfile(PyObject *self, PyObject *args, PyObject *kwdict)
82768291 }
82778292 }
82788293
8294+ _Py_BEGIN_SUPPRESS_IPH
82798295 do {
82808296 Py_BEGIN_ALLOW_THREADS
82818297#ifdef __APPLE__
@@ -8285,6 +8301,7 @@ posix_sendfile(PyObject *self, PyObject *args, PyObject *kwdict)
82858301#endif
82868302 Py_END_ALLOW_THREADS
82878303 } while (ret < 0 && errno == EINTR && !(async_err = PyErr_CheckSignals ()));
8304+ _Py_END_SUPPRESS_IPH
82888305
82898306 if (sf .headers != NULL)
82908307 iov_cleanup (sf .headers , hbuf , sf .hdr_cnt );
@@ -8401,9 +8418,13 @@ static int
84018418os_isatty_impl (PyModuleDef * module , int fd )
84028419/*[clinic end generated code: output=acec9d3c29d16d33 input=08ce94aa1eaf7b5e]*/
84038420{
8421+ int return_value ;
84048422 if (!_PyVerify_fd (fd ))
84058423 return 0 ;
8406- return isatty (fd );
8424+ _Py_BEGIN_SUPPRESS_IPH
8425+ return_value = isatty (fd );
8426+ _Py_END_SUPPRESS_IPH
8427+ return return_value ;
84078428}
84088429
84098430
@@ -8598,7 +8619,9 @@ os_pwrite_impl(PyModuleDef *module, int fd, Py_buffer *buffer, Py_off_t offset)
85988619
85998620 do {
86008621 Py_BEGIN_ALLOW_THREADS
8622+ _Py_BEGIN_SUPPRESS_IPH
86018623 size = pwrite (fd , buffer -> buf , (size_t )buffer -> len , offset );
8624+ _Py_END_SUPPRESS_IPH
86028625 Py_END_ALLOW_THREADS
86038626 } while (size < 0 && errno == EINTR && !(async_err = PyErr_CheckSignals ()));
86048627
@@ -11193,12 +11216,16 @@ static int
1119311216os_get_inheritable_impl (PyModuleDef * module , int fd )
1119411217/*[clinic end generated code: output=36110bb36efaa21e input=89ac008dc9ab6b95]*/
1119511218{
11196- if (!_PyVerify_fd (fd )){
11219+ int return_value ;
11220+ if (!_PyVerify_fd (fd )) {
1119711221 posix_error ();
1119811222 return -1 ;
1119911223 }
1120011224
11201- return _Py_get_inheritable (fd );
11225+ _Py_BEGIN_SUPPRESS_IPH
11226+ return_value = _Py_get_inheritable (fd );
11227+ _Py_END_SUPPRESS_IPH
11228+ return return_value ;
1120211229}
1120311230
1120411231
@@ -11215,10 +11242,14 @@ static PyObject *
1121511242os_set_inheritable_impl (PyModuleDef * module , int fd , int inheritable )
1121611243/*[clinic end generated code: output=2ac5c6ce8623f045 input=9ceaead87a1e2402]*/
1121711244{
11245+ int result ;
1121811246 if (!_PyVerify_fd (fd ))
1121911247 return posix_error ();
1122011248
11221- if (_Py_set_inheritable (fd , inheritable , NULL ) < 0 )
11249+ _Py_BEGIN_SUPPRESS_IPH
11250+ result = _Py_set_inheritable (fd , inheritable , NULL );
11251+ _Py_END_SUPPRESS_IPH
11252+ if (result < 0 )
1122211253 return NULL ;
1122311254 Py_RETURN_NONE ;
1122411255}
@@ -11289,7 +11320,9 @@ posix_get_blocking(PyObject *self, PyObject *args)
1128911320 if (!_PyVerify_fd (fd ))
1129011321 return posix_error ();
1129111322
11323+ _Py_BEGIN_SUPPRESS_IPH
1129211324 blocking = _Py_get_blocking (fd );
11325+ _Py_END_SUPPRESS_IPH
1129311326 if (blocking < 0 )
1129411327 return NULL ;
1129511328 return PyBool_FromLong (blocking );
@@ -11305,15 +11338,18 @@ PyDoc_STRVAR(set_blocking__doc__,
1130511338static PyObject *
1130611339posix_set_blocking (PyObject * self , PyObject * args )
1130711340{
11308- int fd , blocking ;
11341+ int fd , blocking , result ;
1130911342
1131011343 if (!PyArg_ParseTuple (args , "ii:set_blocking" , & fd , & blocking ))
1131111344 return NULL ;
1131211345
1131311346 if (!_PyVerify_fd (fd ))
1131411347 return posix_error ();
1131511348
11316- if (_Py_set_blocking (fd , blocking ) < 0 )
11349+ _Py_BEGIN_SUPPRESS_IPH
11350+ result = _Py_set_blocking (fd , blocking );
11351+ _Py_END_SUPPRESS_IPH
11352+ if (result < 0 )
1131711353 return NULL ;
1131811354 Py_RETURN_NONE ;
1131911355}
0 commit comments