Issue 21044: tarfile.open() now handles fileobj with an integer 'name'
attribute. Based on patch by Martin Panter.
diff --git a/Lib/tarfile.py b/Lib/tarfile.py
index 57ea877..db5ff7f 100644
--- a/Lib/tarfile.py
+++ b/Lib/tarfile.py
@@ -1522,7 +1522,8 @@
fileobj = bltn_open(name, self._mode)
self._extfileobj = False
else:
- if name is None and hasattr(fileobj, "name"):
+ if (name is None and hasattr(fileobj, "name") and
+ isinstance(fileobj.name, basestring)):
name = fileobj.name
if hasattr(fileobj, "mode"):
self._mode = fileobj.mode