[issue15267] tempfile.TemporaryFile and httplib incompatibility

Serhiy Storchaka report at bugs.python.org
Sat Apr 11 13:46:45 CEST 2015


Serhiy Storchaka added the comment:

More general and simple solution is to make tempfile.NamedTemporaryFile new-style class.

Old-style class:

>>> import tempfile
>>> f = tempfile.NamedTemporaryFile()
>>> len(f)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/serhiy/py/cpython-2.7/Lib/tempfile.py", line 391, in __getattr__
    a = getattr(file, name)
AttributeError: 'file' object has no attribute '__len__'

New-style class:

>>> import tempfile
>>> f = tempfile.NamedTemporaryFile()
>>> len(f)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: object of type '_TemporaryFileWrapper' has no len()

----------
nosy: +serhiy.storchaka

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue15267>
_______________________________________


More information about the Python-bugs-list mailing list