[PATCH] D55203: Python 2/3 compat - http server

Phabricator via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Dec 3 12:29:59 PST 2018


This revision was automatically updated to reflect the committed changes.
Closed by commit rL348184: Portable Python script across Python version (authored by serge_sans_paille, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D55203?vs=176345&id=176452#toc

Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D55203/new/

https://reviews.llvm.org/D55203

Files:
  cfe/trunk/tools/scan-view/share/ScanView.py


Index: cfe/trunk/tools/scan-view/share/ScanView.py
===================================================================
--- cfe/trunk/tools/scan-view/share/ScanView.py
+++ cfe/trunk/tools/scan-view/share/ScanView.py
@@ -1,5 +1,8 @@
-import BaseHTTPServer
-import SimpleHTTPServer
+try:
+    from http.server import HTTPServer, SimpleHTTPRequestHandler
+except ImportError:
+    from BaseHTTPServer import HTTPServer
+    from SimpleHTTPServer import SimpleHTTPRequestHandler
 import os
 import sys
 import urllib, urlparse
@@ -112,9 +115,9 @@
             print >>s,'</pre>'
             self.status = s.getvalue()
 
-class ScanViewServer(BaseHTTPServer.HTTPServer):
+class ScanViewServer(HTTPServer):
     def __init__(self, address, handler, root, reporters, options):
-        BaseHTTPServer.HTTPServer.__init__(self, address, handler)
+        HTTPServer.__init__(self, address, handler)
         self.root = root
         self.reporters = reporters
         self.options = options        
@@ -170,7 +173,7 @@
         if self.options.autoReload:
             import ScanView
             self.RequestHandlerClass = reload(ScanView).ScanViewRequestHandler
-        BaseHTTPServer.HTTPServer.finish_request(self, request, client_address)
+        HTTPServer.finish_request(self, request, client_address)
 
     def handle_error(self, request, client_address):
         # Ignore socket errors
@@ -179,7 +182,7 @@
             if self.options.debug > 1:
                 print >>sys.stderr, "%s: SERVER: ignored socket error." % (sys.argv[0],)
             return
-        BaseHTTPServer.HTTPServer.handle_error(self, request, client_address)
+        HTTPServer.handle_error(self, request, client_address)
 
 # Borrowed from Quixote, with simplifications.
 def parse_query(qs, fields=None):
@@ -200,19 +203,19 @@
             item.append(value)
     return fields
 
-class ScanViewRequestHandler(SimpleHTTPServer.SimpleHTTPRequestHandler):
+class ScanViewRequestHandler(SimpleHTTPRequestHandler):
     server_version = "ScanViewServer/" + __version__
     dynamic_mtime = time.time()
 
     def do_HEAD(self):
         try:
-            SimpleHTTPServer.SimpleHTTPRequestHandler.do_HEAD(self)
+            SimpleHTTPRequestHandler.do_HEAD(self)
         except Exception as e:
             self.handle_exception(e)
             
     def do_GET(self):
         try:
-            SimpleHTTPServer.SimpleHTTPRequestHandler.do_GET(self)
+            SimpleHTTPRequestHandler.do_GET(self)
         except Exception as e:
             self.handle_exception(e)
             


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D55203.176452.patch
Type: text/x-patch
Size: 2570 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20181203/39cb1a68/attachment.bin>


More information about the llvm-commits mailing list