Message927

Author nobody
Recipients
Date 2004-09-01.15:59:49
SpamBayes Score
Marked as misclassified
Message-id
In-reply-to
Content
I'm trying to get the Universal Feed Parser to run
under Jython, and I'm running into a problem where
creating a cStringIO object from a string doesn't
change the mode to "rb", and so the code doesn't know
that it can read from the string.

Specifically, the code I'm trying to execute is:
data = gzip.GzipFile(fileobj=_StringIO(data)).read()

and GzipFile contains the code:

if mode is None:
    if hasattr(fileobj, 'mode'): mode = fileobj.mode
    else: mode = 'rb'

which will set the mode of the GzipFile to "w", because
of the line:
transient public String mode = "w";
in the file:
jython/jython/org/python/modules/cStringIO.java

An off-the-top-of-my-head fix would be to change the
constructor taking a string from:
StringIO(String buf) {
    this.buf = new char[buf.length() + 16];
    write(buf);
    seek(0);
}
to:
StringIO(String buf) {
    this.buf = new char[buf.length() + 16];
    this.mode ="r";
    write(buf);
    seek(0);
}


Please feel free to email me at bwinton@latte.ca if you
need any more details, or explanation.
History
Date User Action Args
2008-02-20 17:17:19adminlinkissue1020517 messages
2008-02-20 17:17:19admincreate