diff options
author | Giampaolo Rodola' <g.rodola@gmail.com> | 2013-02-12 14:14:17 (GMT) |
---|---|---|
committer | Giampaolo Rodola' <g.rodola@gmail.com> | 2013-02-12 14:14:17 (GMT) |
commit | 0166a283f65b08ee2dddb1b075f86862b8c7e3e4 (patch) | |
tree | f319f122b4865fcba24d86fd4d48f3f923cfea8b /Lib/test/support.py | |
parent | b071d4f3da8db02dc5b355590f1f909896592ec3 (diff) | |
download | cpython-0166a283f65b08ee2dddb1b075f86862b8c7e3e4.zip cpython-0166a283f65b08ee2dddb1b075f86862b8c7e3e4.tar.gz cpython-0166a283f65b08ee2dddb1b075f86862b8c7e3e4.tar.bz2 |
modernize some modules' code by replacing OSError->ENOENT/ENOTDIR/EPERM/EEXIST occurrences with the corresponding pep-3151 exceptions (FileNotFoundError, NotADirectoryError, etc.)
Diffstat (limited to 'Lib/test/support.py')
-rw-r--r-- | Lib/test/support.py | 17 |
1 files changed, 6 insertions, 11 deletions
diff --git a/Lib/test/support.py b/Lib/test/support.py index 7f60111..d886ad4 100644 --- a/Lib/test/support.py +++ b/Lib/test/support.py @@ -291,25 +291,20 @@ else: def unlink(filename): try: _unlink(filename) - except OSError as error: - # The filename need not exist. - if error.errno not in (errno.ENOENT, errno.ENOTDIR): - raise + except (FileNotFoundError, NotADirectoryError): + pass def rmdir(dirname): try: _rmdir(dirname) - except OSError as error: - # The directory need not exist. - if error.errno != errno.ENOENT: - raise + except FileNotFoundError: + pass def rmtree(path): try: _rmtree(path) - except OSError as error: - if error.errno != errno.ENOENT: - raise + except FileNotFoundError: + pass def make_legacy_pyc(source): """Move a PEP 3147 pyc/pyo file to its legacy pyc/pyo location. |