]> granicus.if.org Git - clang/commitdiff
Portable Python script across Python version
authorSerge Guelton <sguelton@quarkslab.com>
Tue, 18 Dec 2018 08:22:47 +0000 (08:22 +0000)
committerSerge Guelton <sguelton@quarkslab.com>
Tue, 18 Dec 2018 08:22:47 +0000 (08:22 +0000)
dict no longer have the `has_key` method in Python3. Instead, one can
use the `in` keyword which already works in Python2.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@349447 91177308-0d34-0410-b5e6-96231b3b80d8

docs/tools/dump_format_style.py
tools/scan-view/share/startfile.py

index 2e1e8c12297b294b8339996e06fee06e2e12ed47..f2682edc7773718e0d559c5a2226317a1073a56f 100755 (executable)
@@ -180,9 +180,9 @@ def read_options(header):
                            'std::vector<std::string>',
                            'std::vector<IncludeCategory>',
                            'std::vector<RawStringFormat>']:
-      if enums.has_key(option.type):
+      if option.type in enums:
         option.enum = enums[option.type]
-      elif nested_structs.has_key(option.type):
+      elif option.type in nested_structs:
         option.nested_struct = nested_structs[option.type]
       else:
         raise Exception('Unknown type: %s' % option.type)
index f58dbeeaf81797a016063a1968bacb7d100f7eee..58023d0271a6a1df9e2c90651055c4ad62a0ac8d 100644 (file)
@@ -189,7 +189,7 @@ else:
             return _controllers[controller_name].open
 
         except KeyError:
-            if _controllers.has_key('xdg-open'):
+            if 'xdg-open' in _controllers:
                 return _controllers['xdg-open'].open
             else:
                 return webbrowser.open