[issue9928] weird oddity with bz2 context manager

2015-09-23 Thread Roman Valls

Roman Valls added the comment:

It still seems to be failing with Python 2.7.10... or am I doing sth wrong? :/


$ ipython
Python 2.7.10 |Anaconda 2.2.0 (x86_64)| (default, May 28 2015, 17:04:42)
Type "copyright", "credits" or "license" for more information.

IPython 4.0.0 -- An enhanced Interactive Python.
? -> Introduction and overview of IPython's features.
%quickref -> Quick reference.
help  -> Python's own help system.
object?   -> Details about 'object', use 'object??' for extra details.

In [1]: import bz2
In [2]: import pandas as pd
In [3]: import numpy as np
In [4]: import matplotlib as plt
In [5]: import seaborn as sns
In [6]: import cPickle as pickle

In [7]: with open("./collectl_info.pickle.bz2", "rb") as comp:
   ...: with bz2.decompress(comp.read()) as decomp:
   ...: data, hardware, steps = pickle.load(decomp)
   ...:

---
AttributeErrorTraceback (most recent call last)
 in ()
  1 with open("./collectl_info.pickle.bz2", "rb") as comp:
> 2 with bz2.decompress(comp.read()) as decomp:
  3     data, hardware, steps = pickle.load(decomp)
  4

AttributeError: __exit__

--
nosy: +Roman Valls
versions:  -Python 3.1, Python 3.2

___
Python tracker 
<http://bugs.python.org/issue9928>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue9928] weird oddity with bz2 context manager

2015-09-23 Thread Roman Valls

Roman Valls added the comment:

Gotcha, sorry about that :-S

On Wed, Sep 23, 2015 at 4:43 PM, Armin Rigo  wrote:
>
> Armin Rigo added the comment:
>
> Roman: bz2.decompress(comp.read()) returns a string, so you can't use "with" 
> on it.  This bug was about using "with bz2.BZ2File(...) as f:".
>
> --
>
> ___
> Python tracker 
> <http://bugs.python.org/issue9928>
> ___

--

___
Python tracker 
<http://bugs.python.org/issue9928>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com