[PATCH] D68829: [LNT] Python 3 support: Parse HTML as text

Thomas Preud'homme via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Oct 10 13:37:04 PDT 2019


thopre created this revision.
thopre added reviewers: cmatthews, hubert.reinterpretcast, kristof.beyls.
thopre added a parent revision: D68803: [LNT] Python 3 support: sort benchmark regressing.

sanity_check_instance() method in the server/db/Migrations.py
manipulates data from a werkzeug.wrappers.Response instance. However,
data is a property which returns binary data on Python 3 but the code
relies on the data being text, such as the call to the index method with
a text argument.

This commit uses the get_data getter of the data property setting its
as_text parameter to True to request data as text instead.


https://reviews.llvm.org/D68829

Files:
  tests/server/db/Migrations.py


Index: tests/server/db/Migrations.py
===================================================================
--- tests/server/db/Migrations.py
+++ tests/server/db/Migrations.py
@@ -28,9 +28,10 @@
 
     # Visit all the test suites.
     test_suite_link_rex = re.compile("""  <a href="(.*)">(.*)</a><br>""")
-    test_suite_list_start = index.data.index("<h3>Test Suites</h3>")
-    test_suite_list_end = index.data.index("</div>", test_suite_list_start)
-    for ln in index.data[test_suite_list_start:test_suite_list_end].split("\n"):
+    data = index.get_data(as_text=True)
+    test_suite_list_start = data.index("<h3>Test Suites</h3>")
+    test_suite_list_end = data.index("</div>", test_suite_list_start)
+    for ln in data[test_suite_list_start:test_suite_list_end].split("\n"):
         # Ignore non-matching lines.
         print(ln, file=sys.stderr)
         m = test_suite_link_rex.match(ln)


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D68829.224461.patch
Type: text/x-patch
Size: 901 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20191010/ef9ad272/attachment-0001.bin>


More information about the llvm-commits mailing list