Changeset 58036 in webkit


Ignore:
Timestamp:
Apr 21, 2010 6:34:09 PM (14 years ago)
Author:
eric@webkit.org
Message:

2010-04-21 Eric Seidel <eric@webkit.org>

Reviewed by Adam Barth.

REGRESSION(57531): the commit-queue still hates Tor Arne Vestbø
https://bugs.webkit.org/show_bug.cgi?id=37765

Third time is the charm. I've fixed all the
new-run-webkit-tests regressions from previous attempts.

I fixed the queue to not ignore Tor as a reviwer in r57531,
but instead it throws an exception every time his name is in a patch.

This fixes our Executive.run_command code to work around a Popen
bug http://bugs.python.org/issue5290 whereby python versions before 2.6
do not correctly handle unicode objects as input or output to
Popen.communicate.

Following the advice of:
http://farmdev.com/talks/unicode/
I have changed all of webkitpy to use unicode() objects as strings
instead of str objects (which in Python 3 are renamed "bytes").

String literals were left as "foo" instead of converting to u"foo"
as u"foo" is only required if the string has a non-ascii code point.
Python is smart about comparing str() and unicode() values and will
log an error to the console if the comparison is ever invalid.

Executive.run* now correctly accept and return unicode() objects.
I attempted to fix all the places that we call .write() to make sure we
encode any unicode() objects into utf-8.

I removed several uses of StringIO. StringIO should generally always be
passed a unicode() value.

Likewise I replaced most calls to open() with codecs.open().
codecs.open() matches Python 3 open semantics in requiring an encoding
parameter. Files opened with codecs.open() with a unicode-compatible
encoding will vend unicode() objects from their read() calls, like how
StringIO created with a unicode() object will do.

I also deployed "with" statements wider (now that the project has
settled on Python 2.5) to close a bunch of file descriptor leaks.

  • Scripts/webkitpy/common/checkout/api_unittest.py:
    • Read/write utf-8 files instead of ascii.
    • Update the tests to use test for proper unicode() handling.
  • Scripts/webkitpy/common/checkout/changelog.py:
    • Document that parse_latest_entry_from_file expects file-like objects which return unicode strings.
  • Scripts/webkitpy/common/checkout/changelog_unittest.py:
    • Use unicode() strings instead of str() byte arrays.
    • Deploy "with" to close file descriptor leaks.
  • Scripts/webkitpy/common/checkout/commitinfo.py:
    • Remove unneeded import.
  • Scripts/webkitpy/common/checkout/scm.py:
    • Remove use of str().
  • Scripts/webkitpy/common/checkout/scm_unittest.py:
    • Read/write utf-8 files and use unicode() strings in testing.
  • Scripts/webkitpy/common/config/committers.py:
    • Use \u instead of \x to make slightly clearer what we're doing.
  • Scripts/webkitpy/common/net/bugzilla.py:
    • Add a new _string_contents() method and explain why

we have to call unicode() on the result of soup.string
and why it's safe to do so w/o needing to pass a codec name.

  • Remove the (unused) support for passing a file object to add_patch_to_bug().
  • Scripts/webkitpy/common/net/buildbot.py:
    • Use unicode() instead of str() when needing to coax a

NavigableString object into a unicode() object.

  • Scripts/webkitpy/common/net/buildbot_unittest.py:
    • Add a test which contains a unicode builder name.
  • Scripts/webkitpy/common/net/statusserver.py:
    • Remove use of str()
  • Scripts/webkitpy/common/prettypatch.py:
    • Write out the patch file as utf-8.
  • Scripts/webkitpy/common/system/autoinstall.py:
    • Write out files with a explicit encodings.
    • Deploy "with" to close file descriptor leaks.
  • Scripts/webkitpy/common/system/deprecated_logging.py:
    • Write out log files as utf-8.
  • Scripts/webkitpy/common/system/executive.py:
    • Make run* properly take and return unicode() objects.
    • Cleaned up input handling in run_command a little by adding a _compute_input() method which can return early instead of having such a long/cluttered if-block.
  • Scripts/webkitpy/common/system/executive_unittest.py:
    • Added a unit test to make sure we don't break Tor again!
  • Scripts/webkitpy/layout_tests/layout_package/dump_render_tree_thread.py:
    • Write out the test list as utf-8.
  • Scripts/webkitpy/layout_tests/layout_package/json_results_generator.py:
    • Write out json files as utf-8.
  • Scripts/webkitpy/layout_tests/port/apache_http_server.py:
    • Deploy "with" to close file descriptor leaks.
  • Scripts/webkitpy/layout_tests/port/chromium.py: Add Executive.py FIXME.
  • Scripts/webkitpy/layout_tests/port/chromium_linux.py: ditto.
  • Scripts/webkitpy/layout_tests/port/chromium_mac.py: ditto.
  • Scripts/webkitpy/layout_tests/port/gtk.py: ditto.
  • Scripts/webkitpy/layout_tests/port/mac.py: ditto.
  • Scripts/webkitpy/layout_tests/port/mac_unittest.py:
    • Make the skipped file parsing test unicode.
  • Scripts/webkitpy/layout_tests/port/qt.py: Add Executive.py FIXME.
  • Scripts/webkitpy/layout_tests/port/server_process.py: ditto.
  • Scripts/webkitpy/layout_tests/port/webkit.py:
    • Deploy "with" to close file descriptor leaks.
  • Scripts/webkitpy/layout_tests/port/websocket_server.py:
    • Make explicit the encodings of log files and pid files.
  • Scripts/webkitpy/layout_tests/rebaseline_chromium_webkit_tests.py:
    • Make encodings explicit and deploy "with".
  • Scripts/webkitpy/layout_tests/run_webkit_tests.py: ditto.
  • Scripts/webkitpy/layout_tests/test_types/image_diff.py: ditto.
  • Scripts/webkitpy/layout_tests/test_types/test_type_base.py: ditto.
  • Scripts/webkitpy/layout_tests/test_types/text_diff.py: ditto.
  • Scripts/webkitpy/style/filereader_unittest.py: ditto.
  • Scripts/webkitpy/thirdparty/init.py: ditto.
  • Scripts/webkitpy/tool/commands/earlywarningsystem.py:
    • Removed extra import.
  • Scripts/webkitpy/tool/commands/queues.py:
    • No need to map args to strings now that run_command does.
    • Update test results to match args changes.
    • Document our global argument hacks.
  • Scripts/webkitpy/tool/commands/upload.py:
    • Pass the diff directly to add_patch_to_bug instead of creating a StringIO file wrapper.
  • Scripts/webkitpy/tool/mocktool.py:
    • Rename add_patch_to_bug argument to match bugzilla.py
  • Scripts/webkitpy/tool/steps/abstractstep.py:
    • Executive.run_* now require lists instead of strings. The lack of this change was what broke webkit-patch for svn users the first time this was landed.
  • Scripts/webkitpy/tool/steps/postdiff.py:
    • Pass the diff directly to add_patch_to_bug instead of creating a StringIO file wrapper.
  • Scripts/webkitpy/tool/steps/postdiffforcommit.py: ditto
  • Scripts/webkitpy/tool/steps/postdiffforrevert.py: ditto
  • Scripts/webkitpy/tool/steps/steps_unittest.py:
    • Fixed spurious logging seen when running test-webkitpy
Location:
trunk/WebKitTools
Files:
48 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebKitTools/ChangeLog

    r58031 r58036  
     12010-04-21  Eric Seidel  <eric@webkit.org>
     2
     3        Reviewed by Adam Barth.
     4
     5        REGRESSION(57531): the commit-queue still hates Tor Arne Vestbø
     6        https://bugs.webkit.org/show_bug.cgi?id=37765
     7
     8        Third time is the charm.  I've fixed all the
     9        new-run-webkit-tests regressions from previous attempts.
     10
     11        I fixed the queue to not ignore Tor as a reviwer in r57531,
     12        but instead it throws an exception every time his name is in a patch.
     13
     14        This fixes our Executive.run_command code to work around a Popen
     15        bug http://bugs.python.org/issue5290 whereby python versions before 2.6
     16        do not correctly handle unicode objects as input or output to
     17        Popen.communicate.
     18
     19        Following the advice of:
     20        http://farmdev.com/talks/unicode/
     21        I have changed all of webkitpy to use unicode() objects as strings
     22        instead of str objects (which in Python 3 are renamed "bytes").
     23
     24        String literals were left as "foo" instead of converting to u"foo"
     25        as u"foo" is only required if the string has a non-ascii code point.
     26        Python is smart about comparing str() and unicode() values and will
     27        log an error to the console if the comparison is ever invalid.
     28
     29        Executive.run* now correctly accept and return unicode() objects.
     30        I attempted to fix all the places that we call .write() to make sure we
     31        encode any unicode() objects into utf-8.
     32
     33        I removed several uses of StringIO.  StringIO should generally always be
     34        passed a unicode() value.
     35
     36        Likewise I replaced most calls to open() with codecs.open().
     37        codecs.open() matches Python 3 open semantics in requiring an encoding
     38        parameter.  Files opened with codecs.open() with a unicode-compatible
     39        encoding will vend unicode() objects from their read() calls, like how
     40        StringIO created with a unicode() object will do.
     41
     42        I also deployed "with" statements wider (now that the project has
     43        settled on Python 2.5) to close a bunch of file descriptor leaks.
     44
     45        * Scripts/webkitpy/common/checkout/api_unittest.py:
     46         - Read/write utf-8 files instead of ascii.
     47         - Update the tests to use test for proper unicode() handling.
     48        * Scripts/webkitpy/common/checkout/changelog.py:
     49         - Document that parse_latest_entry_from_file expects
     50           file-like objects which return unicode strings.
     51        * Scripts/webkitpy/common/checkout/changelog_unittest.py:
     52         - Use unicode() strings instead of str() byte arrays.
     53         - Deploy "with" to close file descriptor leaks.
     54        * Scripts/webkitpy/common/checkout/commitinfo.py:
     55         - Remove unneeded import.
     56        * Scripts/webkitpy/common/checkout/scm.py:
     57         - Remove use of str().
     58        * Scripts/webkitpy/common/checkout/scm_unittest.py:
     59         - Read/write utf-8 files and use unicode() strings in testing.
     60        * Scripts/webkitpy/common/config/committers.py:
     61         - Use \u instead of \x to make slightly clearer what we're doing.
     62        * Scripts/webkitpy/common/net/bugzilla.py:
     63         - Add a new _string_contents() method and explain why
     64            we have to call unicode() on the result of soup.string
     65            and why it's safe to do so w/o needing to pass a codec name.
     66          - Remove the (unused) support for passing a file object to add_patch_to_bug().
     67        * Scripts/webkitpy/common/net/buildbot.py:
     68         - Use unicode() instead of str() when needing to coax a
     69            NavigableString object into a unicode() object.
     70        * Scripts/webkitpy/common/net/buildbot_unittest.py:
     71         - Add a test which contains a unicode builder name.
     72        * Scripts/webkitpy/common/net/statusserver.py:
     73         - Remove use of str()
     74        * Scripts/webkitpy/common/prettypatch.py:
     75         - Write out the patch file as utf-8.
     76        * Scripts/webkitpy/common/system/autoinstall.py:
     77         - Write out files with a explicit encodings.
     78         - Deploy "with" to close file descriptor leaks.
     79        * Scripts/webkitpy/common/system/deprecated_logging.py:
     80         - Write out log files as utf-8.
     81        * Scripts/webkitpy/common/system/executive.py:
     82         - Make run* properly take and return unicode() objects.
     83         - Cleaned up input handling in run_command a little by adding
     84           a _compute_input() method which can return early instead of having
     85           such a long/cluttered if-block.
     86        * Scripts/webkitpy/common/system/executive_unittest.py:
     87         - Added a unit test to make sure we don't break Tor again!
     88        * Scripts/webkitpy/layout_tests/layout_package/dump_render_tree_thread.py:
     89         - Write out the test list as utf-8.
     90        * Scripts/webkitpy/layout_tests/layout_package/json_results_generator.py:
     91         - Write out json files as utf-8.
     92        * Scripts/webkitpy/layout_tests/port/apache_http_server.py:
     93         - Deploy "with" to close file descriptor leaks.
     94        * Scripts/webkitpy/layout_tests/port/chromium.py: Add Executive.py FIXME.
     95        * Scripts/webkitpy/layout_tests/port/chromium_linux.py: ditto.
     96        * Scripts/webkitpy/layout_tests/port/chromium_mac.py: ditto.
     97        * Scripts/webkitpy/layout_tests/port/gtk.py: ditto.
     98        * Scripts/webkitpy/layout_tests/port/mac.py: ditto.
     99        * Scripts/webkitpy/layout_tests/port/mac_unittest.py:
     100         - Make the skipped file parsing test unicode.
     101        * Scripts/webkitpy/layout_tests/port/qt.py: Add Executive.py FIXME.
     102        * Scripts/webkitpy/layout_tests/port/server_process.py: ditto.
     103        * Scripts/webkitpy/layout_tests/port/webkit.py:
     104         - Deploy "with" to close file descriptor leaks.
     105        * Scripts/webkitpy/layout_tests/port/websocket_server.py:
     106         - Make explicit the encodings of log files and pid files.
     107        * Scripts/webkitpy/layout_tests/rebaseline_chromium_webkit_tests.py:
     108         - Make encodings explicit and deploy "with".
     109        * Scripts/webkitpy/layout_tests/run_webkit_tests.py: ditto.
     110        * Scripts/webkitpy/layout_tests/test_types/image_diff.py: ditto.
     111        * Scripts/webkitpy/layout_tests/test_types/test_type_base.py: ditto.
     112        * Scripts/webkitpy/layout_tests/test_types/text_diff.py: ditto.
     113        * Scripts/webkitpy/style/filereader_unittest.py: ditto.
     114        * Scripts/webkitpy/thirdparty/__init__.py: ditto.
     115        * Scripts/webkitpy/tool/commands/earlywarningsystem.py:
     116         - Removed extra import.
     117        * Scripts/webkitpy/tool/commands/queues.py:
     118         - No need to map args to strings now that run_command does.
     119         - Update test results to match args changes.
     120         - Document our global argument hacks.
     121        * Scripts/webkitpy/tool/commands/upload.py:
     122         - Pass the diff directly to add_patch_to_bug instead of creating a StringIO file wrapper.
     123        * Scripts/webkitpy/tool/mocktool.py:
     124         - Rename add_patch_to_bug argument to match bugzilla.py
     125        * Scripts/webkitpy/tool/steps/abstractstep.py:
     126         - Executive.run_* now require lists instead of strings.
     127           The lack of this change was what broke webkit-patch
     128           for svn users the first time this was landed.
     129        * Scripts/webkitpy/tool/steps/postdiff.py:
     130         - Pass the diff directly to add_patch_to_bug instead of creating a StringIO file wrapper.
     131        * Scripts/webkitpy/tool/steps/postdiffforcommit.py: ditto
     132        * Scripts/webkitpy/tool/steps/postdiffforrevert.py: ditto
     133        * Scripts/webkitpy/tool/steps/steps_unittest.py:
     134         - Fixed spurious logging seen when running test-webkitpy
     135
    11362010-04-21  Chris Fleizach  <cfleizach@apple.com>
    2137
  • trunk/WebKitTools/Scripts/webkitpy/common/checkout/api_unittest.py

    r58023 r58036  
    2727# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    2828
     29from __future__ import with_statement
     30
     31import codecs
    2932import os
    3033import shutil
     
    3841from webkitpy.thirdparty.mock import Mock
    3942
     43
    4044# FIXME: Copied from scm_unittest.py
    41 def write_into_file_at_path(file_path, contents):
    42     new_file = open(file_path, 'w')
    43     new_file.write(contents)
    44     new_file.close()
     45def write_into_file_at_path(file_path, contents, encoding="utf-8"):
     46    with codecs.open(file_path, "w", encoding) as file:
     47        file.write(contents)
    4548
    4649
    47 _changelog1entry1 = """2010-03-25  Eric Seidel  <eric@webkit.org>
     50_changelog1entry1 = u"""2010-03-25  Tor Arne Vestb\u00f8  <vestbo@webkit.org>
    4851
    4952        Unreviewed build fix to un-break webkit-patch land.
     
    5457        * Scripts/webkitpy/common/checkout/api.py: import scm.CommitMessage
    5558"""
    56 _changelog1entry2 = """2010-03-25  Adam Barth  <abarth@webkit.org>
     59_changelog1entry2 = u"""2010-03-25  Adam Barth  <abarth@webkit.org>
    5760
    5861        Reviewed by Eric Seidel.
     
    6366        * Scripts/webkitpy/common/checkout/api.py:
    6467"""
    65 _changelog1 = "\n".join([_changelog1entry1, _changelog1entry2])
    66 _changelog2 = """2010-03-25  Eric Seidel  <eric@webkit.org>
     68_changelog1 = u"\n".join([_changelog1entry1, _changelog1entry2])
     69_changelog2 = u"""2010-03-25  Tor Arne Vestb\u00f8  <vestbo@webkit.org>
    6770
    6871        Unreviewed build fix to un-break webkit-patch land.
     
    8083
    8184class CommitMessageForThisCommitTest(unittest.TestCase):
    82     expected_commit_message = """2010-03-25  Eric Seidel  <eric@webkit.org>
     85    expected_commit_message = u"""2010-03-25  Tor Arne Vestb\u00f8  <vestbo@webkit.org>
    8386
    8487        Unreviewed build fix to un-break webkit-patch land.
     
    8891
    8992        * Scripts/webkitpy/common/checkout/api.py: import scm.CommitMessage
    90 2010-03-25  Eric Seidel  <eric@webkit.org>
     932010-03-25  Tor Arne Vestb\u00f8  <vestbo@webkit.org>
    9194
    9295        Unreviewed build fix to un-break webkit-patch land.
     
    138141        commitinfo = checkout.commit_info_for_revision(4)
    139142        self.assertEqual(commitinfo.bug_id(), 36629)
    140         self.assertEqual(commitinfo.author_name(), "Eric Seidel")
    141         self.assertEqual(commitinfo.author_email(), "eric@webkit.org")
     143        self.assertEqual(commitinfo.author_name(), u"Tor Arne Vestb\u00f8")
     144        self.assertEqual(commitinfo.author_email(), "vestbo@webkit.org")
    142145        self.assertEqual(commitinfo.reviewer_text(), None)
    143146        self.assertEqual(commitinfo.reviewer(), None)
  • trunk/WebKitTools/Scripts/webkitpy/common/checkout/changelog.py

    r58023 r58036  
    100100    @staticmethod
    101101    def parse_latest_entry_from_file(changelog_file):
     102        """changelog_file must be a file-like object which returns
     103        unicode strings.  Use codecs.open or StringIO(unicode())
     104        to pass file objects to this class."""
    102105        date_line_regexp = re.compile(ChangeLogEntry.date_line_regexp)
    103106        entry_lines = []
    104107        # The first line should be a date line.
    105108        first_line = changelog_file.readline()
     109        assert(isinstance(first_line, unicode))
    106110        if not date_line_regexp.match(first_line):
    107111            return None
  • trunk/WebKitTools/Scripts/webkitpy/common/checkout/changelog_unittest.py

    r58023 r58036  
    2727# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    2828
    29 import unittest
     29from __future__ import with_statement
     30
     31import codecs
    3032import os
    3133import tempfile
     34import unittest
    3235
    3336from StringIO import StringIO
     
    5356
    5457    # More example text than we need.  Eventually we need to support parsing this all and write tests for the parsing.
    55     _example_changelog = '''2009-08-17  David Kilzer  <ddkilzer@apple.com>
     58    _example_changelog = u"""2009-08-17  Tor Arne Vestb\xf8  <vestbo@webkit.org>
    5659
    5760        <http://webkit.org/b/28393> check-webkit-style: add check for use of std::max()/std::min() instead of MAX()/MIN()
     
    8588
    8689== Rolled over to ChangeLog-2009-06-16 ==
    87 '''
     90"""
    8891
    8992    def test_latest_entry_parse(self):
    90         changelog_contents = "%s\n%s" % (self._example_entry, self._example_changelog)
     93        changelog_contents = u"%s\n%s" % (self._example_entry, self._example_changelog)
    9194        changelog_file = StringIO(changelog_contents)
    9295        latest_entry = ChangeLog.parse_latest_entry_from_file(changelog_file)
     
    98101
    99102    @staticmethod
    100     def _write_tmp_file_with_contents(contents):
     103    def _write_tmp_file_with_contents(byte_array):
     104        assert(isinstance(byte_array, str))
    101105        (file_descriptor, file_path) = tempfile.mkstemp() # NamedTemporaryFile always deletes the file on close in python < 2.6
    102         file = os.fdopen(file_descriptor, 'w')
    103         file.write(contents)
    104         file.close()
     106        with os.fdopen(file_descriptor, "w") as file:
     107            file.write(byte_array)
    105108        return file_path
    106109
    107110    @staticmethod
    108     def _read_file_contents(file_path):
    109         file = open(file_path)
    110         contents = file.read()
    111         file.close()
    112         return contents
     111    def _read_file_contents(file_path, encoding):
     112        with codecs.open(file_path, "r", encoding) as file:
     113            return file.read()
    113114
    114115    _new_entry_boilerplate = '''2009-08-19  Eric Seidel  <eric@webkit.org>
     
    122123
    123124    def test_set_reviewer(self):
    124         changelog_contents = "%s\n%s" % (self._new_entry_boilerplate, self._example_changelog)
    125         changelog_path = self._write_tmp_file_with_contents(changelog_contents)
     125        changelog_contents = u"%s\n%s" % (self._new_entry_boilerplate, self._example_changelog)
     126        changelog_path = self._write_tmp_file_with_contents(changelog_contents.encode("utf-8"))
    126127        reviewer_name = 'Test Reviewer'
    127128        ChangeLog(changelog_path).set_reviewer(reviewer_name)
    128         actual_contents = self._read_file_contents(changelog_path)
     129        actual_contents = self._read_file_contents(changelog_path, "utf-8")
    129130        expected_contents = changelog_contents.replace('NOBODY (OOPS!)', reviewer_name)
    130131        os.remove(changelog_path)
     
    170171
    171172    def _assert_update_for_revert_output(self, args, expected_entry):
    172         changelog_contents = "%s\n%s" % (self._new_entry_boilerplate, self._example_changelog)
    173         changelog_path = self._write_tmp_file_with_contents(changelog_contents)
     173        changelog_contents = u"%s\n%s" % (self._new_entry_boilerplate, self._example_changelog)
     174        changelog_path = self._write_tmp_file_with_contents(changelog_contents.encode("utf-8"))
    174175        changelog = ChangeLog(changelog_path)
    175176        changelog.update_for_revert(*args)
  • trunk/WebKitTools/Scripts/webkitpy/common/checkout/commitinfo.py

    r58023 r58036  
    2828#
    2929# WebKit's python module for holding information on a commit
    30 
    31 import StringIO
    3230
    3331from webkitpy.common.checkout.changelog import view_source_url
  • trunk/WebKitTools/Scripts/webkitpy/common/checkout/scm.py

    r58023 r58036  
    146146
    147147    def strip_r_from_svn_revision(self, svn_revision):
    148         match = re.match("^r(?P<svn_revision>\d+)", svn_revision)
     148        match = re.match("^r(?P<svn_revision>\d+)", unicode(svn_revision))
    149149        if (match):
    150150            return match.group('svn_revision')
     
    345345    def changed_files_for_revision(self, revision):
    346346        # As far as I can tell svn diff --summarize output looks just like svn status output.
    347         status_command = ["svn", "diff", "--summarize", "-c", str(revision)]
     347        status_command = ["svn", "diff", "--summarize", "-c", revision]
    348348        return self.run_status_and_extract_filenames(status_command, self._status_regexp("ACDMR"))
    349349
     
    362362
    363363    def create_patch(self):
    364         return run_command(self.script_path("svn-create-patch"), cwd=self.checkout_root, return_stderr=False)
     364        return run_command([self.script_path("svn-create-patch")], cwd=self.checkout_root, return_stderr=False)
    365365
    366366    def committer_email_for_revision(self, revision):
    367         return run_command(["svn", "propget", "svn:author", "--revprop", "-r", str(revision)]).rstrip()
     367        return run_command(["svn", "propget", "svn:author", "--revprop", "-r", revision]).rstrip()
    368368
    369369    def contents_at_revision(self, path, revision):
    370370        remote_path = "%s/%s" % (self._repository_url(), path)
    371         return run_command(["svn", "cat", "-r", str(revision), remote_path])
     371        return run_command(["svn", "cat", "-r", revision, remote_path])
    372372
    373373    def diff_for_revision(self, revision):
    374374        # FIXME: This should probably use cwd=self.checkout_root
    375         return run_command(['svn', 'diff', '-c', str(revision)])
     375        return run_command(['svn', 'diff', '-c', revision])
    376376
    377377    def _repository_url(self):
     
    406406
    407407    def svn_commit_log(self, svn_revision):
    408         svn_revision = self.strip_r_from_svn_revision(str(svn_revision))
     408        svn_revision = self.strip_r_from_svn_revision(svn_revision)
    409409        return run_command(['svn', 'log', '--non-interactive', '--revision', svn_revision]);
    410410
  • trunk/WebKitTools/Scripts/webkitpy/common/checkout/scm_unittest.py

    r58023 r58036  
    2828# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    2929
     30from __future__ import with_statement
     31
    3032import base64
     33import codecs
    3134import getpass
    3235import os
     
    5760        raise ScriptError('Failed to run "%s"  exit_code: %d  cwd: %s' % (args, exit_code, cwd))
    5861
    59 def write_into_file_at_path(file_path, contents):
    60     file = open(file_path, 'w')
    61     file.write(contents)
    62     file.close()
    63 
    64 def read_from_path(file_path):
    65     file = open(file_path, 'r')
    66     contents = file.read()
    67     file.close()
    68     return contents
     62
     63def write_into_file_at_path(file_path, contents, encoding="utf-8"):
     64    with codecs.open(file_path, "w", encoding) as file:
     65        file.write(contents)
     66
     67
     68def read_from_path(file_path, encoding="utf-8"):
     69    with codecs.open(file_path, "r", encoding) as file:
     70        return file.read()
     71
    6972
    7073# Exists to share svn repository creation code between the git and svn tests
     
    309312"""
    310313        self.checkout.apply_patch(self._create_patch(git_binary_addition))
    311         added = read_from_path('fizzbuzz7.gif')
     314        added = read_from_path('fizzbuzz7.gif', encoding=None)
    312315        self.assertEqual(512, len(added))
    313316        self.assertTrue(added.startswith('GIF89a'))
     
    337340"""
    338341        self.checkout.apply_patch(self._create_patch(git_binary_modification))
    339         modified = read_from_path('fizzbuzz7.gif')
     342        modified = read_from_path('fizzbuzz7.gif', encoding=None)
    340343        self.assertEqual('foobar\n', modified)
    341344        self.assertTrue('fizzbuzz7.gif' in self.scm.changed_files())
     
    519522        patch_file = self._create_patch(patch_contents)
    520523        self.checkout.apply_patch(patch_file)
    521         actual_contents = read_from_path("test_file.swf")
     524        actual_contents = read_from_path("test_file.swf", encoding=None)
    522525        self.assertEqual(actual_contents, expected_contents)
    523526
     
    740743        test_file_path = os.path.join(self.git_checkout_path, test_file_name)
    741744        file_contents = ''.join(map(chr, range(256)))
    742         write_into_file_at_path(test_file_path, file_contents)
     745        write_into_file_at_path(test_file_path, file_contents, encoding=None)
    743746        run_command(['git', 'add', test_file_name])
    744747        patch = scm.create_patch()
     
    750753        self._setup_webkittools_scripts_symlink(scm)
    751754        self.checkout.apply_patch(self._create_patch(patch))
    752         self.assertEqual(file_contents, read_from_path(test_file_path))
     755        self.assertEqual(file_contents, read_from_path(test_file_path, encoding=None))
    753756
    754757        # Check if we can create a patch from a local commit.
    755         write_into_file_at_path(test_file_path, file_contents)
     758        write_into_file_at_path(test_file_path, file_contents, encoding=None)
    756759        run_command(['git', 'add', test_file_name])
    757760        run_command(['git', 'commit', '-m', 'binary diff'])
  • trunk/WebKitTools/Scripts/webkitpy/common/config/committers.py

    r58023 r58036  
    241241    Reviewer("Tim Omernick", "timo@apple.com"),
    242242    Reviewer("Timothy Hatcher", ["timothy@hatcher.name", "timothy@apple.com"], "xenon"),
    243     Reviewer(u'Tor Arne Vestb\xf8', "vestbo@webkit.org", "torarne"),
     243    Reviewer(u"Tor Arne Vestb\u00f8", "vestbo@webkit.org", "torarne"),
    244244    Reviewer("Vicki Murley", "vicki@apple.com"),
    245245    Reviewer("Xan Lopez", ["xan.lopez@gmail.com", "xan@gnome.org", "xan@webkit.org"], "xan"),
  • trunk/WebKitTools/Scripts/webkitpy/common/net/bugzilla.py

    r58023 r58036  
    3333import os.path
    3434import re
     35import StringIO
    3536import subprocess
    3637
     
    428429                attachment[result_key] = flag['setter']
    429430
     431    def _string_contents(self, soup):
     432        # WebKit's bugzilla instance uses UTF-8.
     433        # BeautifulSoup always returns Unicode strings, however
     434        # the .string method returns a (unicode) NavigableString.
     435        # NavigableString can confuse other parts of the code, so we
     436        # convert from NavigableString to a real unicode() object using unicode().
     437        return unicode(soup.string)
     438
    430439    def _parse_attachment_element(self, element, bug_id):
     440
    431441        attachment = {}
    432442        attachment['bug_id'] = bug_id
     
    436446        # FIXME: No need to parse out the url here.
    437447        attachment['url'] = self.attachment_url_for_id(attachment['id'])
    438         attachment['name'] = unicode(element.find('desc').string)
    439         attachment['attacher_email'] = str(element.find('attacher').string)
    440         attachment['type'] = str(element.find('type').string)
     448        attachment['name'] = self._string_contents(element.find('desc'))
     449        attachment['attacher_email'] = self._string_contents(element.find('attacher'))
     450        attachment['type'] = self._string_contents(element.find('type'))
    441451        self._parse_attachment_flag(
    442452                element, 'review', attachment, 'reviewer_email')
     
    449459        bug = {}
    450460        bug["id"] = int(soup.find("bug_id").string)
    451         bug["title"] = unicode(soup.find("short_desc").string)
    452         bug["reporter_email"] = str(soup.find("reporter").string)
    453         bug["assigned_to_email"] = str(soup.find("assigned_to").string)
    454         bug["cc_emails"] = [str(element.string)
     461        bug["title"] = self._string_contents(soup.find("short_desc"))
     462        bug["reporter_email"] = self._string_contents(soup.find("reporter"))
     463        bug["assigned_to_email"] = self._string_contents(soup.find("assigned_to"))
     464        bug["cc_emails"] = [self._string_contents(element)
    455465                            for element in soup.findAll('cc')]
    456466        bug["attachments"] = [self._parse_attachment_element(element, bug["id"]) for element in soup.findAll('attachment')]
     
    549559    def _fill_attachment_form(self,
    550560                              description,
    551                               patch_file_object,
     561                              diff,
    552562                              comment_text=None,
    553563                              mark_for_review=False,
     
    569579        else:
    570580            patch_name ="%s.patch" % timestamp()
     581
     582        # ClientForm expects a file-like object
     583        patch_file_object = StringIO.StringIO(diff.encode("utf-8"))
    571584        self.browser.add_file(patch_file_object,
    572585                              "text/plain",
     
    576589    def add_patch_to_bug(self,
    577590                         bug_id,
    578                          patch_file_object,
     591                         diff,
    579592                         description,
    580593                         comment_text=None,
     
    595608                          self.bug_server_url, bug_id))
    596609        self.browser.select_form(name="entryform")
     610
    597611        self._fill_attachment_form(description,
    598                                    patch_file_object,
     612                                   diff,
    599613                                   mark_for_review=mark_for_review,
    600614                                   mark_for_commit_queue=mark_for_commit_queue,
     
    629643                   bug_description,
    630644                   component=None,
    631                    patch_file_object=None,
     645                   diff=None,
    632646                   patch_description=None,
    633647                   cc=None,
     
    654668            self.browser["cc"] = cc
    655669        if blocked:
    656             self.browser["blocked"] = str(blocked)
     670            self.browser["blocked"] = unicode(blocked)
    657671        self.browser["short_desc"] = bug_title
    658672        self.browser["comment"] = bug_description
    659673
    660         if patch_file_object:
     674        if diff:
    661675            self._fill_attachment_form(
    662676                    patch_description,
    663                     patch_file_object,
     677                    diff,
    664678                    mark_for_review=mark_for_review,
    665679                    mark_for_commit_queue=mark_for_commit_queue)
  • trunk/WebKitTools/Scripts/webkitpy/common/net/buildbot.py

    r58023 r58036  
    4545class Builder(object):
    4646    def __init__(self, name, buildbot):
    47         self._name = unicode(name)
     47        self._name = name
    4848        self._buildbot = buildbot
    4949        self._builds_cache = {}
     
    224224        tables = BeautifulSoup(page).findAll("table")
    225225        for table in tables:
    226             table_title = table.findPreviousSibling("p").string
     226            table_title = unicode(table.findPreviousSibling("p").string)
    227227            if table_title not in cls.expected_keys:
    228228                # This Exception should only ever be hit if run-webkit-tests changes its results.html format.
    229                 raise Exception("Unhandled title: %s" % str(table_title))
     229                raise Exception("Unhandled title: %s" % table_title)
    230230            # We might want to translate table titles into identifiers before storing.
    231             parsed_results[table_title] = [row.find("a").string for row in table.findAll("tr")]
     231            parsed_results[table_title] = [unicode(row.find("a").string) for row in table.findAll("tr")]
    232232
    233233        return parsed_results
     
    362362        # First cell is the name
    363363        name_link = status_cells[0].find('a')
    364         builder["name"] = name_link.string
     364        builder["name"] = unicode(name_link.string)
    365365
    366366        self._parse_last_build_cell(builder, status_cells[1])
     
    411411
    412412    def _parse_twisted_file_row(self, file_row):
    413         string_or_empty = lambda string: str(string) if string else ""
     413        string_or_empty = lambda soup: unicode(soup.string) if soup.string else u""
    414414        file_cells = file_row.findAll('td')
    415415        return {
    416             "filename" : string_or_empty(file_cells[0].find("a").string),
    417             "size" : string_or_empty(file_cells[1].string),
    418             "type" : string_or_empty(file_cells[2].string),
    419             "encoding" : string_or_empty(file_cells[3].string),
     416            "filename": string_or_empty(file_cells[0].find("a")),
     417            "size": string_or_empty(file_cells[1]),
     418            "type": string_or_empty(file_cells[2]),
     419            "encoding": string_or_empty(file_cells[3]),
    420420        }
    421421
  • trunk/WebKitTools/Scripts/webkitpy/common/net/buildbot_unittest.py

    r58023 r58036  
    5252    def setUp(self):
    5353        self.buildbot = BuildBot()
    54         self.builder = Builder("Test Builder", self.buildbot)
     54        self.builder = Builder(u"Test Builder \u2661", self.buildbot)
    5555        self._install_fetch_build(lambda build_number: ["test1", "test2"])
    5656
  • trunk/WebKitTools/Scripts/webkitpy/common/net/statusserver.py

    r58023 r58036  
    5353            return
    5454        if patch.bug_id():
    55             self.browser["bug_id"] = str(patch.bug_id())
     55            self.browser["bug_id"] = unicode(patch.bug_id())
    5656        if patch.id():
    57             self.browser["patch_id"] = str(patch.id())
     57            self.browser["patch_id"] = unicode(patch.id())
    5858
    5959    def _add_results_file(self, results_file):
     
    8080        self.browser.open(update_svn_revision_url)
    8181        self.browser.select_form(name="update_svn_revision")
    82         self.browser["number"] = str(svn_revision_number)
     82        self.browser["number"] = unicode(svn_revision_number)
    8383        self.browser["broken_bot"] = broken_bot
    8484        return self.browser.submit().read()
  • trunk/WebKitTools/Scripts/webkitpy/common/prettypatch.py

    r58023 r58036  
    3939        pretty_diff = self.pretty_diff(diff)
    4040        diff_file = tempfile.NamedTemporaryFile(suffix=".html")
    41         diff_file.write(pretty_diff)
     41        diff_file.write(pretty_diff.encode("utf-8"))
    4242        diff_file.flush()
    4343        return diff_file
  • trunk/WebKitTools/Scripts/webkitpy/common/system/autoinstall.py

    r58023 r58036  
    3131"""Support for automatically downloading Python packages from an URL."""
    3232
     33
     34from __future__ import with_statement
     35
     36import codecs
    3337import logging
    3438import new
     
    115119        os.makedirs(path)
    116120
    117     def _write_file(self, path, text):
     121    def _write_file(self, path, text, encoding):
    118122        """Create a file at the given path with given text.
    119123
     
    123127        _log.debug("Creating file...")
    124128        _log.debug('    "%s"' % path)
    125         file = open(path, "w")
    126         try:
     129        with codecs.open(path, "w", encoding) as file:
    127130            file.write(text)
    128         finally:
    129             file.close()
    130131
    131132    def _set_up_target_dir(self, target_dir, append_to_search_path,
     
    155156                text = ("# This file is required for Python to search this "
    156157                        "directory for modules.\n")
    157                 self._write_file(init_path, text)
     158                self._write_file(init_path, text, "ascii")
    158159
    159160    def _create_scratch_directory_inner(self, prefix):
     
    217218            return False
    218219
    219         file = open(version_path, "r")
    220         try:
     220        with codecs.open(version_path, "r", "utf-8") as file:
    221221            version = file.read()
    222         finally:
    223             file.close()
    224222
    225223        return version.strip() == url.strip()
     
    232230        _log.debug('     To: "%s"' % version_path)
    233231
    234         self._write_file(version_path, url)
     232        self._write_file(version_path, url, "utf-8")
    235233
    236234    def _extract_targz(self, path, scratch_dir):
     
    285283
    286284            try:
     285                # We open this file w/o encoding, as we're reading/writing
     286                # the raw byte-stream from the zip file.
    287287                outfile = open(path, 'wb')
    288288            except IOError, err:
     
    385385        self._log_transfer("Starting download...", url, target_path)
    386386
    387         stream = file(target_path, "wb")
    388         bytes = self._download_to_stream(url, stream)
    389         stream.close()
     387        with open(target_path, "wb") as stream:
     388            bytes = self._download_to_stream(url, stream)
    390389
    391390        _log.debug("Downloaded %s bytes." % bytes)
  • trunk/WebKitTools/Scripts/webkitpy/common/system/deprecated_logging.py

    r58023 r58036  
    3131# This module is now deprecated in favor of python's built-in logging.py.
    3232
     33import codecs
    3334import os
    3435import sys
     36
    3537
    3638def log(string):
    3739    print >> sys.stderr, string
    3840
     41
    3942def error(string):
    4043    log("ERROR: %s" % string)
    4144    exit(1)
     45
    4246
    4347# Simple class to split output between multiple destinations
     
    4650        self.files = files
    4751
    48     def write(self, string):
     52    # Callers should pass an already encoded string for writing.
     53    def write(self, bytes):
    4954        for file in self.files:
    50             file.write(string)
     55            file.write(bytes)
     56
    5157
    5258class OutputTee:
     
    7278        if log_directory and not os.path.exists(log_directory):
    7379            os.makedirs(log_directory)
    74         return open(log_path, 'a+')
     80        return codecs.open(log_path, "a+", "utf-8")
    7581
    7682    def _tee_outputs_to_files(self, files):
  • trunk/WebKitTools/Scripts/webkitpy/common/system/executive.py

    r58023 r58036  
    8989
    9090    def _run_command_with_teed_output(self, args, teed_output):
     91        args = map(unicode, args)  # Popen will throw an exception if args are non-strings (like int())
    9192        child_process = subprocess.Popen(args,
    9293                                         stdout=subprocess.PIPE,
     
    100101            if output_line == "" and child_process.poll() != None:
    101102                return child_process.poll()
     103            # We assume that the child process wrote to us in utf-8,
     104            # so no re-encoding is necessary before writing here.
    102105            teed_output.write(output_line)
    103106
    104     def run_and_throw_if_fail(self, args, quiet=False):
     107    # FIXME: Remove this deprecated method and move callers to run_command.
     108    # FIXME: This method is a hack to allow running command which both
     109    # capture their output and print out to stdin.  Useful for things
     110    # like "build-webkit" where we want to display to the user that we're building
     111    # but still have the output to stuff into a log file.
     112    def run_and_throw_if_fail(self, args, quiet=False, decode_output=True):
    105113        # Cache the child's output locally so it can be used for error reports.
    106114        child_out_file = StringIO.StringIO()
    107115        tee_stdout = sys.stdout
    108116        if quiet:
    109             dev_null = open(os.devnull, "w")
     117            dev_null = open(os.devnull, "w")  # FIXME: Does this need an encoding?
    110118            tee_stdout = dev_null
    111119        child_stdout = tee(child_out_file, tee_stdout)
     
    116124        child_output = child_out_file.getvalue()
    117125        child_out_file.close()
     126
     127        # We assume the child process output utf-8
     128        if decode_output:
     129            child_output = child_output.decode("utf-8")
    118130
    119131        if exit_code:
     
    146158            # using Cygwin, it worked fine.  We should investigate whether
    147159            # we need this platform specific code here.
    148             subprocess.call(('taskkill.exe', '/f', '/pid', str(pid)),
     160            subprocess.call(('taskkill.exe', '/f', '/pid', unicode(pid)),
    149161                            stdin=open(os.devnull, 'r'),
    150162                            stdout=subprocess.PIPE,
     
    164176        pass
    165177
    166     # FIXME: This should be merged with run_and_throw_if_fail
    167 
     178    def _compute_stdin(self, input):
     179        """Returns (stdin, string_to_communicate)"""
     180        if not input:
     181            return (None, None)
     182        if hasattr(input, "read"):  # Check if the input is a file.
     183            return (input, None)  # Assume the file is in the right encoding.
     184
     185        # Popen in Python 2.5 and before does not automatically encode unicode objects.
     186        # http://bugs.python.org/issue5290
     187        # See https://bugs.webkit.org/show_bug.cgi?id=37528
     188        # for an example of a regresion caused by passing a unicode string directly.
     189        # FIXME: We may need to encode differently on different platforms.
     190        if isinstance(input, unicode):
     191            input = input.encode("utf-8")
     192        return (subprocess.PIPE, input)
     193
     194    # FIXME: run_and_throw_if_fail should be merged into this method.
    168195    def run_command(self,
    169196                    args,
     
    172199                    error_handler=None,
    173200                    return_exit_code=False,
    174                     return_stderr=True):
    175         if hasattr(input, 'read'): # Check if the input is a file.
    176             stdin = input
    177             string_to_communicate = None
    178         else:
    179             stdin = None
    180             if input:
    181                 stdin = subprocess.PIPE
    182             # string_to_communicate seems to need to be a str for proper
    183             # communication with shell commands.
    184             # See https://bugs.webkit.org/show_bug.cgi?id=37528
    185             # For an example of a regresion caused by passing a unicode string through.
    186             string_to_communicate = str(input)
    187         if return_stderr:
    188             stderr = subprocess.STDOUT
    189         else:
    190             stderr = None
     201                    return_stderr=True,
     202                    decode_output=True):
     203        args = map(unicode, args)  # Popen will throw an exception if args are non-strings (like int())
     204        stdin, string_to_communicate = self._compute_stdin(input)
     205        stderr = subprocess.STDOUT if return_stderr else None
    191206
    192207        process = subprocess.Popen(args,
     
    196211                                   cwd=cwd)
    197212        output = process.communicate(string_to_communicate)[0]
     213        # run_command automatically decodes to unicode() unless explicitly told not to.
     214        if decode_output:
     215            output = output.decode("utf-8")
    198216        exit_code = process.wait()
    199217
  • trunk/WebKitTools/Scripts/webkitpy/common/system/executive_unittest.py

    r58023 r58036  
    1 # Copyright (C) 2009 Google Inc. All rights reserved.
     1# Copyright (C) 2010 Google Inc. All rights reserved.
    22# Copyright (C) 2009 Daniel Bates (dbates@intudata.com). All rights reserved.
    33#
     
    3232from webkitpy.common.system.executive import Executive, run_command
    3333
     34
    3435class ExecutiveTest(unittest.TestCase):
    3536
     
    3940        self.failUnlessRaises(OSError, run_bad_command)
    4041
    41 if __name__ == '__main__':
    42     unittest.main()
     42    def test_run_command_with_unicode(self):
     43        """Validate that it is safe to pass unicode() objects
     44        to Executive.run* methods, and they will return unicode()
     45        objects by default unless decode_output=False"""
     46        executive = Executive()
     47        unicode_tor = u"WebKit \u2661 Tor Arne Vestb\u00F8!"
     48        utf8_tor = unicode_tor.encode("utf-8")
     49
     50        output = executive.run_command(["cat"], input=unicode_tor)
     51        self.assertEquals(output, unicode_tor)
     52
     53        output = executive.run_command(["echo", "-n", unicode_tor])
     54        self.assertEquals(output, unicode_tor)
     55
     56        output = executive.run_command(["echo", "-n", unicode_tor], decode_output=False)
     57        self.assertEquals(output, utf8_tor)
     58
     59        # FIXME: We should only have one run* method to test
     60        output = executive.run_and_throw_if_fail(["echo", "-n", unicode_tor], quiet=True)
     61        self.assertEquals(output, unicode_tor)
     62
     63        output = executive.run_and_throw_if_fail(["echo", "-n", unicode_tor], quiet=True, decode_output=False)
     64        self.assertEquals(output, utf8_tor)
  • trunk/WebKitTools/Scripts/webkitpy/layout_tests/layout_package/dump_render_tree_thread.py

    r58023 r58036  
    3636"""
    3737
     38from __future__ import with_statement
     39
     40import codecs
    3841import copy
    3942import logging
     
    9093        filename = os.path.splitext(filename)[0] + "-stack.txt"
    9194        port.maybe_make_directory(os.path.split(filename)[0])
    92         open(filename, "wb").write(error)  # FIXME: This leaks a file handle.
     95        with codecs.open(filename, "wb", "utf-8") as file:
     96            file.write(error)
    9397    elif error:
    9498        _log.debug("Previous test output extra lines after dump:\n%s" %
     
    291295        tests_run_filename = os.path.join(self._options.results_directory,
    292296                                          "tests_run.txt")
    293         tests_run_file = open(tests_run_filename, "a")
     297        tests_run_file = codecs.open(tests_run_filename, "a", "utf-8")
    294298
    295299        while True:
  • trunk/WebKitTools/Scripts/webkitpy/layout_tests/layout_package/json_results_generator.py

    r58023 r58036  
    2828# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    2929
     30from __future__ import with_statement
     31
     32import codecs
    3033import logging
    3134import os
     
    119122        json = self._get_json()
    120123        if json:
    121             results_file = open(self._results_file_path, "w")
     124            results_file = codecs.open(self._results_file_path, "w", "utf-8")
    122125            results_file.write(json)
    123126            results_file.close()
     
    152155
    153156        if os.path.exists(self._results_file_path):
    154             old_results_file = open(self._results_file_path, "r")
    155             old_results = old_results_file.read()
     157            with codecs.open(self._results_file_path, "r", "utf-8") as file:
     158                old_results = file.read()
    156159        elif self._builder_base_url:
    157160            # Check if we have the archived JSON file on the buildbot server.
  • trunk/WebKitTools/Scripts/webkitpy/layout_tests/port/apache_http_server.py

    r58023 r58036  
    3030"""A class to start/stop the apache http server used by layout tests."""
    3131
     32
     33from __future__ import with_statement
     34
     35import codecs
    3236import logging
    3337import optparse
     
    152156        httpd_config = self._port_obj._path_to_apache_config_file()
    153157        httpd_config_copy = os.path.join(output_dir, "httpd.conf")
    154         httpd_conf = open(httpd_config).read()
     158        # httpd.conf is always utf-8 according to http://archive.apache.org/gnats/10125
     159        with codecs.open(httpd_config, "r", "utf-8") as httpd_config_file:
     160            httpd_conf = httpd_config_file.read()
    155161        if self._is_cygwin():
    156162            # This is a gross hack, but it lets us use the upstream .conf file
     
    165171                'ServerRoot "%s"' % self._get_cygwin_path(cygusr))
    166172
    167         f = open(httpd_config_copy, 'wb')
    168         f.write(httpd_conf)
    169         f.close()
     173        with codecs.open(httpd_config_copy, "w", "utf-8") as file:
     174            file.write(httpd_conf)
    170175
    171176        if self._is_cygwin():
  • trunk/WebKitTools/Scripts/webkitpy/layout_tests/port/chromium.py

    r58023 r58036  
    3030"""Chromium implementations of the Port interface."""
    3131
     32from __future__ import with_statement
     33
     34import codecs
    3235import logging
    3336import os
     
    141144            offset = abspath.find('third_party')
    142145            if offset == -1:
     146                # FIXME: This seems like the wrong error to throw.
    143147                raise AssertionError('could not find Chromium base dir from ' +
    144148                                     abspath)
     
    205209        Basically this string should contain the equivalent of a
    206210        test_expectations file. See test_expectations.py for more details."""
    207         expectations_file = self.path_to_test_expectations_file()
    208         return file(expectations_file, "r").read()
     211        expectations_path = self.path_to_test_expectations_file()
     212        with codecs.open(expectations_file, "r", "utf-8") as file:
     213            return file.read()
    209214
    210215    def test_expectations_overrides(self):
     
    214219        except AssertionError:
    215220            return None
    216         if os.path.exists(overrides_file):
    217             return file(overrides_file, "r").read()
    218         else:
     221        if not os.path.exists(overrides_file):
    219222            return None
     223        with codecs.open(overrides_file, "r", "utf-8") as file
     224            return file.read()
    220225
    221226    def test_platform_names(self):
     
    266271
    267272class ChromiumDriver(base.Driver):
    268     """Abstract interface for the DumpRenderTree interface."""
     273    """Abstract interface for test_shell."""
    269274
    270275    def __init__(self, port, image_path, options):
     
    390395                    _log.warning('stopping test driver timed out, '
    391396                                 'killing it')
    392                     null = open(os.devnull, "w")
     397                    # FIXME: This should use Executive.
     398                    null = open(os.devnull, "w")  # Does this need an encoding?
    393399                    subprocess.Popen(["kill", "-9",
    394400                                     str(self._proc.pid)], stderr=null)
  • trunk/WebKitTools/Scripts/webkitpy/layout_tests/port/chromium_linux.py

    r58023 r58036  
    127127
    128128    def _kill_all_process(self, process_name):
     129        # FIXME: This should use Executive.
    129130        null = open(os.devnull)
    130131        subprocess.call(['killall', '-TERM', '-u', os.getenv('USER'),
  • trunk/WebKitTools/Scripts/webkitpy/layout_tests/port/chromium_mac.py

    r58023 r58036  
    100100
    101101    def _check_wdiff_install(self):
     102        # FIXME: This should use Executive.
    102103        f = open(os.devnull, 'w')
    103104        rcode = 0
     
    117118    def _kill_all_process(self, process_name):
    118119        """Kill any processes running under this name."""
     120        # FIXME: This should use Executive.
    119121        # On Mac OS X 10.6, killall has a new constraint: -SIGNALNAME or
    120122        # -SIGNALNUMBER must come first.  Example problem:
  • trunk/WebKitTools/Scripts/webkitpy/layout_tests/port/gtk.py

    r58023 r58036  
    6363
    6464    def _kill_all_process(self, process_name):
     65        # FIXME: This should use Executive.
    6566        null = open(os.devnull)
    6667        subprocess.call(['killall', '-TERM', '-u', os.getenv('USER'),
  • trunk/WebKitTools/Scripts/webkitpy/layout_tests/port/http_server.py

    r55603 r58036  
    3030"""A class to help start/stop the lighttpd server used by layout tests."""
    3131
    32 
     32from __future__ import with_statement
     33
     34import codecs
    3335import logging
    3436import optparse
     
    115117
    116118        # Write out the config
    117         f = file(base_conf_file, 'rb')
    118         base_conf = f.read()
    119         f.close()
    120 
    121         f = file(out_conf_file, 'wb')
     119        with codecs.open(base_conf_file, "r", "utf-8") as file:
     120            base_conf = file.read()
     121
     122        # FIXME: This should be re-worked so that this block can
     123        # use with open() instead of a manual file.close() call.
     124        # lighttpd.conf files seem to be UTF-8 without BOM:
     125        # http://redmine.lighttpd.net/issues/992
     126        f = codecs.open(out_conf_file, "w", "utf-8")
    122127        f.write(base_conf)
    123128
  • trunk/WebKitTools/Scripts/webkitpy/layout_tests/port/mac.py

    r58023 r58036  
    134134    # FIXME: This doesn't have anything to do with WebKit.
    135135    def _kill_all_process(self, process_name):
     136        # FIXME: This should use Executive.
    136137        # On Mac OS X 10.6, killall has a new constraint: -SIGNALNAME or
    137138        # -SIGNALNUMBER must come first.  Example problem:
  • trunk/WebKitTools/Scripts/webkitpy/layout_tests/port/mac_unittest.py

    r58023 r58036  
    4141        self.assertEqual(relative_paths, ['LayoutTests/platform/mac-leopard/Skipped', 'LayoutTests/platform/mac/Skipped'])
    4242
    43     example_skipped_file = """
     43    example_skipped_file = u"""
    4444# <rdar://problem/5647952> fast/events/mouseout-on-window.html needs mac DRT to issue mouse out events
    4545fast/events/mouseout-on-window.html
  • trunk/WebKitTools/Scripts/webkitpy/layout_tests/port/qt.py

    r58023 r58036  
    6464
    6565    def _kill_all_process(self, process_name):
     66        # FIXME: This should use Executive.
    6667        null = open(os.devnull)
    6768        subprocess.call(['killall', '-TERM', '-u', os.getenv('USER'),
  • trunk/WebKitTools/Scripts/webkitpy/layout_tests/port/server_process.py

    r58023 r58036  
    216216                _log.warning('stopping %s timed out, killing it' %
    217217                             self._name)
     218                # FIXME: This should use Executive.
    218219                null = open(os.devnull, "w")
    219220                subprocess.Popen(["kill", "-9",
  • trunk/WebKitTools/Scripts/webkitpy/layout_tests/port/webkit.py

    r58023 r58036  
    3030"""WebKit implementations of the Port interface."""
    3131
     32
     33from __future__ import with_statement
     34
     35import codecs
    3236import logging
    3337import os
     
    135139
    136140        actual_length = os.stat(actual_filename).st_size
    137         actual_file = open(actual_filename).read()
     141        with open(actual_filename) as file:
     142            actual_file = file.read()
    138143        expected_length = os.stat(expected_filename).st_size
    139         expected_file = open(expected_filename).read()
     144        with open(expected_filename) as file:
     145            expected_file = file.read()
    140146        sp.write('Content-Length: %d\n%sContent-Length: %d\n%s' %
    141147                 (actual_length, actual_file, expected_length, expected_file))
     
    166172                result = False
    167173        elif output and diff_filename:
    168             open(diff_filename, 'w').write(output)  # FIXME: This leaks a file handle.
     174            with open(diff_filename, 'w') as file:
     175                file.write(output)
    169176        elif sp.timed_out:
    170177            _log.error("ImageDiff timed out on %s" % expected_filename)
     
    253260                _log.warn("Failed to open Skipped file: %s" % filename)
    254261                continue
    255             skipped_file = file(filename)
    256             tests_to_skip.extend(self._tests_from_skipped_file(skipped_file))
    257             skipped_file.close()
     262            with codecs.open(filename, "r", "utf-8") as skipped_file:
     263                tests_to_skip.extend(self._tests_from_skipped_file(skipped_file))
    258264        return tests_to_skip
    259265
     
    261267        # The WebKit mac port uses a combination of a test_expectations file
    262268        # and 'Skipped' files.
    263         expectations_file = self.path_to_test_expectations_file()
    264         expectations = file(expectations_file, "r").read()
    265         return expectations + self._skips()
     269        expectations_path = self.path_to_test_expectations_file()
     270        with codecs.open(expectations_path, "r", "utf-8") as file:
     271            return file.read() + self._skips()
    266272
    267273    def _skips(self):
     
    397403        have_seen_content_type = False
    398404        actual_image_hash = None
    399         output = ''
     405        output = u''
    400406        image = ''
    401407
     
    410416                have_seen_content_type = True
    411417            else:
    412                 output += line
     418                # We expect the text content from DumpRenderTree to be UTF-8
     419                output += line.decode("utf-8")
    413420            line = self._server_process.read_line(timeout)
    414421            timeout = deadline - time.time()
     
    434441
    435442        if self._image_path and len(self._image_path):
    436             image_file = file(self._image_path, "wb")
    437             image_file.write(image)
    438             image_file.close()
     443            with open(self._image_path, "wb") as image_file:
     444                image_file.write(image)
    439445        return (self._server_process.crashed,
    440446                self._server_process.timed_out,
  • trunk/WebKitTools/Scripts/webkitpy/layout_tests/port/websocket_server.py

    r58023 r58036  
    3131
    3232
     33from __future__ import with_statement
     34
     35import codecs
    3336import logging
    3437import optparse
     
    152155
    153156        output_log = os.path.join(self._output_dir, log_file_name + "-out.txt")
    154         self._wsout = open(output_log, "w")
     157        self._wsout = codecs.open(output_log, "w", "utf-8")
    155158
    156159        python_interp = sys.executable
     
    217220        url = url + '://127.0.0.1:%d/' % self._port
    218221        if not url_is_alive(url):
    219             fp = open(output_log)
     222            fp = codecs.open(output_log, "utf-8")
    220223            try:
    221224                for line in fp:
     
    232235                'Failed to start %s server.' % self._server_name)
    233236        if self._pidfile:
    234             f = open(self._pidfile, 'w')
    235             f.write("%d" % self._process.pid)
    236             f.close()
     237            with codecs.open(self._pidfile, "w", "ascii") as file:
     238                file.write("%d" % self._process.pid)
    237239
    238240    def stop(self, force=False):
     
    244246            pid = self._process.pid
    245247        elif self._pidfile:
    246             f = open(self._pidfile)
    247             pid = int(f.read().strip())
    248             f.close()
     248            with codecs.open(self._pidfile, "r", "ascii") as file:
     249                pid = int(f.read().strip())
    249250
    250251        if not pid:
  • trunk/WebKitTools/Scripts/webkitpy/layout_tests/rebaseline_chromium_webkit_tests.py

    r58023 r58036  
    4242"""
    4343
     44from __future__ import with_statement
     45
     46import codecs
    4447import copy
    4548import logging
     
    599602                _log.info('Saving original file to "%s"', backup_file)
    600603                os.rename(path, backup_file)
    601             f = open(path, "w")
    602             f.write(new_expectations)
    603             f.close()
     604            # FIXME: What encoding are these files?
     605            # Or is new_expectations always a byte array?
     606            with open(path, "w") as file:
     607                file.write(new_expectations)
    604608        else:
    605609            _log.info('No test was rebaselined so nothing to remove.')
     
    716720                                             baseline_filename, self._platform,
    717721                                             'old')
    718         f = open(base_file, 'wb')
    719         f.write(output)
    720         f.close()
     722        # FIXME: This assumes run_shell returns a byte array.
     723        # We should be using an explicit encoding here.
     724        with open(base_file, "wb") as file:
     725            file.write(output)
    721726        _log.info('  Html: created old baseline file: "%s".',
    722727                  base_file)
     
    749754                    self._options.html_directory, baseline_filename,
    750755                    self._platform, 'diff')
    751                 f = open(diff_file, 'wb')
    752                 f.write(output)
    753                 f.close()
     756                # FIXME: This assumes run_shell returns a byte array, not unicode()
     757                with open(diff_file, 'wb') as file:
     758                    file.write(output)
    754759                _log.info('  Html: created baseline diff file: "%s".',
    755760                          diff_file)
     
    836841        _log.debug(html)
    837842
    838         f = open(self._html_file, 'w')
    839         f.write(html)
    840         f.close()
     843        with codecs.open(self._html_file, "w", "utf-8") as file:
     844            file.write(html)
    841845
    842846        _log.info('Baseline comparison html generated at "%s"',
  • trunk/WebKitTools/Scripts/webkitpy/layout_tests/run_webkit_tests.py

    r58023 r58036  
    368368            tests_run_filename = os.path.join(self._options.results_directory,
    369369                                              "tests_run.txt")
    370             tests_run_file = open(tests_run_filename, "w")
    371             tests_run_file.write(tests_run_msg + "\n")
    372             tests_run_file.close()
     370            with codecs.open(tests_run_filename, "w", "utf-8") as file:
     371                file.write(tests_run_msg + "\n")
    373372
    374373            len_skip_chunk = int(len(files) * len(skipped) /
     
    967966            dashboard).
    968967        """
    969         _log.debug("Writing JSON files in %s." %
    970                    self._options.results_directory)
    971         unexpected_file = open(os.path.join(self._options.results_directory,
    972             "unexpected_results.json"), "w")
    973         unexpected_file.write(simplejson.dumps(unexpected_results,
    974                               sort_keys=True, indent=2))
    975         unexpected_file.close()
     968        results_directory = self._options.results_directory
     969        _log.debug("Writing JSON files in %s." % results_directory)
     970        unexpected_json_path = os.path.join(results_directory, "unexpected_results.json")
     971        with codecs.open(unexpected_json_path, "w", "utf-8") as file:
     972            simplejson.dump(unexpected_results, file, sort_keys=True, indent=2)
    976973
    977974        # Write a json file of the test_expectations.txt file for the layout
    978975        # tests dashboard.
    979         expectations_file = open(os.path.join(self._options.results_directory,
    980             "expectations.json"), "w")
     976        expectations_path = os.path.join(results_directory, "expectations.json")
    981977        expectations_json = \
    982978            self._expectations.get_expectations_json_for_all_platforms()
    983         expectations_file.write("ADD_EXPECTATIONS(" + expectations_json + ");")
    984         expectations_file.close()
     979        with codecs.open(expectations_path, "w", "utf-8") as file:
     980            file.write(u"ADD_EXPECTATIONS(%s);" % expectations_json)
    985981
    986982        json_layout_results_generator.JSONLayoutResultsGenerator(
     
    13931389        out_filename = os.path.join(self._options.results_directory,
    13941390                                    "results.html")
    1395         out_file = open(out_filename, 'w')
     1391        # FIXME: This should be re-written to prepare the string first
     1392        # so that the "open" call can be wrapped in a with statement.
     1393        out_file = codecs.open(out_filename, "w", "utf-8")
    13961394        # header
    13971395        if self._options.full_results_html:
     
    14061404        for test_file in test_files:
    14071405            test_failures = result_summary.failures.get(test_file, [])
    1408             out_file.write("<p><a href='%s'>%s</a><br />\n"
     1406            out_file.write(u"<p><a href='%s'>%s</a><br />\n"
    14091407                           % (self._port.filename_to_uri(test_file),
    14101408                              self._port.relative_test_filename(test_file)))
    14111409            for failure in test_failures:
    1412                 out_file.write("&nbsp;&nbsp;%s<br/>"
     1410                out_file.write(u"&nbsp;&nbsp;%s<br/>"
    14131411                               % failure.result_html_output(
    14141412                                 self._port.relative_test_filename(test_file)))
     
    14171415        # footer
    14181416        out_file.write("</body></html>\n")
     1417        out_file.close()
    14191418        return True
    14201419
     
    14331432    tests = []
    14341433    for file in files:
    1435         for line in open(file):
     1434        # FIXME: This could be cleaner using a list comprehension.
     1435        for line in codecs.open(file, "r", "utf-8"):
    14361436            line = test_expectations.strip_comments(line)
    14371437            if line:
     
    15081508        unexpected_results_filename = os.path.join(
    15091509           options.results_directory, "unexpected_results.json")
    1510         f = file(unexpected_results_filename)
    1511         results = simplejson.load(f)
    1512         f.close()
     1510        with open(unexpected_results_filename, "r", "utf-8") as file:
     1511            results = simplejson.load(file)
    15131512        last_unexpected_results = results['tests'].keys()
    15141513        if options.print_unexpected_results:
  • trunk/WebKitTools/Scripts/webkitpy/layout_tests/test_types/image_diff.py

    r58023 r58036  
    3535"""
    3636
     37from __future__ import with_statement
     38
     39import codecs
    3740import errno
    3841import logging
     
    7982          checksum: value of the actual checksum result
    8083        """
    81         png_file = open(png_path, "rb")
    82         png_data = png_file.read()
    83         png_file.close()
     84        with open(png_path, "rb") as png_file:
     85            png_data = png_file.read()
    8486        self._save_baseline_data(filename, png_data, ".png")
    8587        self._save_baseline_data(filename, checksum, ".checksum")
     
    141143            _log.debug('Using %s' % expected_png_file)
    142144
     145        # FIXME: We repeat this pattern often, we should share code.
    143146        try:
    144             expected_hash = open(expected_hash_file, "r").read()
     147            with codecs.open(expected_hash_file, "r", "ascii") as file:
     148                expected_hash = file.read()
    145149        except IOError, e:
    146150            if errno.ENOENT != e.errno:
  • trunk/WebKitTools/Scripts/webkitpy/layout_tests/test_types/test_type_base.py

    r58023 r58036  
    3333"""
    3434
     35from __future__ import with_statement
     36
     37import codecs
    3538import cgi
    3639import errno
     
    151154        raise NotImplemented
    152155
    153     def _write_into_file_at_path(self, file_path, contents):
    154         file = open(file_path, "wb")
    155         file.write(contents)
    156         file.close()
     156    def _write_into_file_at_path(self, file_path, byte_array):
     157        """This method assumes that byte_array is already encoded
     158        into the right format."""
     159        with open(file_path, "wb") as file:
     160            file.write(byte_array)
    157161
    158162    def write_output_files(self, port, filename, file_type,
     
    189193        diff = port.diff_text(expected, output, expected_filename, actual_filename)
    190194        diff_filename = self.output_filename(filename, self.FILENAME_SUFFIX_DIFF + file_type)
    191         self._write_into_file_at_path(diff_filename, diff)
     195        self._write_into_file_at_path(diff_filename, diff.encode("utf-8"))
    192196
    193197        # Shell out to wdiff to get colored inline diffs.
    194198        wdiff = port.wdiff_text(expected_filename, actual_filename)
    195199        wdiff_filename = self.output_filename(filename, self.FILENAME_SUFFIX_WDIFF)
    196         self._write_into_file_at_path(wdiff_filename, wdiff)
     200        self._write_into_file_at_path(wdiff_filename, wdiff.encode("utf-8"))
    197201
    198202        # Use WebKit's PrettyPatch.rb to get an HTML diff.
    199203        pretty_patch = port.pretty_patch_text(diff_filename)
    200204        pretty_patch_filename = self.output_filename(filename, self.FILENAME_SUFFIX_PRETTY_PATCH)
    201         self._write_into_file_at_path(pretty_patch_filename, pretty_patch)
     205        self._write_into_file_at_path(pretty_patch_filename, pretty_patch.encode("utf-8"))
  • trunk/WebKitTools/Scripts/webkitpy/layout_tests/test_types/text_diff.py

    r58023 r58036  
    3434"""
    3535
     36from __future__ import with_statement
     37
     38import codecs
    3639import errno
    3740import logging
     
    7174
    7275    def get_normalized_text(self, filename):
     76        # FIXME: We repeat this pattern often, we should share code.
    7377        try:
    74             text = open(filename).read()
     78            with codecs.open(filename, "r", "utf-8") as file:
     79                text = file.read()
    7580        except IOError, e:
    7681            if errno.ENOENT != e.errno:
  • trunk/WebKitTools/Scripts/webkitpy/style/filereader_unittest.py

    r58023 r58036  
    2323"""Contains unit tests for filereader.py."""
    2424
     25from __future__ import with_statement
     26
     27import codecs
    2528import os
    2629import shutil
     
    6871        shutil.rmtree(self._temp_dir)
    6972
    70     def _create_file(self, rel_path, text):
     73    def _create_file(self, rel_path, text, encoding="utf-8"):
    7174        """Create a file with given text and return the path to the file."""
     75        # FIXME: There are better/more secure APIs for creatin tmp file paths.
    7276        file_path = os.path.join(self._temp_dir, rel_path)
    73 
    74         file = open(file_path, 'w')
    75         file.write(text)
    76         file.close()
    77 
     77        with codecs.open(file_path, "w", encoding) as file:
     78            file.write(text)
    7879        return file_path
    7980
  • trunk/WebKitTools/Scripts/webkitpy/thirdparty/__init__.py

    r58023 r58036  
    2525"""Autoinstalls third-party code required by WebKit."""
    2626
     27from __future__ import with_statement
     28
     29import codecs
    2730import os
    2831
     
    8992readme_path = os.path.join(autoinstalled_dir, "README")
    9093if not os.path.exists(readme_path):
    91     file = open(readme_path, "w")
    92     try:
     94    with codecs.open(readme_path, "w", "ascii") as file:
    9395        file.write("This directory is auto-generated by WebKit and is "
    9496                   "safe to delete.\nIt contains needed third-party Python "
    9597                   "packages automatically downloaded from the web.")
    96     finally:
    97         file.close()
  • trunk/WebKitTools/Scripts/webkitpy/tool/commands/earlywarningsystem.py

    r58023 r58036  
    2626# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
    2727# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    28 
    29 from StringIO import StringIO
    3028
    3129from webkitpy.tool.commands.queues import AbstractReviewQueue
  • trunk/WebKitTools/Scripts/webkitpy/tool/commands/queues.py

    r58023 r58036  
    7272        webkit_patch_args = [self.tool.path()]
    7373        # FIXME: This is a hack, we should have a more general way to pass global options.
     74        # FIXME: We must always pass global options and their value in one argument
     75        # because our global option code looks for the first argument which does
     76        # not begin with "-" and assumes that is the command name.
    7477        webkit_patch_args += ["--status-host=%s" % self.tool.status_server.host]
    75         webkit_patch_args += map(str, args)
     78        webkit_patch_args.extend(args)
    7679        return self.tool.executive.run_and_throw_if_fail(webkit_patch_args)
    7780
     
    124127            message = "Error: %s" % message
    125128        output = script_error.message_with_output(output_limit=1024*1024) # 1MB
    126         return tool.status_server.update_status(cls.name, message, state["patch"], StringIO(output))
     129        # We pre-encode the string to a byte array before passing it
     130        # to status_server, because ClientForm (part of mechanize)
     131        # wants a file-like object with pre-encoded data.
     132        return tool.status_server.update_status(cls.name, message, state["patch"], StringIO(output.encode("utf-8")))
    127133
    128134
  • trunk/WebKitTools/Scripts/webkitpy/tool/commands/queues_unittest.py

    r58023 r58036  
    7676
    7777        queue.run_webkit_patch(run_args)
    78         expected_run_args = ["echo", "--status-host=example.com"] + map(str, run_args)
     78        expected_run_args = ["echo", "--status-host=example.com"] + run_args
    7979        tool.executive.run_and_throw_if_fail.assert_called_with(expected_run_args)
    8080
     
    1511511 patch in commit-queue [106]
    152152""",
    153             "process_work_item": "MOCK run_and_throw_if_fail: ['echo', '--status-host=example.com', 'land-attachment', '--force-clean', '--build', '--test', '--non-interactive', '--ignore-builders', '--build-style=both', '--quiet', '76543']\n",
     153            "process_work_item": "MOCK run_and_throw_if_fail: ['echo', '--status-host=example.com', 'land-attachment', '--force-clean', '--build', '--test', '--non-interactive', '--ignore-builders', '--build-style=both', '--quiet', 76543]\n",
    154154        }
    155155        self.assert_queue_outputs(CommitQueue(), tool=tool, work_item=rollout_patch, expected_stderr=expected_stderr)
  • trunk/WebKitTools/Scripts/webkitpy/tool/commands/upload.py

    r58023 r58036  
    3131import os
    3232import re
    33 import StringIO
    3433import sys
    3534
     
    261260        return comment_text
    262261
    263     def _diff_file_for_commit(self, tool, commit_id):
    264         diff = tool.scm().create_patch_from_local_commit(commit_id)
    265         return StringIO.StringIO(diff) # add_patch_to_bug expects a file-like object
    266 
    267262    def execute(self, options, args, tool):
    268263        commit_ids = tool.scm().commit_ids_from_commitish_arguments(args)
     
    285280                have_obsoleted_patches.add(bug_id)
    286281
    287             diff_file = self._diff_file_for_commit(tool, commit_id)
     282            diff = tool.scm().create_patch_from_local_commit(commit_id)
    288283            description = options.description or commit_message.description(lstrip=True, strip_url=True)
    289284            comment_text = self._comment_text_for_commit(options, commit_message, tool, commit_id)
    290             tool.bugs.add_patch_to_bug(bug_id, diff_file, description, comment_text, mark_for_review=options.review, mark_for_commit_queue=options.request_commit)
     285            tool.bugs.add_patch_to_bug(bug_id, diff, description, comment_text, mark_for_review=options.review, mark_for_commit_queue=options.request_commit)
    291286
    292287
     
    405400
    406401        diff = tool.scm().create_patch_from_local_commit(commit_id)
    407         diff_file = StringIO.StringIO(diff) # create_bug expects a file-like object
    408         bug_id = tool.bugs.create_bug(bug_title, comment_text, options.component, diff_file, "Patch", cc=options.cc, mark_for_review=options.review, mark_for_commit_queue=options.request_commit)
     402        bug_id = tool.bugs.create_bug(bug_title, comment_text, options.component, diff, "Patch", cc=options.cc, mark_for_review=options.review, mark_for_commit_queue=options.request_commit)
    409403
    410404        if bug_id and len(commit_ids) > 1:
     
    425419
    426420        diff = tool.scm().create_patch()
    427         diff_file = StringIO.StringIO(diff) # create_bug expects a file-like object
    428         bug_id = tool.bugs.create_bug(bug_title, comment_text, options.component, diff_file, "Patch", cc=options.cc, mark_for_review=options.review, mark_for_commit_queue=options.request_commit)
     421        bug_id = tool.bugs.create_bug(bug_title, comment_text, options.component, diff, "Patch", cc=options.cc, mark_for_review=options.review, mark_for_commit_queue=options.request_commit)
    429422
    430423    def prompt_for_bug_title_and_comment(self):
  • trunk/WebKitTools/Scripts/webkitpy/tool/mocktool.py

    r58023 r58036  
    261261                   bug_description,
    262262                   component=None,
    263                    patch_file_object=None,
     263                   diff=None,
    264264                   patch_description=None,
    265265                   cc=None,
     
    303303    def add_patch_to_bug(self,
    304304                         bug_id,
    305                          patch_file_object,
     305                         diff,
    306306                         description,
    307307                         comment_text=None,
  • trunk/WebKitTools/Scripts/webkitpy/tool/steps/abstractstep.py

    r58023 r58036  
    4040        log("Running %s" % script_name)
    4141        # FIXME: This should use self.port()
    42         self._tool.executive.run_and_throw_if_fail(port.script_path(script_name), quiet)
     42        self._tool.executive.run_and_throw_if_fail([port.script_path(script_name)], quiet)
    4343
    4444    # FIXME: The port should live on the tool.
  • trunk/WebKitTools/Scripts/webkitpy/tool/steps/postdiff.py

    r58023 r58036  
    2727# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    2828
    29 import StringIO
    30 
    3129from webkitpy.tool.steps.abstractstep import AbstractStep
    3230from webkitpy.tool.steps.options import Options
     
    4543    def run(self, state):
    4644        diff = self.cached_lookup(state, "diff")
    47         diff_file = StringIO.StringIO(diff) # add_patch_to_bug expects a file-like object
    4845        description = self._options.description or "Patch"
    4946        comment_text = None
     
    5350        if codereview_issue:
    5451            description += "-%s" % state["codereview_issue"]
    55         self._tool.bugs.add_patch_to_bug(state["bug_id"], diff_file, description, comment_text=comment_text, mark_for_review=self._options.review, mark_for_commit_queue=self._options.request_commit)
     52        self._tool.bugs.add_patch_to_bug(state["bug_id"], diff, description, comment_text=comment_text, mark_for_review=self._options.review, mark_for_commit_queue=self._options.request_commit)
    5653        if self._options.open_bug:
    5754            self._tool.user.open_url(self._tool.bugs.bug_url_for_bug_id(state["bug_id"]))
  • trunk/WebKitTools/Scripts/webkitpy/tool/steps/postdiffforcommit.py

    r58023 r58036  
    2727# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    2828
    29 import StringIO
    30 
    3129from webkitpy.tool.steps.abstractstep import AbstractStep
    3230
     
    3634        self._tool.bugs.add_patch_to_bug(
    3735            state["bug_id"],
    38             StringIO.StringIO(self.cached_lookup(state, "diff")),
     36            self.cached_lookup(state, "diff"),
    3937            "Patch for landing",
    4038            mark_for_review=False,
  • trunk/WebKitTools/Scripts/webkitpy/tool/steps/postdiffforrevert.py

    r58023 r58036  
    2727# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    2828
    29 import StringIO
    30 
    3129from webkitpy.common.net.bugzilla import Attachment
    3230from webkitpy.tool.steps.abstractstep import AbstractStep
     
    4543        self._tool.bugs.add_patch_to_bug(
    4644            state["bug_id"],
    47             StringIO.StringIO(self.cached_lookup(state, "diff")),
     45            self.cached_lookup(state, "diff"),
    4846            "%s%s" % (Attachment.rollout_preamble, state["revision"]),
    4947            comment_text=comment_text,
  • trunk/WebKitTools/Scripts/webkitpy/tool/steps/steps_unittest.py

    r58023 r58036  
    4949        options = Mock()
    5050        options.update = True
    51         self._run_step(Update, options)
     51        expected_stderr = "Updating working directory\n"
     52        OutputCapture().assert_outputs(self, self._run_step, [Update, options], expected_stderr=expected_stderr)
    5253
    5354    def test_prompt_for_bug_or_title_step(self):
Note: See TracChangeset for help on using the changeset viewer.