aports/testing/cpplint/replace-codecs-open.patch
mio f3a16a9262 testing/cpplint: rebuild against python 3.14
Replace usage of deprecated `codecs.open` function to fix deprecation
warnings emitted in tests, leading to test failure.

```
AssertionError: Failed check in /tmp/tmp_kcwi3hr/./samples/chromium-sample comparing to ./samples/chromium-sample/simple.def for command: /builds/alpine/aports/testing/cpplint/src/cpplint-2.0.2/.testenv/bin/python3 /builds/alpine/aports/testing/cpplint/src/cpplint-2.0.2/cpplint.py  --repository /tmp/tmp_kcwi3hr :
--- first
+++ second
@@ -1,3 +1,5 @@
+'/builds/alpine/aports/testing/cpplint/src/cpplint-2.0.2/cpplint.py:7553: DeprecationWarning: codecs.open()is deprecated. Use open() instead.\n'
+'  with codecs.open(filename, "r", "utf8", "replace") as target_file:\n'

[...]

cpplint_clitest.py:167: AssertionError
```

Ref: https://gitlab.alpinelinux.org/alpine/aports/-/issues/18025
2026-04-01 02:16:53 +00:00

22 lines
951 B
Diff

diff -rupN a/cpplint.py b/cpplint.py
--- a/cpplint.py 2025-04-08 01:16:55.000000000 +0000
+++ b/cpplint.py 2026-04-01 01:08:06.670000000 +0000
@@ -7448,7 +7448,7 @@ def ProcessConfigOverrides(filename):
continue
try:
- with codecs.open(cfg_file, "r", "utf8", "replace") as file_handle:
+ with open(cfg_file, "r", encoding="utf-8") as file_handle:
for line in file_handle:
line, _, _ = line.partition("#") # Remove comments.
if not line.strip():
@@ -7550,7 +7550,7 @@ def ProcessFile(filename, vlevel, extra_
if filename == "-":
lines = sys.stdin.read().split("\n")
else:
- with codecs.open(filename, "r", "utf8", "replace") as target_file:
+ with open(filename, "r", encoding="utf-8") as target_file:
lines = target_file.read().split("\n")
# Remove trailing '\r'.