Skip to content

Commit dbe60c0

Browse files
committed
fix: resolve Windows Unicode encoding errors in CI workflow verification scripts
**Unicode Encoding Fixes:** - Replace Unicode emojis with ASCII alternatives in CI verification scripts to prevent Windows console encoding errors - Add PYTHONIOENCODING=utf-8 environment variable to all Python steps for proper Unicode handling - Fix UnicodeEncodeError: 'charmap' codec can't encode character '\u2705' on Windows Server **Specific Changes:** 1. Build Python extension verification script: - Replace (U+2705) with [OK] for success messages - Replace (U+274C) with [ERROR] for error messages - Replace (U+26A0) with [WARN] for warning messages 2. Fallback test verification: - Replace with [OK] in success message 3. Environment variable additions: - Add PYTHONIOENCODING=utf-8 to Build Python extension step - Add PYTHONIOENCODING=utf-8 to Run Python tests step - Add PYTHONIOENCODING=utf-8 to Test pure Python fallback step - Add PYTHONIOENCODING=utf-8 to Run integration tests step **Cross-Platform Compatibility:** - ASCII alternatives work on all platforms (Ubuntu, Windows, macOS) - UTF-8 encoding ensures Unicode characters in integration tests display correctly - Maintains clear status reporting while preventing encoding errors - Preserves all verification functionality **Verification:** - Local testing confirms ASCII alternatives work correctly on Windows - UTF-8 encoding allows integration test script to run without Unicode errors - All verification scripts maintain same functionality with improved compatibility **Root Cause:** Windows console uses cp1252 encoding by default, which cannot display Unicode emoji characters ( U+2705, U+274C, U+26A0) used in verification scripts. **Solution:** Dual approach - ASCII alternatives for inline scripts + UTF-8 encoding environment variable for external scripts that use Unicode characters.
1 parent 8a7e862 commit dbe60c0

File tree

1 file changed

+14
-6
lines changed

1 file changed

+14
-6
lines changed

.github/workflows/ci.yml

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,8 @@ jobs:
171171
172172
- name: Build Python extension
173173
shell: bash
174+
env:
175+
PYTHONIOENCODING: utf-8
174176
run: |
175177
source venv/bin/activate || source venv/Scripts/activate
176178
echo "Building Rust extension with maturin..."
@@ -180,29 +182,33 @@ jobs:
180182
python -c "
181183
try:
182184
import demopy
183-
print(' Successfully imported demopy')
185+
print('[OK] Successfully imported demopy')
184186
print(f'Version: {demopy.__version__}')
185187
hello_result = demopy.hello()
186188
print(f'Hello: {hello_result}')
187189
if 'Rust edition' in hello_result:
188-
print(' Using Rust extension')
190+
print('[OK] Using Rust extension')
189191
elif 'Python fallback' in hello_result:
190-
print(' Using Python fallback')
192+
print('[OK] Using Python fallback')
191193
else:
192-
print(f'⚠️ Unknown implementation: {hello_result}')
194+
print(f'[WARN] Unknown implementation: {hello_result}')
193195
except Exception as e:
194-
print(f' Import failed: {e}')
196+
print(f'[ERROR] Import failed: {e}')
195197
raise
196198
"
197199
198200
- name: Run Python tests
199201
shell: bash
202+
env:
203+
PYTHONIOENCODING: utf-8
200204
run: |
201205
source venv/bin/activate || source venv/Scripts/activate
202206
pytest tests/ -v
203207
204208
- name: Test pure Python fallback
205209
shell: bash
210+
env:
211+
PYTHONIOENCODING: utf-8
206212
run: |
207213
source venv/bin/activate || source venv/Scripts/activate
208214
# Test that fallback works when Rust extension is not available
@@ -227,11 +233,13 @@ jobs:
227233
assert demopy.sum_list([1, 2, 3]) == 6
228234
assert demopy.reverse_string('hello') == 'olleh'
229235
assert demopy.power(2, 3) == 8
230-
print(' Pure Python fallback test passed!')
236+
print('[OK] Pure Python fallback test passed!')
231237
"
232238
233239
- name: Run integration tests
234240
shell: bash
241+
env:
242+
PYTHONIOENCODING: utf-8
235243
run: |
236244
source venv/bin/activate || source venv/Scripts/activate
237245
python scripts/test_integration.py

0 commit comments

Comments
 (0)