@@ -82,16 +82,13 @@ internal_close(fileio *self)
8282 int fd = self -> fd ;
8383 self -> fd = -1 ;
8484 /* fd is accessible and someone else may have closed it */
85- if (_PyVerify_fd (fd )) {
86- Py_BEGIN_ALLOW_THREADS
87- err = close (fd );
88- if (err < 0 )
89- save_errno = errno ;
90- Py_END_ALLOW_THREADS
91- } else {
85+ Py_BEGIN_ALLOW_THREADS
86+ _Py_BEGIN_SUPPRESS_IPH
87+ err = close (fd );
88+ if (err < 0 )
9289 save_errno = errno ;
93- err = -1 ;
94- }
90+ _Py_END_SUPPRESS_IPH
91+ Py_END_ALLOW_THREADS
9592 }
9693 if (err < 0 ) {
9794 errno = save_errno ;
@@ -172,12 +169,10 @@ check_fd(int fd)
172169 PyObject * exc ;
173170 char * msg ;
174171
175- if (!_PyVerify_fd (fd )) {
176- goto badfd ;
177- }
178-
179172 Py_BEGIN_ALLOW_THREADS
173+ _Py_BEGIN_SUPPRESS_IPH
180174 res = fstat (fd , & buf );
175+ _Py_END_SUPPRESS_IPH
181176 Py_END_ALLOW_THREADS
182177
183178 if (res < 0 && errno == EBADF ) {
@@ -511,20 +506,19 @@ fileio_readinto(fileio *self, PyObject *args)
511506 if (!PyArg_ParseTuple (args , "w*" , & pbuf ))
512507 return NULL ;
513508
514- if ( _PyVerify_fd ( self -> fd )) {
515- len = pbuf . len ;
516- Py_BEGIN_ALLOW_THREADS
517- errno = 0 ;
509+ len = pbuf . len ;
510+ Py_BEGIN_ALLOW_THREADS
511+ _Py_BEGIN_SUPPRESS_IPH
512+ errno = 0 ;
518513#if defined(MS_WIN64 ) || defined(MS_WINDOWS )
519- if (len > INT_MAX )
520- len = INT_MAX ;
521- n = read (self -> fd , pbuf .buf , (int )len );
514+ if (len > INT_MAX )
515+ len = INT_MAX ;
516+ n = read (self -> fd , pbuf .buf , (int )len );
522517#else
523- n = read (self -> fd , pbuf .buf , len );
518+ n = read (self -> fd , pbuf .buf , len );
524519#endif
525- Py_END_ALLOW_THREADS
526- } else
527- n = -1 ;
520+ _Py_END_SUPPRESS_IPH
521+ Py_END_ALLOW_THREADS
528522 PyBuffer_Release (& pbuf );
529523 if (n < 0 ) {
530524 if (errno == EAGAIN )
@@ -580,8 +574,6 @@ fileio_readall(fileio *self)
580574
581575 if (self -> fd < 0 )
582576 return err_closed ();
583- if (!_PyVerify_fd (self -> fd ))
584- return PyErr_SetFromErrno (PyExc_IOError );
585577
586578 result = PyBytes_FromStringAndSize (NULL , SMALLCHUNK );
587579 if (result == NULL )
@@ -602,6 +594,7 @@ fileio_readall(fileio *self)
602594 return NULL ; /* result has been freed */
603595 }
604596 Py_BEGIN_ALLOW_THREADS
597+ _Py_BEGIN_SUPPRESS_IPH
605598 errno = 0 ;
606599 n = newsize - total ;
607600#if defined(MS_WIN64 ) || defined(MS_WINDOWS )
@@ -615,6 +608,7 @@ fileio_readall(fileio *self)
615608 PyBytes_AS_STRING (result ) + total ,
616609 n );
617610#endif
611+ _Py_END_SUPPRESS_IPH
618612 Py_END_ALLOW_THREADS
619613 if (n == 0 )
620614 break ;
@@ -677,17 +671,16 @@ fileio_read(fileio *self, PyObject *args)
677671 return NULL ;
678672 ptr = PyBytes_AS_STRING (bytes );
679673
680- if ( _PyVerify_fd ( self -> fd )) {
681- Py_BEGIN_ALLOW_THREADS
682- errno = 0 ;
674+ Py_BEGIN_ALLOW_THREADS
675+ _Py_BEGIN_SUPPRESS_IPH
676+ errno = 0 ;
683677#if defined(MS_WIN64 ) || defined(MS_WINDOWS )
684- n = read (self -> fd , ptr , (int )size );
678+ n = read (self -> fd , ptr , (int )size );
685679#else
686- n = read (self -> fd , ptr , size );
680+ n = read (self -> fd , ptr , size );
687681#endif
688- Py_END_ALLOW_THREADS
689- } else
690- n = -1 ;
682+ _Py_END_SUPPRESS_IPH
683+ Py_END_ALLOW_THREADS
691684
692685 if (n < 0 ) {
693686 Py_DECREF (bytes );
@@ -727,20 +720,19 @@ fileio_write(fileio *self, PyObject *args)
727720 return NULL ;
728721 }
729722
730- if ( _PyVerify_fd ( self -> fd )) {
731- Py_BEGIN_ALLOW_THREADS
732- errno = 0 ;
733- len = pbuf .len ;
723+ Py_BEGIN_ALLOW_THREADS
724+ _Py_BEGIN_SUPPRESS_IPH
725+ errno = 0 ;
726+ len = pbuf .len ;
734727#if defined(MS_WIN64 ) || defined(MS_WINDOWS )
735- if (len > INT_MAX )
736- len = INT_MAX ;
737- n = write (self -> fd , pbuf .buf , (int )len );
728+ if (len > INT_MAX )
729+ len = INT_MAX ;
730+ n = write (self -> fd , pbuf .buf , (int )len );
738731#else
739- n = write (self -> fd , pbuf .buf , len );
732+ n = write (self -> fd , pbuf .buf , len );
740733#endif
741- Py_END_ALLOW_THREADS
742- } else
743- n = -1 ;
734+ _Py_END_SUPPRESS_IPH
735+ Py_END_ALLOW_THREADS
744736
745737 PyBuffer_Release (& pbuf );
746738
@@ -793,16 +785,15 @@ portable_lseek(int fd, PyObject *posobj, int whence)
793785 return NULL ;
794786 }
795787
796- if ( _PyVerify_fd ( fd )) {
797- Py_BEGIN_ALLOW_THREADS
788+ Py_BEGIN_ALLOW_THREADS
789+ _Py_BEGIN_SUPPRESS_IPH
798790#if defined(MS_WIN64 ) || defined(MS_WINDOWS )
799- res = _lseeki64 (fd , pos , whence );
791+ res = _lseeki64 (fd , pos , whence );
800792#else
801- res = lseek (fd , pos , whence );
793+ res = lseek (fd , pos , whence );
802794#endif
803- Py_END_ALLOW_THREADS
804- } else
805- res = -1 ;
795+ _Py_END_SUPPRESS_IPH
796+ Py_END_ALLOW_THREADS
806797 if (res < 0 )
807798 return PyErr_SetFromErrno (PyExc_IOError );
808799
0 commit comments