You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
bpo-1286: fileinput, StringIO, and cStringIO do not support the with protocol
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
assignee=Noneclosed_at=<Date2009-12-04.19:45:14.761>created_at=<Date2009-12-03.10:12:51.830>labels= ['type-bug']
title='StringIO and with statement'updated_at=<Date2009-12-04.19:45:14.760>user='https://bugs.python.org/jmfauth'
When toying with the "with" statement, I fell on this:
Python 2.6.4
>>> withopen('abc.txt', 'r') as f:
for line in f:
print line.rstrip()
abc
def
>>>
>>> import StringIO
>>> fo = StringIO.StringIO('abc\ndef\n')
>>> fo.seek(0)
>>> with fo as f2:
for line in f2:
print line.rstrip()
Traceback (most recent call last):
File "<psi last command>", line 2, in <module>
AttributeError: StringIO instance has no attribute '__exit__'
>>>
>>>
Same result with cStringIO
-----
Python 3.1.1
>>> fo = io.StringIO('abc\ndef\n')
>>> fo.seek(0)
0
>>> with fo as f:
for line in f:
print(line.rstrip())
Activity
jmfauth commentedon Dec 3, 2009
When toying with the "with" statement, I fell on this:
Python 2.6.4
Same result with cStringIO
-----
Python 3.1.1
abc
def
briancurtin commentedon Dec 4, 2009
bpo-1286 looks related