summaryrefslogtreecommitdiffstats
path: root/Lib/tarfile.py
diff options
context:
space:
mode:
authorBrett Cannon <brett@python.org>2013-06-14 00:57:26 (GMT)
committerBrett Cannon <brett@python.org>2013-06-14 00:57:26 (GMT)
commit0a140668faf18bf7f8d2ea15e57da5e2a0625292 (patch)
tree97522129bc600a6eff09899ae7a177b5f3e980b3 /Lib/tarfile.py
parent9702a17a6ab90d026449dd20631a6f380d007b3d (diff)
downloadcpython-0a140668faf18bf7f8d2ea15e57da5e2a0625292.zip
cpython-0a140668faf18bf7f8d2ea15e57da5e2a0625292.tar.gz
cpython-0a140668faf18bf7f8d2ea15e57da5e2a0625292.tar.bz2
Issue #18200: Update the stdlib (except tests) to use
ModuleNotFoundError.
Diffstat (limited to 'Lib/tarfile.py')
-rw-r--r--Lib/tarfile.py12
1 files changed, 6 insertions, 6 deletions
diff --git a/Lib/tarfile.py b/Lib/tarfile.py
index 06df7df..289aefd 100644
--- a/Lib/tarfile.py
+++ b/Lib/tarfile.py
@@ -50,7 +50,7 @@ import re
try:
import grp, pwd
-except ImportError:
+except ModuleNotFoundError:
grp = pwd = None
# os.symlink on Windows prior to 6.0 raises NotImplementedError
@@ -381,7 +381,7 @@ class _Stream:
if comptype == "gz":
try:
import zlib
- except ImportError:
+ except ModuleNotFoundError:
raise CompressionError("zlib module is not available")
self.zlib = zlib
self.crc = zlib.crc32(b"")
@@ -394,7 +394,7 @@ class _Stream:
elif comptype == "bz2":
try:
import bz2
- except ImportError:
+ except ModuleNotFoundError:
raise CompressionError("bz2 module is not available")
if mode == "r":
self.dbuf = b""
@@ -406,7 +406,7 @@ class _Stream:
elif comptype == "xz":
try:
import lzma
- except ImportError:
+ except ModuleNotFoundError:
raise CompressionError("lzma module is not available")
if mode == "r":
self.dbuf = b""
@@ -1654,7 +1654,7 @@ class TarFile(object):
try:
import bz2
- except ImportError:
+ except ModuleNotFoundError:
raise CompressionError("bz2 module is not available")
fileobj = bz2.BZ2File(fileobj or name, mode,
@@ -1678,7 +1678,7 @@ class TarFile(object):
try:
import lzma
- except ImportError:
+ except ModuleNotFoundError:
raise CompressionError("lzma module is not available")
fileobj = lzma.LZMAFile(fileobj or name, mode, preset=preset)