Logged In: YES
user_id=178886
I found and solved this bug. Patch is request number
1267425. I hope this will make into next release
There are two separate problems:
- jython's cStringIO sets (through reflection) name and mode
attributes for
the created stream. Mode is wrong, always 'w', and name is
used by gzip as a hint that the stream is coming from a
file. Furthermore, cStringIO in cPython does not set these
attributes.
- There is a bug in seek, where the second parameter is
completely ignored (an else missing)
Output from jython:
Jython 2.2a1 on java1.4.2 (JIT: jitc)
Type "copyright", "credits" or "license" for more information.
>>> import cStringIO
>>> a=cStringIO.StringIO("Hello, world!")
>>> dir(a)
['__class__', '__delattr__', '__doc__', '__getattribute__',
'__hash__', '__init__', '__iter__', '__new__', '__repr__',
'__setattr__', '__str__', 'atty', 'close', 'closed',
'flush', 'getvalue', 'isatty', 'mode', 'name', 'read',
'readline', 'readlineNoNl', 'readlines', 'reset', 'seek',
'softspace', 'tell', 'truncate', 'value', 'write',
'writeChar', 'writelines']
>>> a.name
'<cStringIO>'
>>> a.mode
'w'
>>>
Output from python 2.2
>>> import cStringIO
>>> a=cStringIO.StringIO("Hello, world!")
>>> dir(a)
['close', 'flush', 'getvalue', 'isatty', 'read', 'readline',
'readlines', 'reset', 'seek', 'tell', 'truncate']
>>> a.name
Traceback (most recent call last):
File "<stdin>", line 1, in ?
AttributeError: name
>>> a.mode
Traceback (most recent call last):
File "<stdin>", line 1, in ?
AttributeError: mode
Output from python 2.3
>>> import cStringIO
>>> a=cStringIO.StringIO("Hello, world!")
>>> dir(a)
['__class__', '__delattr__', '__doc__', '__getattribute__',
'__hash__', '__init__', '__iter__', '__new__', '__reduce__',
'__reduce_ex__', '__repr__', '__setattr__', '__str__',
'close', 'closed', 'flush', 'getvalue', 'isatty', 'next',
'read', 'readline', 'readlines', 'reset', 'seek', 'tell',
'truncate']
>>> a.name
Traceback (most recent call last):
File "<stdin>", line 1, in ?
AttributeError: 'cStringIO.StringI' object has no attribute
'name'
>>> a.mode
Traceback (most recent call last):
File "<stdin>", line 1, in ?
AttributeError: 'cStringIO.StringI' object has no attribute
'mode'
Output from python 2.4
>>> import cStringIO
>>> a=cStringIO.StringIO("Hello, world!")
>>> dir(a)
['__class__', '__delattr__', '__doc__', '__getattribute__',
'__hash__', '__init__', '__iter__', '__new__', '__reduce__',
'__reduce_ex__', '__repr__', '__setattr__', '__str__',
'close', 'closed', 'flush', 'getvalue', 'isatty', 'next',
'read', 'readline', 'readlines', 'reset', 'seek', 'tell',
'truncate']
>>> a.name
Traceback (most recent call last):
File "<stdin>", line 1, in ?
AttributeError: 'cStringIO.StringI' object has no attribute
'name'
>>> a.mode
Traceback (most recent call last):
File "<stdin>", line 1, in ?
AttributeError: 'cStringIO.StringI' object has no attribute
'mode'
|