r349449 - Portable Python script across Python version

Serge Guelton via cfe-commits cfe-commits at lists.llvm.org
Tue Dec 18 00:25:25 PST 2018


Author: serge_sans_paille
Date: Tue Dec 18 00:25:25 2018
New Revision: 349449

URL: http://llvm.org/viewvc/llvm-project?rev=349449&view=rev
Log:
Portable Python script across Python version

ConfigParser module has been renamed as configparser in Python3

Differential Revision: https://reviews.llvm.org/D55200

Modified:
    cfe/trunk/tools/scan-view/share/ScanView.py
    cfe/trunk/utils/check_cfc/check_cfc.py

Modified: cfe/trunk/tools/scan-view/share/ScanView.py
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/scan-view/share/ScanView.py?rev=349449&r1=349448&r2=349449&view=diff
==============================================================================
--- cfe/trunk/tools/scan-view/share/ScanView.py (original)
+++ cfe/trunk/tools/scan-view/share/ScanView.py Tue Dec 18 00:25:25 2018
@@ -16,7 +16,10 @@ import socket
 import itertools
 
 import Reporter
-import ConfigParser
+try:
+    import configparser
+except ImportError:
+    import ConfigParser as configparser
 
 ###
 # Various patterns matched or replaced by server.
@@ -126,7 +129,7 @@ class ScanViewServer(HTTPServer):
         self.load_config()
 
     def load_config(self):
-        self.config = ConfigParser.RawConfigParser()
+        self.config = configparser.RawConfigParser()
 
         # Add defaults
         self.config.add_section('ScanView')

Modified: cfe/trunk/utils/check_cfc/check_cfc.py
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/utils/check_cfc/check_cfc.py?rev=349449&r1=349448&r2=349449&view=diff
==============================================================================
--- cfe/trunk/utils/check_cfc/check_cfc.py (original)
+++ cfe/trunk/utils/check_cfc/check_cfc.py Tue Dec 18 00:25:25 2018
@@ -56,7 +56,10 @@ import shutil
 import subprocess
 import sys
 import tempfile
-import ConfigParser
+try:
+    import configparser
+except ImportError:
+    import ConfigParser as configparser
 import io
 
 import obj_diff
@@ -318,7 +321,7 @@ if __name__ == '__main__':
     for c in checks:
         default_config += "{} = false\n".format(c)
 
-    config = ConfigParser.RawConfigParser()
+    config = configparser.RawConfigParser()
     config.readfp(io.BytesIO(default_config))
     scriptdir = get_main_dir()
     config_path = os.path.join(scriptdir, 'check_cfc.cfg')




More information about the cfe-commits mailing list