Skip to content

Commit 8a0b97b

Browse files
fanquakevijaydasmp
authored andcommitted
Merge bitcoin#28035: test: Ignore UTF-8 errors in assert_debug_log
fa3d729 lint: Ignore check_fileopens failure on **kwargs (MarcoFalke) fa6bb85 test: Ignore UTF-8 errors in assert_debug_log (MarcoFalke) fa63326 test: Fix debug_log_size helper (MarcoFalke) Pull request description: Fix two bugs, see commit messages. ACKs for top commit: theStack: utACK fa3d729 Tree-SHA512: 4a29bdf954bf62bb7676c2a41b03ad017bc86d535b2bd912c96bd41d1621beb06d840b53c211480ad51974e8b293bbae620060d2528d269159f32c0b44e47712
1 parent bd6535f commit 8a0b97b

2 files changed

Lines changed: 6 additions & 6 deletions

File tree

test/functional/test_framework/test_node.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -453,8 +453,8 @@ def chain_path(self) -> Path:
453453
def debug_log_path(self) -> Path:
454454
return self.chain_path / 'debug.log'
455455

456-
def debug_log_bytes(self) -> int:
457-
with open(self.debug_log_path, encoding='utf-8') as dl:
456+
def debug_log_size(self, **kwargs) -> int:
457+
with open(self.debug_log_path, **kwargs) as dl:
458458
dl.seek(0, 2)
459459
return dl.tell()
460460

@@ -466,13 +466,13 @@ def assert_debug_log(self, expected_msgs, unexpected_msgs=None, timeout=2):
466466
assert_equal(type(unexpected_msgs), list)
467467

468468
time_end = time.time() + timeout * self.timeout_factor
469-
prev_size = self.debug_log_bytes()
469+
prev_size = self.debug_log_size(encoding="utf-8") # Must use same encoding that is used to read() below
470470

471471
yield
472472

473473
while True:
474474
found = True
475-
with open(self.debug_log_path, encoding='utf-8') as dl:
475+
with open(self.debug_log_path, encoding="utf-8", errors="replace") as dl:
476476
dl.seek(prev_size)
477477
log = dl.read()
478478
print_log = " - " + "\n - ".join(log.splitlines())
@@ -497,7 +497,7 @@ def wait_for_debug_log(self, expected_msgs, timeout=60):
497497
the number of log lines we encountered when matching
498498
"""
499499
time_end = time.time() + timeout * self.timeout_factor
500-
prev_size = self.debug_log_bytes()
500+
prev_size = self.debug_log_size(mode="rb") # Must use same mode that is used to read() below
501501

502502
yield
503503

test/lint/lint-python-utf8-encoding.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ def check_fileopens():
2929
if e.returncode > 1:
3030
raise e
3131

32-
filtered_fileopens = [fileopen for fileopen in fileopens if not re.search(r"encoding=.(ascii|utf8|utf-8).|open\([^,]*, ['\"][^'\"]*b[^'\"]*['\"]", fileopen)]
32+
filtered_fileopens = [fileopen for fileopen in fileopens if not re.search(r"encoding=.(ascii|utf8|utf-8).|open\([^,]*, (\*\*kwargs|['\"][^'\"]*b[^'\"]*['\"])", fileopen)]
3333

3434
return filtered_fileopens
3535

0 commit comments

Comments
 (0)