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 bkabrda
Recipients bkabrda
Date 2015-03-18.15:17:05
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1426691826.62.0.385210447346.issue23700@psf.upfronthosting.co.za>
In-reply-to
Content
This bug is very similar to #18879, the only difference is that _TemporaryFileWrapper.__iter__ is the problem (in #18879, __getattr__ was fixed, but __iter__ was not). The real world use case that helped me find this bug is at the bottom of this report, this is a simple reproducer:


>>> import tempfile
>>> for l in tempfile.NamedTemporaryFile(mode='a+b'):
...     print(l)
... 
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ValueError: readline of closed file


I'm attaching a patch that fixes this (+ testcase).

Note: I actually discovered this while using


>>> from urllib.request import urlopen
>>> for l in urlopen('ftp://<some_ftp>'):
...     print(l)
... 
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ValueError: readline of closed file


Opening FTP uses urllib.response, which in turn uses tempfile._TemporaryFileWrapper, which makes this example fail.
History
Date User Action Args
2015-03-18 15:17:06bkabrdasetrecipients: + bkabrda
2015-03-18 15:17:06bkabrdasetmessageid: <1426691826.62.0.385210447346.issue23700@psf.upfronthosting.co.za>
2015-03-18 15:17:06bkabrdalinkissue23700 messages
2015-03-18 15:17:06bkabrdacreate