LZMAFile does not support the with statement properly

Bug #1219296 reported by Cristian Ciupitu
This bug affects 1 person
Affects Status Importance Assigned to Milestone

Bug Description

Description of problem:
LZMAFile does not support the with statement properly.

Version-Release number of selected component (if applicable):

How reproducible:
Every time

Steps to Reproduce:
1. Use LZMAFile in a with statement, for example like this:
#!/usr/bin/env python2
import sys
from lzma import LZMAFile

lzmafile = LZMAFile(sys.argv[1])
with lzmafile as f:
    print f.read()

2. Run the script from above, for example like this:
 python2 bug-lzma-with.py /usr/share/gettext/archive.dir.tar.xz

Actual results:
Traceback (most recent call last):
  File "./bug-lzma-with.py", line 7, in <module>
    with tmp as f:
AttributeError: __exit__

Expected results:
No errors

Additional info:
If the dir call is uncommented, the program will work fine.
I'm using python-2.7.5-4.fc19.x86_64.rpm.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers