Changeset 254382 in webkit


Ignore:
Timestamp:
Jan 10, 2020 4:48:21 PM (4 years ago)
Author:
Jonathan Bedard
Message:

webkit-patch crashes when creating new bug with Python 3
https://bugs.webkit.org/show_bug.cgi?id=205911

Reviewed by Stephanie Lewis.

  • Scripts/webkitpy/common/net/bugzilla/bugzilla.py:

(BugzillaQueries.is_invalid_bugzilla_email): Decode page before applying regex.
(Bugzilla.authenticate): Decode group before printing.
(Bugzilla._parse_attachment_id_from_add_patch_to_bug_response): Ensure HTML response
Is a string before applying the regex.
(Bugzilla._check_create_bug_response): Ditto.

  • Scripts/webkitpy/common/net/bugzilla/bugzilla_unittest.py: Attachment ID should be a string,

not a byte array.

Location:
trunk/Tools
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Tools/ChangeLog

    r254367 r254382  
     12020-01-10  Jonathan Bedard  <jbedard@apple.com>
     2
     3        webkit-patch crashes when creating new bug with Python 3
     4        https://bugs.webkit.org/show_bug.cgi?id=205911
     5
     6        Reviewed by Stephanie Lewis.
     7
     8        * Scripts/webkitpy/common/net/bugzilla/bugzilla.py:
     9        (BugzillaQueries.is_invalid_bugzilla_email): Decode page before applying regex.
     10        (Bugzilla.authenticate): Decode group before printing.
     11        (Bugzilla._parse_attachment_id_from_add_patch_to_bug_response): Ensure HTML response
     12        Is a string before applying the regex.
     13        (Bugzilla._check_create_bug_response): Ditto.
     14        * Scripts/webkitpy/common/net/bugzilla/bugzilla_unittest.py: Attachment ID should be a string,
     15        not a byte array.
     16
    1172020-01-10  Alex Christensen  <achristensen@webkit.org>
    218
  • trunk/Tools/Scripts/webkitpy/common/net/bugzilla/bugzilla.py

    r253222 r254382  
    4141from datetime import datetime  # used in timestamp()
    4242
    43 from webkitpy.common.unicode_compatibility import BytesIO, StringIO, unicode
     43from webkitpy.common.unicode_compatibility import BytesIO, StringIO, unicode, decode_for
    4444from webkitpy.common.net.bugzilla.attachment import Attachment
    4545from webkitpy.common.net.bugzilla.bug import Bug
     
    299299        review_queue_url = "request.cgi?action=queue&requester=%s&product=&type=review&requestee=&component=&group=requestee" % urllib.quote(search_string)
    300300        results_page = self._load_query(review_queue_url)
    301         return bool(re.search("did not match anything", results_page.read()))
     301        return bool(re.search('did not match anything', decode_for(results_page.read(), str)))
    302302
    303303
     
    590590            # "invalid" assume it's the login failure page.
    591591            if match and re.search(b'Invalid', match.group(1), re.IGNORECASE):
    592                 errorMessage = "Bugzilla login failed: %s" % match.group(1)
     592                errorMessage = "Bugzilla login failed: {}".format(decode_for(match.group(1), str))
    593593                # raise an exception only if this was the last attempt
    594594                if attempts < 5:
     
    666666    @staticmethod
    667667    def _parse_attachment_id_from_add_patch_to_bug_response(response_html):
    668         match = re.search(b'<title>Attachment (?P<attachment_id>\d+) added to Bug \d+</title>', response_html)
     668        response_html = decode_for(response_html, str)
     669        match = re.search('<title>Attachment (?P<attachment_id>\d+) added to Bug \d+</title>', response_html)
    669670        if match:
    670671            return match.group('attachment_id')
     
    709710    # FIXME: There has to be a more concise way to write this method.
    710711    def _check_create_bug_response(self, response_html):
    711         match = re.search("<title>Bug (?P<bug_id>\d+) Submitted[^<]*</title>",
    712                           response_html)
     712        response_html = decode_for(response_html, str)
     713        match = re.search('<title>Bug (?P<bug_id>\d+) Submitted[^<]*</title>', response_html)
    713714        if match:
    714715            return match.group('bug_id')
     
    720721        error_message = "FAIL"
    721722        if match:
    722             text_lines = BeautifulSoup(
    723                     match.group('error_message')).findAll(text=True)
    724             error_message = "\n" + '\n'.join(
    725                     ["  " + line.strip()
    726                      for line in text_lines if line.strip()])
    727         raise Exception("Bug not created: %s" % error_message)
     723            text_lines = BeautifulSoup(match.group('error_message')).findAll(text=True)
     724            error_message = "\n" + '\n'.join(["  " + line.strip() for line in text_lines if line.strip()])
     725        raise Exception("Bug not created: {}".format(error_message))
    728726
    729727    def create_bug(self,
  • trunk/Tools/Scripts/webkitpy/common/net/bugzilla/bugzilla_unittest.py

    r253230 r254382  
    365365
    366366        title_html = b'<title>Attachment 317591 added to Bug 175247</title>'
    367         self.assertEqual(bugzilla._parse_attachment_id_from_add_patch_to_bug_response(title_html), b'317591')
     367        self.assertEqual(bugzilla._parse_attachment_id_from_add_patch_to_bug_response(title_html), '317591')
    368368
    369369        title_html = b'<title>Attachment 317591; malformed</title>'
Note: See TracChangeset for help on using the changeset viewer.