Skip to content

Commit d695289

Browse files
author
subrata-ms
committed
Fix Windows CI encoding issue - simplify safe_print to use ASCII directly
1 parent ac56363 commit d695289

File tree

1 file changed

+6
-18
lines changed

1 file changed

+6
-18
lines changed

tests/test_002_types.py

Lines changed: 6 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -814,13 +814,9 @@ def test_utf8_2byte_sequence_complete_coverage():
814814
def safe_print(msg):
815815
try:
816816
print(msg)
817-
except UnicodeEncodeError:
817+
except (UnicodeEncodeError, UnicodeDecodeError):
818818
# Fallback for Windows console encoding issues
819-
print(
820-
msg.encode(sys.stdout.encoding or "ascii", errors="backslashreplace").decode(
821-
sys.stdout.encoding or "ascii"
822-
)
823-
)
819+
print(msg.encode("ascii", errors="backslashreplace").decode("ascii"))
824820

825821
safe_print("\n=== Testing 2-byte UTF-8 Sequence Handler (lines 473-488) ===\n")
826822

@@ -962,13 +958,9 @@ def test_utf8_3byte_sequence_complete_coverage():
962958
def safe_print(msg):
963959
try:
964960
print(msg)
965-
except UnicodeEncodeError:
961+
except (UnicodeEncodeError, UnicodeDecodeError):
966962
# Fallback for Windows console encoding issues
967-
print(
968-
msg.encode(sys.stdout.encoding or "ascii", errors="backslashreplace").decode(
969-
sys.stdout.encoding or "ascii"
970-
)
971-
)
963+
print(msg.encode("ascii", errors="backslashreplace").decode("ascii"))
972964

973965
safe_print("\n=== Testing 3-byte UTF-8 Sequence Handler (lines 490-506) ===\n")
974966

@@ -1191,13 +1183,9 @@ def test_utf8_4byte_sequence_complete_coverage():
11911183
def safe_print(msg):
11921184
try:
11931185
print(msg)
1194-
except UnicodeEncodeError:
1186+
except (UnicodeEncodeError, UnicodeDecodeError):
11951187
# Fallback for Windows console encoding issues
1196-
print(
1197-
msg.encode(sys.stdout.encoding or "ascii", errors="backslashreplace").decode(
1198-
sys.stdout.encoding or "ascii"
1199-
)
1200-
)
1188+
print(msg.encode("ascii", errors="backslashreplace").decode("ascii"))
12011189

12021190
safe_print("\n=== Testing 4-byte UTF-8 Sequence Handler (lines 508-530) ===\n")
12031191

0 commit comments

Comments
 (0)