@@ -1178,34 +1178,6 @@ PyLong_FromPy_off_t(Py_off_t offset)
11781178#endif
11791179}
11801180
1181-
1182- #if defined _MSC_VER && _MSC_VER >= 1400 && _MSC_VER < 1900
1183- /* Legacy implementation of _PyVerify_fd_dup2 while transitioning to
1184- * MSVC 14.0. This should eventually be removed. (issue23524)
1185- */
1186- #define IOINFO_L2E 5
1187- #define IOINFO_ARRAYS 64
1188- #define IOINFO_ARRAY_ELTS (1 << IOINFO_L2E)
1189- #define _NHANDLE_ (IOINFO_ARRAYS * IOINFO_ARRAY_ELTS)
1190- #define _NO_CONSOLE_FILENO (intptr_t)-2
1191-
1192- /* the special case of checking dup2. The target fd must be in a sensible range */
1193- static int
1194- _PyVerify_fd_dup2 (int fd1 , int fd2 )
1195- {
1196- if (!_PyVerify_fd (fd1 ))
1197- return 0 ;
1198- if (fd2 == _NO_CONSOLE_FILENO )
1199- return 0 ;
1200- if ((unsigned )fd2 < _NHANDLE_ )
1201- return 1 ;
1202- else
1203- return 0 ;
1204- }
1205- #else
1206- #define _PyVerify_fd_dup2 (fd1 , fd2 ) (_PyVerify_fd(fd1) && (fd2) >= 0)
1207- #endif
1208-
12091181#ifdef MS_WINDOWS
12101182
12111183static int
@@ -1409,9 +1381,6 @@ posix_fildes_fd(int fd, int (*func)(int))
14091381 int res ;
14101382 int async_err = 0 ;
14111383
1412- if (!_PyVerify_fd (fd ))
1413- return posix_error ();
1414-
14151384 do {
14161385 Py_BEGIN_ALLOW_THREADS
14171386 _Py_BEGIN_SUPPRESS_IPH
@@ -7549,8 +7518,6 @@ os_close_impl(PyObject *module, int fd)
75497518/*[clinic end generated code: output=2fe4e93602822c14 input=2bc42451ca5c3223]*/
75507519{
75517520 int res ;
7552- if (!_PyVerify_fd (fd ))
7553- return posix_error ();
75547521 /* We do not want to retry upon EINTR: see http://lwn.net/Articles/576478/
75557522 * and http://linux.derkeiler.com/Mailing-Lists/Kernel/2005-09/3000.html
75567523 * for more details.
@@ -7583,9 +7550,8 @@ os_closerange_impl(PyObject *module, int fd_low, int fd_high)
75837550 int i ;
75847551 Py_BEGIN_ALLOW_THREADS
75857552 _Py_BEGIN_SUPPRESS_IPH
7586- for (i = fd_low ; i < fd_high ; i ++ )
7587- if (_PyVerify_fd (i ))
7588- close (i );
7553+ for (i = max (fd_low , 0 ); i < fd_high ; i ++ )
7554+ close (i );
75897555 _Py_END_SUPPRESS_IPH
75907556 Py_END_ALLOW_THREADS
75917557 Py_RETURN_NONE ;
@@ -7629,7 +7595,7 @@ os_dup2_impl(PyObject *module, int fd, int fd2, int inheritable)
76297595 int dup3_works = -1 ;
76307596#endif
76317597
7632- if (! _PyVerify_fd_dup2 ( fd , fd2 ) )
7598+ if (fd < 0 || fd2 < 0 )
76337599 return posix_error ();
76347600
76357601 /* dup2() can fail with EINTR if the target FD is already open, because it
@@ -7753,10 +7719,6 @@ os_lseek_impl(PyObject *module, int fd, Py_off_t position, int how)
77537719{
77547720 Py_off_t result ;
77557721
7756- if (!_PyVerify_fd (fd )) {
7757- posix_error ();
7758- return -1 ;
7759- }
77607722#ifdef SEEK_SET
77617723 /* Turn 0, 1, 2 into SEEK_{SET,CUR,END} */
77627724 switch (how ) {
@@ -7769,10 +7731,6 @@ os_lseek_impl(PyObject *module, int fd, Py_off_t position, int how)
77697731 if (PyErr_Occurred ())
77707732 return -1 ;
77717733
7772- if (!_PyVerify_fd (fd )) {
7773- posix_error ();
7774- return -1 ;
7775- }
77767734 Py_BEGIN_ALLOW_THREADS
77777735 _Py_BEGIN_SUPPRESS_IPH
77787736#ifdef MS_WINDOWS
@@ -7980,10 +7938,6 @@ os_pread_impl(PyObject *module, int fd, int length, Py_off_t offset)
79807938 buffer = PyBytes_FromStringAndSize ((char * )NULL , length );
79817939 if (buffer == NULL )
79827940 return NULL ;
7983- if (!_PyVerify_fd (fd )) {
7984- Py_DECREF (buffer );
7985- return posix_error ();
7986- }
79877941
79887942 do {
79897943 Py_BEGIN_ALLOW_THREADS
@@ -8226,8 +8180,6 @@ os_isatty_impl(PyObject *module, int fd)
82268180/*[clinic end generated code: output=6a48c8b4e644ca00 input=08ce94aa1eaf7b5e]*/
82278181{
82288182 int return_value ;
8229- if (!_PyVerify_fd (fd ))
8230- return 0 ;
82318183 _Py_BEGIN_SUPPRESS_IPH
82328184 return_value = isatty (fd );
82338185 _Py_END_SUPPRESS_IPH
@@ -8419,11 +8371,6 @@ os_pwrite_impl(PyObject *module, int fd, Py_buffer *buffer, Py_off_t offset)
84198371 Py_ssize_t size ;
84208372 int async_err = 0 ;
84218373
8422- if (!_PyVerify_fd (fd )) {
8423- posix_error ();
8424- return -1 ;
8425- }
8426-
84278374 do {
84288375 Py_BEGIN_ALLOW_THREADS
84298376 _Py_BEGIN_SUPPRESS_IPH
@@ -8606,9 +8553,6 @@ os_ftruncate_impl(PyObject *module, int fd, Py_off_t length)
86068553 int result ;
86078554 int async_err = 0 ;
86088555
8609- if (!_PyVerify_fd (fd ))
8610- return posix_error ();
8611-
86128556 do {
86138557 Py_BEGIN_ALLOW_THREADS
86148558 _Py_BEGIN_SUPPRESS_IPH
@@ -10979,11 +10923,6 @@ os_get_inheritable_impl(PyObject *module, int fd)
1097910923/*[clinic end generated code: output=0445e20e149aa5b8 input=89ac008dc9ab6b95]*/
1098010924{
1098110925 int return_value ;
10982- if (!_PyVerify_fd (fd )) {
10983- posix_error ();
10984- return -1 ;
10985- }
10986-
1098710926 _Py_BEGIN_SUPPRESS_IPH
1098810927 return_value = _Py_get_inheritable (fd );
1098910928 _Py_END_SUPPRESS_IPH
@@ -11005,8 +10944,6 @@ os_set_inheritable_impl(PyObject *module, int fd, int inheritable)
1100510944/*[clinic end generated code: output=f1b1918a2f3c38c2 input=9ceaead87a1e2402]*/
1100610945{
1100710946 int result ;
11008- if (!_PyVerify_fd (fd ))
11009- return posix_error ();
1101010947
1101110948 _Py_BEGIN_SUPPRESS_IPH
1101210949 result = _Py_set_inheritable (fd , inheritable , NULL );
@@ -11080,9 +11017,6 @@ posix_get_blocking(PyObject *self, PyObject *args)
1108011017 if (!PyArg_ParseTuple (args , "i:get_blocking" , & fd ))
1108111018 return NULL ;
1108211019
11083- if (!_PyVerify_fd (fd ))
11084- return posix_error ();
11085-
1108611020 _Py_BEGIN_SUPPRESS_IPH
1108711021 blocking = _Py_get_blocking (fd );
1108811022 _Py_END_SUPPRESS_IPH
@@ -11106,9 +11040,6 @@ posix_set_blocking(PyObject *self, PyObject *args)
1110611040 if (!PyArg_ParseTuple (args , "ii:set_blocking" , & fd , & blocking ))
1110711041 return NULL ;
1110811042
11109- if (!_PyVerify_fd (fd ))
11110- return posix_error ();
11111-
1111211043 _Py_BEGIN_SUPPRESS_IPH
1111311044 result = _Py_set_blocking (fd , blocking );
1111411045 _Py_END_SUPPRESS_IPH
0 commit comments