File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -460,6 +460,8 @@ def nreadahead():
460460 return 1
461461 if limit is None :
462462 limit = - 1
463+ elif not isinstance (limit , int ):
464+ raise TypeError ("limit must be an integer" )
463465 res = bytearray ()
464466 while limit < 0 or len (res ) < limit :
465467 b = self .read (nreadahead ())
@@ -1741,6 +1743,8 @@ def readline(self, limit=None):
17411743 raise ValueError ("read from closed file" )
17421744 if limit is None :
17431745 limit = - 1
1746+ elif not isinstance (limit , int ):
1747+ raise TypeError ("limit must be an integer" )
17441748
17451749 # Grab all the decoded text (we will rewind any extra bits later).
17461750 line = self ._get_decoded_chars ()
Original file line number Diff line number Diff line change @@ -319,7 +319,7 @@ def test_buffered_file_io(self):
319319 f .close ()
320320
321321 def test_readline (self ):
322- f = io .open (support .TESTFN , "wb" )
322+ f = self .open (support .TESTFN , "wb" )
323323 f .write (b"abc\n def\n xyzzy\n foo\x00 bar\n another line" )
324324 f .close ()
325325 f = self .open (support .TESTFN , "rb" )
@@ -329,7 +329,10 @@ def test_readline(self):
329329 self .assertEqual (f .readline (4 ), b"zzy\n " )
330330 self .assertEqual (f .readline (), b"foo\x00 bar\n " )
331331 self .assertEqual (f .readline (), b"another line" )
332+ self .assertRaises (TypeError , f .readline , 5.3 )
332333 f .close ()
334+ f = self .open (support .TESTFN , "r" )
335+ self .assertRaises (TypeError , f .readline , 5.3 )
333336
334337 def test_raw_bytes_io (self ):
335338 f = self .BytesIO ()
You can’t perform that action at this time.
0 commit comments