Title: [254382] trunk/Tools
Revision
254382
Author
[email protected]
Date
2020-01-10 16:48:21 -0800 (Fri, 10 Jan 2020)

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

Modified Paths

Diff

Modified: trunk/Tools/ChangeLog (254381 => 254382)


--- trunk/Tools/ChangeLog	2020-01-11 00:45:19 UTC (rev 254381)
+++ trunk/Tools/ChangeLog	2020-01-11 00:48:21 UTC (rev 254382)
@@ -1,3 +1,19 @@
+2020-01-10  Jonathan Bedard  <[email protected]>
+
+        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.
+
 2020-01-10  Alex Christensen  <[email protected]>
 
         Fix test assertions after r254345

Modified: trunk/Tools/Scripts/webkitpy/common/net/bugzilla/bugzilla.py (254381 => 254382)


--- trunk/Tools/Scripts/webkitpy/common/net/bugzilla/bugzilla.py	2020-01-11 00:45:19 UTC (rev 254381)
+++ trunk/Tools/Scripts/webkitpy/common/net/bugzilla/bugzilla.py	2020-01-11 00:48:21 UTC (rev 254382)
@@ -40,7 +40,7 @@
 
 from datetime import datetime  # used in timestamp()
 
-from webkitpy.common.unicode_compatibility import BytesIO, StringIO, unicode
+from webkitpy.common.unicode_compatibility import BytesIO, StringIO, unicode, decode_for
 from webkitpy.common.net.bugzilla.attachment import Attachment
 from webkitpy.common.net.bugzilla.bug import Bug
 
@@ -298,7 +298,7 @@
     def is_invalid_bugzilla_email(self, search_string):
         review_queue_url = "request.cgi?action="" % urllib.quote(search_string)
         results_page = self._load_query(review_queue_url)
-        return bool(re.search("did not match anything", results_page.read()))
+        return bool(re.search('did not match anything', decode_for(results_page.read(), str)))
 
 
 class CommitQueueFlag(object):
@@ -589,7 +589,7 @@
             # If the resulting page has a title, and it contains the word
             # "invalid" assume it's the login failure page.
             if match and re.search(b'Invalid', match.group(1), re.IGNORECASE):
-                errorMessage = "Bugzilla login failed: %s" % match.group(1)
+                errorMessage = "Bugzilla login failed: {}".format(decode_for(match.group(1), str))
                 # raise an exception only if this was the last attempt
                 if attempts < 5:
                     _log.error(errorMessage)
@@ -665,7 +665,8 @@
 
     @staticmethod
     def _parse_attachment_id_from_add_patch_to_bug_response(response_html):
-        match = re.search(b'<title>Attachment (?P<attachment_id>\d+) added to Bug \d+</title>', response_html)
+        response_html = decode_for(response_html, str)
+        match = re.search('<title>Attachment (?P<attachment_id>\d+) added to Bug \d+</title>', response_html)
         if match:
             return match.group('attachment_id')
         _log.warning('Unable to parse attachment id')
@@ -708,8 +709,8 @@
 
     # FIXME: There has to be a more concise way to write this method.
     def _check_create_bug_response(self, response_html):
-        match = re.search("<title>Bug (?P<bug_id>\d+) Submitted[^<]*</title>",
-                          response_html)
+        response_html = decode_for(response_html, str)
+        match = re.search('<title>Bug (?P<bug_id>\d+) Submitted[^<]*</title>', response_html)
         if match:
             return match.group('bug_id')
 
@@ -719,12 +720,9 @@
             re.DOTALL)
         error_message = "FAIL"
         if match:
-            text_lines = BeautifulSoup(
-                    match.group('error_message')).findAll(text=True)
-            error_message = "\n" + '\n'.join(
-                    ["  " + line.strip()
-                     for line in text_lines if line.strip()])
-        raise Exception("Bug not created: %s" % error_message)
+            text_lines = BeautifulSoup(match.group('error_message')).findAll(text=True)
+            error_message = "\n" + '\n'.join(["  " + line.strip() for line in text_lines if line.strip()])
+        raise Exception("Bug not created: {}".format(error_message))
 
     def create_bug(self,
                    bug_title,

Modified: trunk/Tools/Scripts/webkitpy/common/net/bugzilla/bugzilla_unittest.py (254381 => 254382)


--- trunk/Tools/Scripts/webkitpy/common/net/bugzilla/bugzilla_unittest.py	2020-01-11 00:45:19 UTC (rev 254381)
+++ trunk/Tools/Scripts/webkitpy/common/net/bugzilla/bugzilla_unittest.py	2020-01-11 00:48:21 UTC (rev 254382)
@@ -364,7 +364,7 @@
         bugzilla = Bugzilla()
 
         title_html = b'<title>Attachment 317591 added to Bug 175247</title>'
-        self.assertEqual(bugzilla._parse_attachment_id_from_add_patch_to_bug_response(title_html), b'317591')
+        self.assertEqual(bugzilla._parse_attachment_id_from_add_patch_to_bug_response(title_html), '317591')
 
         title_html = b'<title>Attachment 317591; malformed</title>'
         self.assertEqual(bugzilla._parse_attachment_id_from_add_patch_to_bug_response(title_html), None)
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to