]> granicus.if.org Git - python/commitdiff
Replace mentions of IOError
authorAntoine Pitrou <solipsis@pitrou.net>
Wed, 12 Oct 2011 18:10:51 +0000 (20:10 +0200)
committerAntoine Pitrou <solipsis@pitrou.net>
Wed, 12 Oct 2011 18:10:51 +0000 (20:10 +0200)
17 files changed:
Doc/library/atexit.rst
Doc/library/fcntl.rst
Doc/library/functions.rst
Doc/library/gettext.rst
Doc/library/http.cookiejar.rst
Doc/library/http.server.rst
Doc/library/inspect.rst
Doc/library/msvcrt.rst
Doc/library/multiprocessing.rst
Doc/library/os.rst
Doc/library/ossaudiodev.rst
Doc/library/packaging.database.rst
Doc/library/readline.rst
Doc/library/shutil.rst
Doc/library/tarfile.rst
Doc/library/urllib.error.rst
Doc/library/zipimport.rst

index 15b55e854babf6dd99fde277271487a9eeeb2ef4..54131f5614ccabce5033ff2b66b64523121d0490 100644 (file)
@@ -69,7 +69,7 @@ making an explicit call into this module at termination. ::
    try:
        with open("/tmp/counter") as infile:
            _count = int(infile.read())
-   except IOError:
+   except FileNotFoundError:
        _count = 0
 
    def incrcounter(n):
index 6192400c9da1d0b3c1dc3f2545e60670ed0fc34d..9a9cdc16897a659853046a4e84dfb4e5f85f1d2d 100644 (file)
@@ -19,6 +19,11 @@ argument.  This can be an integer file descriptor, such as returned by
 ``sys.stdin.fileno()``, or a :class:`io.IOBase` object, such as ``sys.stdin``
 itself, which provides a :meth:`fileno` that returns a genuine file descriptor.
 
+.. versionchanged:: 3.3
+   Operations in this module used to raise a :exc:`IOError` where they now
+   raise a :exc:`OSError`.
+
+
 The module defines the following functions:
 
 
@@ -40,7 +45,7 @@ The module defines the following functions:
    larger than 1024 bytes, this is most likely to result in a segmentation
    violation or a more subtle data corruption.
 
-   If the :c:func:`fcntl` fails, an :exc:`IOError` is raised.
+   If the :c:func:`fcntl` fails, an :exc:`OSError` is raised.
 
 
 .. function:: ioctl(fd, op[, arg[, mutate_flag]])
@@ -107,7 +112,7 @@ The module defines the following functions:
    When *operation* is :const:`LOCK_SH` or :const:`LOCK_EX`, it can also be
    bitwise ORed with :const:`LOCK_NB` to avoid blocking on lock acquisition.
    If :const:`LOCK_NB` is used and the lock cannot be acquired, an
-   :exc:`IOError` will be raised and the exception will have an *errno*
+   :exc:`OSError` will be raised and the exception will have an *errno*
    attribute set to :const:`EACCES` or :const:`EAGAIN` (depending on the
    operating system; for portability, check for both values).  On at least some
    systems, :const:`LOCK_EX` can only be used if the file descriptor refers to a
index 4ed3ec5d97c0e7252949599b6a156d02cb7825d0..22e2468eb8bc8f49255052f37cf96f97d513333d 100644 (file)
@@ -783,7 +783,7 @@ are always available.  They are listed here in alphabetical order.
 .. function:: open(file, mode='r', buffering=-1, encoding=None, errors=None, newline=None, closefd=True)
 
    Open *file* and return a corresponding stream.  If the file cannot be opened,
-   an :exc:`IOError` is raised.
+   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
@@ -912,6 +912,9 @@ are always available.  They are listed here in alphabetical order.
    (where :func:`open` is declared), :mod:`os`, :mod:`os.path`, :mod:`tempfile`,
    and :mod:`shutil`.
 
+   .. versionchanged:: 3.3
+      :exc:`IOError` used to be raised, it is now an alias of :exc:`OSError`.
+
 
 .. XXX works for bytes too, but should it?
 .. function:: ord(c)
index 0fa022c4b82b80656a0ff7fef591701de461c201..825311bfdc2baf8b4bbcdfd5c623657b7d394716 100644 (file)
@@ -185,10 +185,13 @@ class can also install themselves in the built-in namespace as the function
    translation object from the cache; the actual instance data is still shared with
    the cache.
 
-   If no :file:`.mo` file is found, this function raises :exc:`IOError` if
+   If no :file:`.mo` file is found, this function raises :exc:`OSError` if
    *fallback* is false (which is the default), and returns a
    :class:`NullTranslations` instance if *fallback* is true.
 
+   .. versionchanged:: 3.3
+      :exc:`IOError` used to be raised instead of :exc:`OSError`.
+
 
 .. function:: install(domain, localedir=None, codeset=None, names=None)
 
@@ -342,7 +345,7 @@ The entire set of key/value pairs are placed into a dictionary and set as the
 
 If the :file:`.mo` file's magic number is invalid, or if other problems occur
 while reading the file, instantiating a :class:`GNUTranslations` class can raise
-:exc:`IOError`.
+:exc:`OSError`.
 
 The following methods are overridden from the base class implementation:
 
index 97714968f279563acf45e37e121d10865a7982ed..1fe775f32fee3cc8955be80f01602974d73e18f6 100644 (file)
@@ -40,7 +40,11 @@ The module defines the following exception:
 .. exception:: LoadError
 
    Instances of :class:`FileCookieJar` raise this exception on failure to load
-   cookies from a file.  :exc:`LoadError` is a subclass of :exc:`IOError`.
+   cookies from a file.  :exc:`LoadError` is a subclass of :exc:`OSError`.
+
+   .. versionchanged:: 3.3
+      LoadError was made a subclass of :exc:`OSError` instead of
+      :exc:`IOError`.
 
 
 The following classes are provided:
@@ -257,9 +261,12 @@ contained :class:`Cookie` objects.
    Arguments are as for :meth:`save`.
 
    The named file must be in the format understood by the class, or
-   :exc:`LoadError` will be raised.  Also, :exc:`IOError` may be raised, for
+   :exc:`LoadError` will be raised.  Also, :exc:`OSError` may be raised, for
    example if the file does not exist.
 
+   .. versionchanged:: 3.3
+      :exc:`IOError` used to be raised, it is now an alias of :exc:`OSError`.
+
 
 .. method:: FileCookieJar.revert(filename=None, ignore_discard=False, ignore_expires=False)
 
index b30a661edc0851cf6f1e119af384d31206e330b2..d9aaa728bf0f10283b4c1dd9d2866f3563039300 100644 (file)
@@ -318,7 +318,7 @@ of which this module provides three different variants:
       response if the :func:`listdir` fails.
 
       If the request was mapped to a file, it is opened and the contents are
-      returned.  Any :exc:`IOError` exception in opening the requested file is
+      returned.  Any :exc:`OSError` exception in opening the requested file is
       mapped to a ``404``, ``'File not found'`` error. Otherwise, the content
       type is guessed by calling the :meth:`guess_type` method, which in turn
       uses the *extensions_map* variable.
index d127ce8cfcd72917c23e2296c7c083994c4d6810..ac6ae994369e7d42cd0a8c9bd57bf3290908fdfb 100644 (file)
@@ -355,17 +355,25 @@ Retrieving source code
    argument may be a module, class, method, function, traceback, frame, or code
    object.  The source code is returned as a list of the lines corresponding to the
    object and the line number indicates where in the original source file the first
-   line of code was found.  An :exc:`IOError` is raised if the source code cannot
+   line of code was found.  An :exc:`OSError` is raised if the source code cannot
    be retrieved.
 
+   .. versionchanged:: 3.3
+      :exc:`OSError` is raised instead of :exc:`IOError`, now an alias of the
+      former.
+
 
 .. function:: getsource(object)
 
    Return the text of the source code for an object. The argument may be a module,
    class, method, function, traceback, frame, or code object.  The source code is
-   returned as a single string.  An :exc:`IOError` is raised if the source code
+   returned as a single string.  An :exc:`OSError` is raised if the source code
    cannot be retrieved.
 
+   .. versionchanged:: 3.3
+      :exc:`OSError` is raised instead of :exc:`IOError`, now an alias of the
+      former.
+
 
 .. function:: cleandoc(doc)
 
index 889a0c5eb11cef70ff2a2aa1704c299b51d9152d..9d23720e322566381b966919e4b2d6516c5fe582 100644 (file)
@@ -20,6 +20,11 @@ api. The normal API deals only with ASCII characters and is of limited use
 for internationalized applications. The wide char API should be used where
 ever possible
 
+.. versionchanged:: 3.3
+   Operations in this module now raise :exc:`OSError` where :exc:`IOError`
+   was raised.
+
+
 .. _msvcrt-files:
 
 File Operations
@@ -29,7 +34,7 @@ File Operations
 .. function:: locking(fd, mode, nbytes)
 
    Lock part of a file based on file descriptor *fd* from the C runtime.  Raises
-   :exc:`IOError` on failure.  The locked region of the file extends from the
+   :exc:`OSError` on failure.  The locked region of the file extends from the
    current file position for *nbytes* bytes, and may continue beyond the end of the
    file.  *mode* must be one of the :const:`LK_\*` constants listed below. Multiple
    regions in a file may be locked at the same time, but may not overlap.  Adjacent
@@ -41,13 +46,13 @@ File Operations
 
    Locks the specified bytes. If the bytes cannot be locked, the program
    immediately tries again after 1 second.  If, after 10 attempts, the bytes cannot
-   be locked, :exc:`IOError` is raised.
+   be locked, :exc:`OSError` is raised.
 
 
 .. data:: LK_NBLCK
           LK_NBRLCK
 
-   Locks the specified bytes. If the bytes cannot be locked, :exc:`IOError` is
+   Locks the specified bytes. If the bytes cannot be locked, :exc:`OSError` is
    raised.
 
 
@@ -73,7 +78,7 @@ File Operations
 
 .. function:: get_osfhandle(fd)
 
-   Return the file handle for the file descriptor *fd*.  Raises :exc:`IOError` if
+   Return the file handle for the file descriptor *fd*.  Raises :exc:`OSError` if
    *fd* is not recognized.
 
 
@@ -144,4 +149,4 @@ Other Functions
 .. function:: heapmin()
 
    Force the :c:func:`malloc` heap to clean itself up and return unused blocks to
-   the operating system.  On failure, this raises :exc:`IOError`.
+   the operating system.  On failure, this raises :exc:`OSError`.
index f68efede44c2ab0579b74d80cef64fa4a31de1a0..5df9851328a4c1a14e3dbca16f60baf73ec41b35 100644 (file)
@@ -784,9 +784,14 @@ Connection objects usually created using :func:`Pipe` -- see also
       to receive and the other end has closed.
 
       If *maxlength* is specified and the message is longer than *maxlength*
-      then :exc:`IOError` is raised and the connection will no longer be
+      then :exc:`OSError` is raised and the connection will no longer be
       readable.
 
+      .. versionchanged:: 3.3
+         This function used to raise a :exc:`IOError`, which is now an
+         alias of :exc:`OSError`.
+
+
    .. method:: recv_bytes_into(buffer[, offset])
 
       Read into *buffer* a complete message of byte data sent from the other end
index 636ac24034d321cde9139861ec46724895ce56a4..919077589a03bbdf7aad21a743b4d6ba2114c3b8 100644 (file)
@@ -1426,11 +1426,8 @@ Files and Directories
 
          try:
              fp = open("myfile")
-         except IOError as e:
-             if e.errno == errno.EACCESS:
-                 return "some default data"
-             # Not a permission error.
-             raise
+         except PermissionError:
+             return "some default data"
          else:
              with fp:
                  return fp.read()
index 0a08428409e5cbb038d5d90c3f55b9406719dd0b..51c58579b0a4a36c4c9e4dfcea8b2ef2001603d9 100644 (file)
@@ -38,6 +38,10 @@ the standard audio interface for Linux and recent versions of FreeBSD.
    This probably all warrants a footnote or two, but I don't understand
    things well enough right now to write it!   --GPW
 
+.. versionchanged:: 3.3
+   Operations in this module now raise :exc:`OSError` where :exc:`IOError`
+   was raised.
+
 
 .. seealso::
 
@@ -56,7 +60,7 @@ the standard audio interface for Linux and recent versions of FreeBSD.
    what went wrong.
 
    (If :mod:`ossaudiodev` receives an error from a system call such as
-   :c:func:`open`, :c:func:`write`, or :c:func:`ioctl`, it raises :exc:`IOError`.
+   :c:func:`open`, :c:func:`write`, or :c:func:`ioctl`, it raises :exc:`OSError`.
    Errors detected directly by :mod:`ossaudiodev` result in :exc:`OSSAudioError`.)
 
    (For backwards compatibility, the exception class is also available as
@@ -168,7 +172,7 @@ The following methods each map to exactly one :func:`ioctl` system call.  The
 correspondence is obvious: for example, :meth:`setfmt` corresponds to the
 ``SNDCTL_DSP_SETFMT`` ioctl, and :meth:`sync` to ``SNDCTL_DSP_SYNC`` (this can
 be useful when consulting the OSS documentation).  If the underlying
-:func:`ioctl` fails, they all raise :exc:`IOError`.
+:func:`ioctl` fails, they all raise :exc:`OSError`.
 
 
 .. method:: oss_audio_device.nonblock()
@@ -344,7 +348,7 @@ The mixer object provides two file-like methods:
 .. method:: oss_mixer_device.close()
 
    This method closes the open mixer device file.  Any further attempts to use the
-   mixer after this file is closed will raise an :exc:`IOError`.
+   mixer after this file is closed will raise an :exc:`OSError`.
 
 
 .. method:: oss_mixer_device.fileno()
@@ -403,7 +407,7 @@ The remaining methods are specific to audio mixing:
    returned, but both volumes are the same.
 
    Raises :exc:`OSSAudioError` if an invalid control was is specified, or
-   :exc:`IOError` if an unsupported control is specified.
+   :exc:`OSError` if an unsupported control is specified.
 
 
 .. method:: oss_mixer_device.set(control, (left, right))
@@ -427,7 +431,7 @@ The remaining methods are specific to audio mixing:
 .. method:: oss_mixer_device.set_recsrc(bitmask)
 
    Call this function to specify a recording source.  Returns a bitmask indicating
-   the new recording source (or sources) if successful; raises :exc:`IOError` if an
+   the new recording source (or sources) if successful; raises :exc:`OSError` if an
    invalid source was specified.  To set the current recording source to the
    microphone input::
 
index 5d0ff216d929f1020d107269444427ebb01172c1..aaa2cb9f30ef262e407c488c95f42553d90cb3ce 100644 (file)
@@ -213,7 +213,7 @@ information that can be obtained using functions provided in this module::
    # first create the Distribution instance
    try:
        dist = packaging.database.Distribution(path)
-   except IOError:
+   except FileNotFoundError:
        sys.exit('No such distribution')
 
    print('Information about %r' % dist.name)
index ab5519775b4d92bbe28882ae5abcd75dbe24655f..11346190c2a6ebeb2456523228ac922511b06323 100644 (file)
@@ -199,7 +199,7 @@ normally be executed automatically during interactive sessions from the user's
    histfile = os.path.join(os.path.expanduser("~"), ".pyhist")
    try:
        readline.read_history_file(histfile)
-   except IOError:
+   except FileNotFoundError:
        pass
    import atexit
    atexit.register(readline.write_history_file, histfile)
@@ -224,7 +224,7 @@ support history save/restore. ::
            if hasattr(readline, "read_history_file"):
                try:
                    readline.read_history_file(histfile)
-               except IOError:
+               except FileNotFoundError:
                    pass
                atexit.register(self.save_history, histfile)
 
index d87e605b99ffb6991b00af0a9c27892f83921b16..6cb03b86648b2c4717def10d20e455990f76f606 100644 (file)
@@ -51,11 +51,14 @@ Directory and files operations
    *dst* must be the complete target file name; look at :func:`copy` for a copy that
    accepts a target directory path.  If *src* and *dst* are the same files,
    :exc:`Error` is raised.
-   The destination location must be writable; otherwise,  an :exc:`IOError` exception
+   The destination location must be writable; otherwise,  an :exc:`OSError` exception
    will be raised. If *dst* already exists, it will be replaced.   Special files
    such as character or block devices and pipes cannot be copied with this
    function.  *src* and *dst* are path names given as strings.
 
+   .. versionchanged:: 3.3
+      :exc:`IOError` used to be raised instead of :exc:`OSError`.
+
 
 .. function:: copymode(src, dst)
 
index 9b7071bf69f307def4baec10faa18719e2b00ba6..edae7f17ae018441af15b05529a0c86270465f52 100644 (file)
@@ -262,9 +262,9 @@ be finalized; only the internally used file object will be closed. See the
 
    If *errorlevel* is ``0``, all errors are ignored when using :meth:`TarFile.extract`.
    Nevertheless, they appear as error messages in the debug output, when debugging
-   is enabled.  If ``1``, all *fatal* errors are raised as :exc:`OSError` or
-   :exc:`IOError` exceptions. If ``2``, all *non-fatal* errors are raised as
-   :exc:`TarError` exceptions as well.
+   is enabled.  If ``1``, all *fatal* errors are raised as :exc:`OSError`
+   exceptions. If ``2``, all *non-fatal* errors are raised as :exc:`TarError`
+   exceptions as well.
 
    The *encoding* and *errors* arguments define the character encoding to be
    used for reading or writing the archive and how conversion errors are going
index 793d3e2b1a3a1aec63a65be149f8b1e8342cb39f..e20db276a43c25abb55bd99efe7debf58a8cdeae 100644 (file)
@@ -8,20 +8,23 @@
 
 
 The :mod:`urllib.error` module defines the exception classes for exceptions
-raised by :mod:`urllib.request`.  The base exception class is :exc:`URLError`,
-which inherits from :exc:`IOError`.
+raised by :mod:`urllib.request`.  The base exception class is :exc:`URLError`.
 
 The following exceptions are raised by :mod:`urllib.error` as appropriate:
 
 .. exception:: URLError
 
    The handlers raise this exception (or derived exceptions) when they run into
-   a problem.  It is a subclass of :exc:`IOError`.
+   a problem.  It is a subclass of :exc:`OSError`.
 
    .. attribute:: reason
 
       The reason for this error.  It can be a message string or another
-      exception instance such as :exc:`OSError`.
+      exception instance.
+
+   .. versionchanged:: 3.3
+      :exc:`URLError` has been made a subclass of :exc:`OSError` instead
+      of :exc:`IOError`.
 
 
 .. exception:: HTTPError
index 4f170924e96bc2fe67dc753547447fe7086f0469..b47c35b2369b77ceb4a7f28a060ffb7fd457aaba 100644 (file)
@@ -85,9 +85,12 @@ zipimporter Objects
 
    .. method:: get_data(pathname)
 
-      Return the data associated with *pathname*. Raise :exc:`IOError` if the
+      Return the data associated with *pathname*. Raise :exc:`OSError` if the
       file wasn't found.
 
+      .. versionchanged:: 3.3
+         :exc:`IOError` used to be raised instead of :exc:`OSError`.
+
 
    .. method:: get_filename(fullname)