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

bugzilla-daemon at webkit.org bugzilla-daemon at webkit.org
Wed Apr 21 14:18:07 PDT 2010


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





--- Comment #49 from Chris Jerdonek <cjerdonek at webkit.org>  2010-04-21 14:18:05 PST ---
(In reply to comment #47)

> We should *never* be using open() directly.  codecs.open takes an encoding
> parameter (just like Python 3.x open() does).  encoding=None results in
> open()-like, return-a-str-object behavior.

I just wanted to bring attention to a couple other uses of the codecs module
that I noticed in check-webkit-style -- in case they might be useful elsewhere
in webkitpy.  Mainly this code--

    # Change stderr to write with replacement characters so we don't die
    # if we try to print something containing non-ASCII characters.
    stderr = codecs.StreamReaderWriter(sys.stderr,
                                       codecs.getreader('utf8'),
                                       codecs.getwriter('utf8'),
                                       'replace')
    # Setting an "encoding" attribute on the stream is necessary to
    # prevent the logging module from raising an error.  See
    # the checker.configure_logging() function for more information.
    stderr.encoding = "UTF-8"

    # FIXME: Change webkitpy.style so that we do not need to overwrite
    #        the global sys.stderr.  This involves updating the code to
    #        accept a stream parameter where necessary, and not calling
    #        sys.stderr explicitly anywhere.
    sys.stderr = stderr

(This is from
http://trac.webkit.org/browser/trunk/WebKitTools/Scripts/check-webkit-style?rev=57467#L61
)

IIRC, this codecs.StreamReaderWriter code was present in its basic form from
the beginning.  I'm not sure when we might want to use this pattern over
codecs.open(), but perhaps it might be useful elsewhere.

Note also the use of the errors='replace' parameter, which codecs.open() also
accepts.  The "errors" parameter in these methods controls how bad bytes should
be handled when encountered while reading from or writing to a stream.  There
may be cases where we want to be more lenient than the default value of
errors='strict' and continue processing a file if possible.  It doesn't look
like the errors parameter is being used in any of the codecs.open() calls in
this patch (which could very well be exactly what we want).

-- 
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