[clang] 79f8c20 - update string comparison in clang-format.py

via cfe-commits cfe-commits at lists.llvm.org
Fri Dec 6 09:37:17 PST 2019


Author: mydeveloperday
Date: 2019-12-06T17:36:56Z
New Revision: 79f8c20e2cb634c1b8e42f01b42fc5ab2a512d60

URL: https://github.com/llvm/llvm-project/commit/79f8c20e2cb634c1b8e42f01b42fc5ab2a512d60
DIFF: https://github.com/llvm/llvm-project/commit/79f8c20e2cb634c1b8e42f01b42fc5ab2a512d60.diff

LOG: update string comparison in clang-format.py

Summary: Python 3.8 introduces a SyntaxWarning about string comparisons with 'is'. This commit updates the string comparison in clang-format.py that is done with 'is not' to '!='. This should not break compatibility with older python versions (tested 3.4.9, 2.7.17, 2.7.5, 3.8.0).

Reviewers: MyDeveloperDay, klimek, llvm-commits, cfe-commits

Reviewed By: MyDeveloperDay, klimek

Patch By: pseyfert

Tags: #clang-format, #clang

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

Added: 
    

Modified: 
    clang/tools/clang-format/clang-format.py

Removed: 
    


################################################################################
diff  --git a/clang/tools/clang-format/clang-format.py b/clang/tools/clang-format/clang-format.py
index 596270cb55d3..1a615b170722 100644
--- a/clang/tools/clang-format/clang-format.py
+++ b/clang/tools/clang-format/clang-format.py
@@ -136,7 +136,7 @@ def main():
     lines = lines[1:-1]
     sequence = 
diff lib.SequenceMatcher(None, buf, lines)
     for op in reversed(sequence.get_opcodes()):
-      if op[0] is not 'equal':
+      if op[0] != 'equal':
         vim.current.buffer[op[1]:op[2]] = lines[op[3]:op[4]]
     if output.get('IncompleteFormat'):
       print('clang-format: incomplete (syntax errors)')


        


More information about the cfe-commits mailing list