| 1 |
From: Steve Kowalik <[email protected]> |
| 2 |
Date: Fri, 31 Oct 2025 12:50:26 +1100 |
| 3 |
Subject: chore: Drop use of codecs.open() |
| 4 |
|
| 5 |
codecs.open() has been deprecated as of Python 3.14, and plain open() |
| 6 |
supports all use-cases we have, switch to using it. |
| 7 |
|
| 8 |
[pre-commit.ci] auto fixes from pre-commit.com hooks: for more information, see https://pre-commit.ci |
| 9 |
|
| 10 |
Drop mode argument to open(): ruff complains about open(mode="r") |
| 11 |
--- |
| 12 |
cpplint.py | 11 +++++------ |
| 13 |
1 file changed, 5 insertions(+), 6 deletions(-) |
| 14 |
|
| 15 |
diff --git a/cpplint.py b/cpplint.py |
| 16 |
index 7abd2ba..30a6869 100755 |
| 17 |
--- a/cpplint.py |
| 18 |
+++ b/cpplint.py |
| 19 |
@@ -7448,7 +7448,7 @@ def ProcessConfigOverrides(filename): |
| 20 |
continue |
| 21 |
|
| 22 |
try: |
| 23 |
- with codecs.open(cfg_file, "r", "utf8", "replace") as file_handle: |
| 24 |
+ with open(cfg_file, encoding="utf8", errors="replace") as file_handle: |
| 25 |
for line in file_handle: |
| 26 |
line, _, _ = line.partition("#") # Remove comments. |
| 27 |
if not line.strip(): |
| 28 |
@@ -7541,16 +7541,15 @@ def ProcessFile(filename, vlevel, extra_check_functions=None): |
| 29 |
crlf_lines = [] |
| 30 |
try: |
| 31 |
# Support the UNIX convention of using "-" for stdin. Note that |
| 32 |
- # we are not opening the file with universal newline support |
| 33 |
- # (which codecs doesn't support anyway), so the resulting lines do |
| 34 |
- # contain trailing '\r' characters if we are reading a file that |
| 35 |
- # has CRLF endings. |
| 36 |
+ # we are not opening the file with universal newline support, |
| 37 |
+ # so the resulting lines do # contain trailing '\r' characters |
| 38 |
+ # if we are reading a file that # has CRLF endings. |
| 39 |
# If after the split a trailing '\r' is present, it is removed |
| 40 |
# below. |
| 41 |
if filename == "-": |
| 42 |
lines = sys.stdin.read().split("\n") |
| 43 |
else: |
| 44 |
- with codecs.open(filename, "r", "utf8", "replace") as target_file: |
| 45 |
+ with open(filename, encoding="utf8", errors="replace") as target_file: |
| 46 |
lines = target_file.read().split("\n") |
| 47 |
|
| 48 |
# Remove trailing '\r'. |