[PATCH] D79183: Fix dynamic import of http.client

Thomas Preud'homme via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Apr 30 10:08:31 PDT 2020


thopre created this revision.
thopre added reviewers: cmatthews, hubert.reinterpretcast, kristof.beyls, PrzemekWirkus.

Contrary to __import__, importlib.import_module returns the specified
package or module while __import__ returns the top-level package or
module and is thus what http would be bound to when importing
http.client. This commit fixes the import of http.client so that the
http module is bound to the http variable. Without this change LNT
crashes when receiving an HTTP response not between 200 and 400 (not
included).


https://reviews.llvm.org/D79183

Files:
  lnt/lnttool/admin.py


Index: lnt/lnttool/admin.py
===================================================================
--- lnt/lnttool/admin.py
+++ lnt/lnttool/admin.py
@@ -13,7 +13,8 @@
     requests = import_module('requests')
     json = import_module('json')
     os = import_module('os')
-    http = import_module('http.client')
+    http = import_module('http')
+    import_module('http.client')
 
 
 def _error(msg):


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D79183.261271.patch
Type: text/x-patch
Size: 401 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200430/4b3d1d31/attachment.bin>


More information about the llvm-commits mailing list