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.

classification
Title: codecs.open problem with "with" statement
Type: Stage:
Components: Library (Lib) Versions: Python 2.5
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: georg.brandl Nosy List: georg.brandl, shauncutts
Priority: normal Keywords:

Created on 2006-10-29 02:56 by shauncutts, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Messages (2)
msg30408 - (view) Author: Shaun Cutts (shauncutts) Date: 2006-10-29 02:56
Codecs.open does not seem to properly support the
"with" protocol. Using codecs.open with "with" and
without "with" hill give different results in a simple
test.

-----------------------------------------
from __future__ import with_statement
import codecs

fn = 'test.txt'
f = open( fn, 'w' )
f.write( '\xc5' )
f.close()


f = codecs.open( fn, 'r', 'L1' )
print repr( f.read() )
f.close()

with codecs.open( fn, 'r', 'L1' ) as f:
    print repr( f.read() )
---------------------------------------
output:
---------------------------------------
u'\xc5'
'\xc5'
---------------------------------------
Note: 2nd string not unicode.
msg30409 - (view) Author: Georg Brandl (georg.brandl) * (Python committer) Date: 2006-10-29 08:39
Logged In: YES 
user_id=849994

Thanks for the report, this is now fixed in rev. 52517,
52518 (2.5).
History
Date User Action Args
2022-04-11 14:56:21adminsetgithub: 44175
2006-10-29 02:56:28shauncuttscreate