@@ -95,7 +95,7 @@ def open(file, mode="r", buffering=-1, encoding=None, errors=None,
9595 use line buffering. Other text files use the policy described above
9696 for binary files.
9797
98- encoding is the name of the encoding used to decode or encode the
98+ encoding is the str name of the encoding used to decode or encode the
9999 file. This should only be used in text mode. The default encoding is
100100 platform dependent, but any encoding supported by Python can be
101101 passed. See the codecs module for the list of supported encodings.
@@ -108,9 +108,9 @@ def open(file, mode="r", buffering=-1, encoding=None, errors=None,
108108 See the documentation for codecs.register for a list of the permitted
109109 encoding error strings.
110110
111- newline controls how universal newlines works (it only applies to text
112- mode). It can be None, '', '\n', '\r', and '\r\n'. It works as
113- follows:
111+ newline is a string controlling how universal newlines works (it only
112+ applies to text mode). It can be None, '', '\n', '\r', and '\r\n'. It works
113+ as follows:
114114
115115 * On input, if newline is None, universal newlines mode is
116116 enabled. Lines in the input can end in '\n', '\r', or '\r\n', and
@@ -126,9 +126,9 @@ def open(file, mode="r", buffering=-1, encoding=None, errors=None,
126126 other legal values, any '\n' characters written are translated to
127127 the given string.
128128
129- If closefd is False, the underlying file descriptor will be kept open
130- when the file is closed. This does not work when a file name is given
131- and must be True in that case.
129+ closedfd is a bool. If closefd is False, the underlying file descriptor will
130+ be kept open when the file is closed. This does not work when a file name is
131+ given and must be True in that case.
132132
133133 open() returns a file object whose type depends on the mode, and
134134 through which the standard file operations such as reading and writing
@@ -287,7 +287,7 @@ class IOBase(metaclass=abc.ABCMeta):
287287 ### Internal ###
288288
289289 def _unsupported (self , name ):
290- """Internal: raise an exception for unsupported operations."""
290+ """Internal: raise an IOError exception for unsupported operations."""
291291 raise UnsupportedOperation ("%s.%s() not supported" %
292292 (self .__class__ .__name__ , name ))
293293
@@ -298,18 +298,18 @@ def seek(self, pos, whence=0):
298298
299299 Change the stream position to byte offset offset. offset is
300300 interpreted relative to the position indicated by whence. Values
301- for whence are:
301+ for whence are ints :
302302
303303 * 0 -- start of stream (the default); offset should be zero or positive
304304 * 1 -- current stream position; offset may be negative
305305 * 2 -- end of stream; offset is usually negative
306306
307- Return the new absolute position.
307+ Return an int indicating the new absolute position.
308308 """
309309 self ._unsupported ("seek" )
310310
311311 def tell (self ):
312- """Return current stream position."""
312+ """Return an int indicating the current stream position."""
313313 return self .seek (0 , 1 )
314314
315315 def truncate (self , pos = None ):
@@ -356,7 +356,7 @@ def __del__(self):
356356 ### Inquiries ###
357357
358358 def seekable (self ):
359- """Return whether object supports random access.
359+ """Return a bool indicating whether object supports random access.
360360
361361 If False, seek(), tell() and truncate() will raise UnsupportedOperation.
362362 This method may need to do a test seek().
@@ -371,7 +371,7 @@ def _checkSeekable(self, msg=None):
371371 if msg is None else msg )
372372
373373 def readable (self ):
374- """Return whether object was opened for reading.
374+ """Return a bool indicating whether object was opened for reading.
375375
376376 If False, read() will raise UnsupportedOperation.
377377 """
@@ -385,7 +385,7 @@ def _checkReadable(self, msg=None):
385385 if msg is None else msg )
386386
387387 def writable (self ):
388- """Return whether object was opened for writing.
388+ """Return a bool indicating whether object was opened for writing.
389389
390390 If False, write() and truncate() will raise UnsupportedOperation.
391391 """
@@ -416,7 +416,7 @@ def _checkClosed(self, msg=None):
416416 ### Context manager ###
417417
418418 def __enter__ (self ): # That's a forward reference
419- """Context management protocol. Returns self."""
419+ """Context management protocol. Returns self (an instance of IOBase) ."""
420420 self ._checkClosed ()
421421 return self
422422
@@ -429,14 +429,14 @@ def __exit__(self, *args):
429429 # XXX Should these be present even if unimplemented?
430430
431431 def fileno (self ):
432- """Returns underlying file descriptor if one exists.
432+ """Returns underlying file descriptor (an int) if one exists.
433433
434434 An IOError is raised if the IO object does not use a file descriptor.
435435 """
436436 self ._unsupported ("fileno" )
437437
438438 def isatty (self ):
439- """Return whether this is an 'interactive' stream.
439+ """Return a bool indicating whether this is an 'interactive' stream.
440440
441441 Return False if it can't be determined.
442442 """
@@ -446,9 +446,10 @@ def isatty(self):
446446 ### Readline[s] and writelines ###
447447
448448 def readline (self , limit = - 1 ):
449- r"""Read and return a line from the stream.
449+ r"""Read and return a line of bytes from the stream.
450450
451451 If limit is specified, at most limit bytes will be read.
452+ Limit should be an int.
452453
453454 The line terminator is always b'\n' for binary files; for text
454455 files, the newlines argument to open can be used to select the line
@@ -532,7 +533,7 @@ class RawIOBase(IOBase):
532533 # a subclass doesn't implement either.)
533534
534535 def read (self , n = - 1 ):
535- """Read and return up to n bytes.
536+ """Read and return up to n bytes, where n is an int .
536537
537538 Returns an empty bytes object on EOF, or None if the object is
538539 set not to block and has no data to read.
@@ -559,10 +560,10 @@ def readall(self):
559560 return bytes (res )
560561
561562 def readinto (self , b ):
562- """Read up to len(b) bytes into b.
563+ """Read up to len(b) bytes into bytearray b.
563564
564- Returns number of bytes read (0 for EOF), or None if the object
565- is set not to block and has no data to read.
565+ Returns an int representing the number of bytes read (0 for EOF), or
566+ None if the object is set not to block and has no data to read.
566567 """
567568 self ._unsupported ("readinto" )
568569
@@ -596,7 +597,7 @@ class BufferedIOBase(IOBase):
596597 """
597598
598599 def read (self , n = None ):
599- """Read and return up to n bytes.
600+ """Read and return up to n bytes, where n is an int .
600601
601602 If the argument is omitted, None, or negative, reads and
602603 returns all data until EOF.
@@ -616,16 +617,18 @@ def read(self, n=None):
616617 self ._unsupported ("read" )
617618
618619 def read1 (self , n = None ):
619- """Read up to n bytes with at most one read() system call."""
620+ """Read up to n bytes with at most one read() system call,
621+ where n is an int.
622+ """
620623 self ._unsupported ("read1" )
621624
622625 def readinto (self , b ):
623- """Read up to len(b) bytes into b.
626+ """Read up to len(b) bytes into bytearray b.
624627
625628 Like read(), this may issue multiple reads to the underlying raw
626629 stream, unless the latter is 'interactive'.
627630
628- Returns the number of bytes read (0 for EOF).
631+ Returns an int representing the number of bytes read (0 for EOF).
629632
630633 Raises BlockingIOError if the underlying raw stream has no
631634 data at the moment.
@@ -643,7 +646,7 @@ def readinto(self, b):
643646 return n
644647
645648 def write (self , b ):
646- """Write the given buffer to the IO stream.
649+ """Write the given bytes buffer to the IO stream.
647650
648651 Return the number of bytes written, which is never less than
649652 len(b).
@@ -1272,19 +1275,21 @@ class TextIOBase(IOBase):
12721275 """
12731276
12741277 def read (self , n = - 1 ):
1275- """Read at most n characters from stream.
1278+ """Read at most n characters from stream, where n is an int .
12761279
12771280 Read from underlying buffer until we have n characters or we hit EOF.
12781281 If n is negative or omitted, read until EOF.
1282+
1283+ Returns a string.
12791284 """
12801285 self ._unsupported ("read" )
12811286
12821287 def write (self , s ):
1283- """Write string s to stream."""
1288+ """Write string s to stream and returning an int ."""
12841289 self ._unsupported ("write" )
12851290
12861291 def truncate (self , pos = None ):
1287- """Truncate size to pos."""
1292+ """Truncate size to pos, where pos is an int ."""
12881293 self ._unsupported ("truncate" )
12891294
12901295 def readline (self ):
@@ -1567,6 +1572,7 @@ def isatty(self):
15671572 return self .buffer .isatty ()
15681573
15691574 def write (self , s ):
1575+ 'Write data, where s is a str'
15701576 if self .closed :
15711577 raise ValueError ("write to closed file" )
15721578 if not isinstance (s , str ):
0 commit comments