[Webkit-unassigned] [Bug 37765] REGRESSION(57531): the commit-queue still hates Tor Arne Vestbø

bugzilla-daemon at webkit.org bugzilla-daemon at webkit.org
Sun Apr 18 19:59:40 PDT 2010


https://bugs.webkit.org/show_bug.cgi?id=37765





--- Comment #22 from Chris Jerdonek <cjerdonek at webkit.org>  2010-04-18 19:59:38 PST ---
(In reply to comment #19)

Thanks for your responses, Eric.

> > I understand what you're saying, but maybe the conclusion that should be drawn
> > is that we shouldn't have parse_latest_entry_from_file() as part of our API? 
> > In other words, the caller should be responsible.  That would also be more
> > consistent with the rule of thumb to decode as early as possible.
> 
> Any API which takes a file-like object is rather confusing.  Because the read()
> method is expected to return a byte stream.  However you can use codecs.open()
> to create a file-like object which will return unicode() strings instead of
> str() byte streams from the various methods.

I guess what I was getting at here is that -- following the "decode early"
mantra -- we might want to have parse_latest_entry_from_file() accept a
file-like object from codecs.open() rather than a UTF-8 encoded stream.  That
way parse_latest_entry_from_file() doesn't have to be encoding aware and will
see only unicode strings.

I only bring this up because this issue will probably come up in more spots as
we review more of our code.  Any time we define a function that takes a
file-like object representing text, we'll need to decide if that function
should take a UTF-8 encoded stream, say, or an encoding-aware stream from
codecs.

(The codecs module blurs the recommendations in the slide show somewhat because
you can "decode early" while still seeming to handle a stream of bytes.)

Incidentally, the Python documentation notes that in Python 3, "there is no
longer any need for using the encoding-aware streams in the codecs module."

(from
http://docs.python.org/release/3.0.1/whatsnew/3.0.html#text-vs-data-instead-of-unicode-vs-8-bit
)

-- 
Configure bugmail: https://bugs.webkit.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.



More information about the webkit-unassigned mailing list