Make BZ2File's fileobj support easier to use.
The fileobj argument was added during the 3.3 development cycle, so this change
does not break backward compatibility with 3.2.
diff --git a/Lib/tarfile.py b/Lib/tarfile.py
index 8549677..6d73569 100644
--- a/Lib/tarfile.py
+++ b/Lib/tarfile.py
@@ -1657,8 +1657,8 @@
except ImportError:
raise CompressionError("bz2 module is not available")
- fileobj = bz2.BZ2File(filename=name if fileobj is None else None,
- mode=mode, fileobj=fileobj, compresslevel=compresslevel)
+ fileobj = bz2.BZ2File(fileobj or name, mode,
+ compresslevel=compresslevel)
try:
t = cls.taropen(name, mode, fileobj, **kwargs)