@@ -319,9 +319,10 @@ def readline(self, size=-1):
319319 non-negative, no more than size bytes will be read (in which
320320 case the line may be incomplete). Returns b'' if already at EOF.
321321 """
322- if not hasattr (size , "__index__" ):
323- raise TypeError ("Integer argument expected" )
324- size = size .__index__ ()
322+ if not isinstance (size , int ):
323+ if not hasattr (size , "__index__" ):
324+ raise TypeError ("Integer argument expected" )
325+ size = size .__index__ ()
325326 with self ._lock :
326327 self ._check_can_read ()
327328 # Shortcut for the common case - the whole line is in the buffer.
@@ -341,9 +342,10 @@ def readlines(self, size=-1):
341342 further lines will be read once the total size of the lines read
342343 so far equals or exceeds size.
343344 """
344- if not hasattr (size , "__index__" ):
345- raise TypeError ("Integer argument expected" )
346- size = size .__index__ ()
345+ if not isinstance (size , int ):
346+ if not hasattr (size , "__index__" ):
347+ raise TypeError ("Integer argument expected" )
348+ size = size .__index__ ()
347349 with self ._lock :
348350 return io .BufferedIOBase .readlines (self , size )
349351
0 commit comments