This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author antoine.pietri
Recipients antoine.pietri
Date 2014-03-24.01:32:55
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
The fact that tempfile.TemporaryFile() has a "name" integer attribute  causes weird behavior when interacting with libraries that rely on this attribute being a valid string for file objects.
For instance, it led to this exception with the "tarfile" module, which I resolved by using a NamedTemporaryFile():

>>>, mode='w')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python3.4/", line 1585, in open
    return cls.taropen(name, mode, fileobj, **kwargs)
  File "/usr/lib/python3.4/", line 1595, in taropen
    return cls(name, mode, fileobj, **kwargs)
  File "/usr/lib/python3.4/", line 1431, in __init__ = os.path.abspath(name) if name else None
  File "/usr/lib/python3.4/", line 360, in abspath
    if not isabs(path):
  File "/usr/lib/python3.4/", line 64, in isabs
    return s.startswith(sep)
AttributeError: 'int' object has no attribute 'startswith'

Which is caused by these lines in the "tarfile" module:

if name is None and hasattr(fileobj, "name"):
    name =

If TemporaryFile() didn't have a name attribute, tarfile, which doesn't really need the file name, would simply have continued without errors.

I am not aware of any place where this "name" integer attribute is actually useful, and, as a matter of fact, it is not even documented:
Date User Action Args
2014-03-24 01:32:57antoine.pietrisetrecipients: + antoine.pietri
2014-03-24 01:32:57antoine.pietrisetmessageid: <>
2014-03-24 01:32:57antoine.pietrilinkissue21044 messages
2014-03-24 01:32:55antoine.pietricreate