Skip to content

Commit 11c5e7b

Browse files
Fix debug script to avoid console encoding issues
1 parent 0b30502 commit 11c5e7b

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

debug_unicode.py

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,25 @@
55
import sys
66

77
def test_unicode_warning():
8-
"""Test that triggers Unicode in warnings system"""
8+
"""Test that triggers Unicode in warnings system - matches actual test behavior"""
99
unicode_string = "\U00010002abc--abc\u79d8\u5bc6\u4ee3\u7801-\u79d8\u5bc6\u4ee3\u7801"
1010

11+
# Don't print Unicode - just process it like the real test does
1112
print(f"Python version: {sys.version}")
1213
print(f"Platform: {sys.platform}")
13-
print(f"Architecture: {sys.maxsize > 2**32}")
14-
print(f"Unicode string: {repr(unicode_string)}")
14+
print(f"Architecture: {'x64' if sys.maxsize > 2**32 else 'x86'}")
15+
print(f"Unicode string length: {len(unicode_string)}")
1516

16-
# Trigger a warning with Unicode content
17-
warnings.warn(f"Test warning with Unicode: {unicode_string}")
17+
# Process the Unicode data (like the real test does)
18+
result = unicode_string.encode('utf-8')
19+
decoded = result.decode('utf-8')
20+
assert decoded == unicode_string
21+
22+
# Trigger a warning with Unicode content (this is what causes the crash)
23+
warnings.warn(f"Test warning: {unicode_string}")
1824

1925
print("Test completed successfully")
2026

2127
if __name__ == "__main__":
2228
test_unicode_warning()
29+

0 commit comments

Comments
 (0)