diff options
author | Victor Stinner <victor.stinner@haypocalc.com> | 2011-10-12 18:35:02 (GMT) |
---|---|---|
committer | Victor Stinner <victor.stinner@haypocalc.com> | 2011-10-12 18:35:02 (GMT) |
commit | a1bf2984541056449ed86256b2214a1930665657 (patch) | |
tree | b87a66360363cde73a509edb40009dba9bc3a928 /Doc/whatsnew | |
parent | 62ab10a05acdc8bb45549e4df6fd6fb5f4623aab (diff) | |
download | cpython-a1bf2984541056449ed86256b2214a1930665657.zip cpython-a1bf2984541056449ed86256b2214a1930665657.tar.gz cpython-a1bf2984541056449ed86256b2214a1930665657.tar.bz2 |
What's New in Python 3.3: mention the PEP 3151
Diffstat (limited to 'Doc/whatsnew')
-rw-r--r-- | Doc/whatsnew/3.3.rst | 63 |
1 files changed, 63 insertions, 0 deletions
diff --git a/Doc/whatsnew/3.3.rst b/Doc/whatsnew/3.3.rst index 0687d9a..2468d04 100644 --- a/Doc/whatsnew/3.3.rst +++ b/Doc/whatsnew/3.3.rst @@ -109,6 +109,69 @@ XXX Add list of changes introduced by :pep:`393` here: XXX mention new and deprecated functions and macros +PEP 3151: Reworking the OS and IO exception hierarchy +===================================================== + +:pep:`3151` - Reworking the OS and IO exception hierarchy +PEP written and implemented by Antoine Pitrou. + +New subclasses of :exc:`OSError` exceptions: + + * :exc:`BlockingIOError` + * :exc:`ChildProcessError` + * :exc:`ConnectionError` + + * :exc:`BrokenPipeError` + * :exc:`ConnectionAbortedError` + * :exc:`ConnectionRefusedError` + * :exc:`ConnectionResetError` + + * :exc:`FileExistsError` + * :exc:`FileNotFoundError` + * :exc:`InterruptedError` + * :exc:`IsADirectoryError` + * :exc:`NotADirectoryError` + * :exc:`PermissionError` + * :exc:`ProcessLookupError` + * :exc:`TimeoutError` + +The following exceptions have been merged into :exc:`OSError`: + + * :exc:`EnvironmentError` + * :exc:`IOError` + * :exc:`WindowsError` + * :exc:`VMSError` + * :exc:`socket.error` + * :exc:`select.error` + * :exc:`mmap.error` + +Thanks to the new exceptions, common usages of the :mod:`errno` can now be +avoided. For example, the following code written for Python 3.2: :: + + from errno import ENOENT, EACCES, EPERM + + try: + with open("document.txt") as f: + content = f.read() + except IOError as err: + if err.errno == ENOENT: + print("document.txt file is missing") + elif err.errno in (EACCES, EPERM): + print("You are not allowed to read document.txt") + else: + raise + +can now be written without the :mod:`errno` import: :: + + try: + with open("document.txt") as f: + content = f.read() + except FileNotFoundError: + print("document.txt file is missing") + except PermissionError: + print("You are not allowed to read document.txt") + + Other Language Changes ====================== |