File: 0004-chore-Drop-use-of-codecs.open.patch

package info (click to toggle)
cpplint 2.0.2-3
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 3,656 kB
  • sloc: cpp: 13,681; python: 10,095; ansic: 854; sh: 30; makefile: 18
file content (48 lines) | stat: -rw-r--r-- 2,106 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
From: Steve Kowalik <steven@wedontsleep.org>
Date: Fri, 31 Oct 2025 12:50:26 +1100
Subject: chore: Drop use of codecs.open()

codecs.open() has been deprecated as of Python 3.14, and plain open()
supports all use-cases we have, switch to using it.

[pre-commit.ci] auto fixes from pre-commit.com hooks: for more information, see https://pre-commit.ci

Drop mode argument to open(): ruff complains about open(mode="r")
---
 cpplint.py | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)

diff --git a/cpplint.py b/cpplint.py
index 7abd2ba..30a6869 100755
--- a/cpplint.py
+++ b/cpplint.py
@@ -7448,7 +7448,7 @@ def ProcessConfigOverrides(filename):
             continue
 
         try:
-            with codecs.open(cfg_file, "r", "utf8", "replace") as file_handle:
+            with open(cfg_file, encoding="utf8", errors="replace") as file_handle:
                 for line in file_handle:
                     line, _, _ = line.partition("#")  # Remove comments.
                     if not line.strip():
@@ -7541,16 +7541,15 @@ def ProcessFile(filename, vlevel, extra_check_functions=None):
     crlf_lines = []
     try:
         # Support the UNIX convention of using "-" for stdin.  Note that
-        # we are not opening the file with universal newline support
-        # (which codecs doesn't support anyway), so the resulting lines do
-        # contain trailing '\r' characters if we are reading a file that
-        # has CRLF endings.
+        # we are not opening the file with universal newline support,
+        # so the resulting lines do # contain trailing '\r' characters
+        # if we are reading a file that # has CRLF endings.
         # If after the split a trailing '\r' is present, it is removed
         # below.
         if filename == "-":
             lines = sys.stdin.read().split("\n")
         else:
-            with codecs.open(filename, "r", "utf8", "replace") as target_file:
+            with open(filename, encoding="utf8", errors="replace") as target_file:
                 lines = target_file.read().split("\n")
 
         # Remove trailing '\r'.