[all-commits] [llvm/llvm-project] 307b1f: [clang-tidy] Always open files using UTF-8 encoding

Andy Hippo via All-commits all-commits at lists.llvm.org
Mon Aug 2 02:37:45 PDT 2021


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 307b1fddd4d84b559b154ff7744ae68bf9c6f503
      https://github.com/llvm/llvm-project/commit/307b1fddd4d84b559b154ff7744ae68bf9c6f503
  Author: Andy Yankovsky <weratt at gmail.com>
  Date:   2021-08-02 (Mon, 02 Aug 2021)

  Changed paths:
    M clang-tools-extra/clang-tidy/add_new_check.py
    M clang-tools-extra/clang-tidy/rename_check.py

  Log Message:
  -----------
  [clang-tidy] Always open files using UTF-8 encoding

The encoding used for opening files depends on the OS and might be different
from UTF-8 (e.g. on Windows it can be CP-1252). The documentation files use
UTF-8 and might be incompatible with other encodings. For example, right now
`clang-tools-extra/docs/clang-tidy/checks/abseil-no-internal-dependencies.rst`
has non-ASCII quotes and running `add_new_check.py` fails on Windows, because
it tries to read the file with incompatible encoding.

Use `io.open` for compatibility with both Python 2 and Python 3.

Reviewed By: kbobyrev

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




More information about the All-commits mailing list