[PATCH] D74498: [clang-tidy] Fix performance-noexcept-move-constructor-fix.cpp on non-English locale

Alexandre Ganea via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Feb 12 11:47:41 PST 2020


aganea created this revision.
aganea added reviewers: rnk, alexfh.
Herald added subscribers: cfe-commits, xazax.hun.
Herald added a project: clang.

When running on Windows under the following locale:

  D:\llvm-project>python
  Python 3.8.0 (tags/v3.8.0:fa919fd, Oct 14 2019, 19:37:50) [MSC v.1916 64 bit (AMD64)] on win32
  Type "help", "copyright", "credits" or "license" for more information.
  >>> import locale
  >>> locale.getlocale()
  ('French_Canada', '1252')
  >>>

Fix the following issue:

  # command stderr:
  Traceback (most recent call last):
    File "D:/llvm-project/clang-tools-extra/test/../test\clang-tidy\check_clang_tidy.py", line 249, in <module>
      main()
    File "D:/llvm-project/clang-tools-extra/test/../test\clang-tidy\check_clang_tidy.py", line 245, in main
      run_test_once(args, extra_args)
    File "D:/llvm-project/clang-tools-extra/test/../test\clang-tidy\check_clang_tidy.py", line 162, in run_test_once
      diff_output.decode() +
  UnicodeDecodeError: 'utf-8' codec can't decode byte 0xe0 in position 2050: invalid continuation byte


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D74498

Files:
  clang-tools-extra/test/clang-tidy/check_clang_tidy.py


Index: clang-tools-extra/test/clang-tidy/check_clang_tidy.py
===================================================================
--- clang-tools-extra/test/clang-tidy/check_clang_tidy.py
+++ clang-tools-extra/test/clang-tidy/check_clang_tidy.py
@@ -31,7 +31,7 @@
 import re
 import subprocess
 import sys
-
+import locale
 
 def write_file(file_name, text):
   with open(file_name, 'w') as f:
@@ -151,6 +151,13 @@
         clang_tidy_output +
         '\n------------------------------------------------------------------')
 
+  try:
+    locale.setlocale('en_US')
+  except:
+    try:
+	  locale.setlocale('en_US.uf8')
+	except:
+
   try:
     diff_output = subprocess.check_output(
         ['diff', '-u', original_file_name, temp_file_name],


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D74498.244236.patch
Type: text/x-patch
Size: 745 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20200212/2571bb45/attachment-0001.bin>


More information about the cfe-commits mailing list