[New-bugs-announce] [issue8601] bz2.BZ2File should support "with" protocol per PEP 343

Matt Wartell report at bugs.python.org
Mon May 3 08:54:29 CEST 2010


New submission from Matt Wartell <matt.wartell+pt at gmail.com>:

As the bz2.BZ2File object claims to be a file-like object it should conform to PEP 343 "The 'with' statement" by implementation of the __enter__ and __exit__ methods.


boring, substantiating detail follows:
$ uname -a
Linux tallguy 2.6.32-21-generic #32-Ubuntu SMP Fri Apr 16 08:10:02 UTC 2010 i686 GNU/Linux
$ python
Python 2.6.5 (r265:79063, Apr 16 2010, 13:09:56) 
[GCC 4.4.3] on linux2
>>> with bz2.BZ2File('test.bz2') as infile:
...     pass
... 
AttributeError: 'bz2.BZ2File' object has no attribute '__exit__'

>>> getattr(bz2.BZ2File, '__enter__')
AttributeError: type object 'bz2.BZ2File' has no attribute '__enter__'
>>> getattr(bz2.BZ2File, '__exit__')
AttributeError: type object 'bz2.BZ2File' has no attribute '__exit__'


$ dpkg -l python2.6
ii  python2.6    2.6.5-1ubuntu6     An interactive hig...
$ dpkg -L python2.6 | grep bz2.so
/usr/lib/python2.6/lib-dynload/bz2.so

----------
components: Extension Modules
messages: 104817
nosy: Matt.Wartell
priority: normal
severity: normal
status: open
title: bz2.BZ2File should support "with" protocol per PEP 343
type: behavior
versions: Python 2.6

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue8601>
_______________________________________


More information about the New-bugs-announce mailing list