]> granicus.if.org Git - python/commitdiff
Merge #15694: Link discussion of file objects to glossary entry.
authorR David Murray <rdmurray@bitdance.com>
Sat, 18 Aug 2012 00:38:19 +0000 (20:38 -0400)
committerR David Murray <rdmurray@bitdance.com>
Sat, 18 Aug 2012 00:38:19 +0000 (20:38 -0400)
This is analogous to the link for `flie objects` in the description of
'open' that exists in the 2.7 docs, and adds a similar link to the
io docs.

Patch by Chris Jerdonek.

1  2 
Doc/library/functions.rst
Doc/library/io.rst

index de29a1ae22c0967dd40fd8b84da0fa29a7e13b72,753541f41d326609cc5f44a03c8f888a113a5909..e063895428bb8d30384ab7d754deb587266e7fff
@@@ -787,10 -790,13 +787,13 @@@ are always available.  They are listed 
     :meth:`__index__` method that returns an integer.
  
  
 -.. function:: open(file, mode='r', buffering=-1, encoding=None, errors=None, newline=None, closefd=True)
+    .. index::
+       single: file object; open() built-in function
 +.. function:: open(file, mode='r', buffering=-1, encoding=None, errors=None, newline=None, closefd=True, opener=None)
  
-    Open *file* and return a corresponding stream.  If the file cannot be opened,
-    an :exc:`OSError` is raised.
+    Open *file* and return a corresponding :term:`file object`.  If the file
 -   cannot be opened, an :exc:`IOError` is raised.
++   cannot be opened, an :exc:`OSError` is raised.
  
     *file* is either a string or bytes object giving the pathname (absolute or
     relative to the current working directory) of the file to be opened or
     closed.  If a filename is given *closefd* has no effect and must be ``True``
     (the default).
  
-    The type of file object returned by the :func:`open` function depends on the
 +   A custom opener can be used by passing a callable as *opener*. The underlying
 +   file descriptor for the file object is then obtained by calling *opener* with
 +   (*file*, *flags*). *opener* must return an open file descriptor (passing
 +   :mod:`os.open` as *opener* results in functionality similar to passing
 +   ``None``).
 +
 +   .. versionchanged:: 3.3
 +      The *opener* parameter was added.
 +      The ``'x'`` mode was added.
 +
+    The type of :term:`file object` returned by the :func:`open` function
+    depends on the
     mode.  When :func:`open` is used to open a file in a text mode (``'w'``,
     ``'r'``, ``'wt'``, ``'rt'``, etc.), it returns a subclass of
     :class:`io.TextIOBase` (specifically :class:`io.TextIOWrapper`).  When used
Simple merge