Skip to content

Commit 2a45435

Browse files
authored
fix: Windows cross-platform support (#310)
- Add stdout UTF-8 wrapper in config.py and check_prerequisites.py to prevent UnicodeEncodeError on Windows cp1252 terminals - Add .gitattributes to force LF line endings on shell scripts, preventing CRLF breakage in Linux containers - Remove emoji from docker/entrypoint.sh - Update test_pages_render_without_errors routes to match /demo/cineflow/ prefix after recent refactor Closes #309
1 parent 09411e5 commit 2a45435

5 files changed

Lines changed: 16 additions & 2 deletions

File tree

.gitattributes

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Force LF line endings for shell scripts (prevents CRLF breakage in Linux containers)
2+
*.sh text eol=lf
3+
docker/entrypoint.sh text eol=lf

docker/entrypoint.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/bin/sh
22
set -e
33

4-
echo "Running bootstrap (migrations, seeding, definitions)..."
4+
echo "Running bootstrap (migrations, seeding, definitions)..."
55
python scripts/bootstrap.py
66

77
exec "$@"

finbot/config.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,16 @@
33
"""
44

55
import hashlib
6+
import io
67
import os
8+
import sys
79
from typing import Any, Literal
810
from urllib.parse import urlparse
911

12+
# Ensure stdout can handle Unicode on all platforms (Windows cp1252 fix)
13+
if sys.stdout.encoding and sys.stdout.encoding.lower().replace("-", "") != "utf8":
14+
sys.stdout = io.TextIOWrapper(sys.stdout.buffer, encoding="utf-8", errors="replace")
15+
1016
from pydantic import ConfigDict, model_validator
1117
from pydantic_settings import BaseSettings
1218

scripts/check_prerequisites.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,15 @@
1010
python scripts/check_prerequisites.py
1111
"""
1212

13+
import io
1314
import shutil
1415
import subprocess
1516
import sys
1617

18+
# Ensure stdout can handle Unicode on all platforms (Windows cp1252 fix)
19+
if sys.stdout.encoding and sys.stdout.encoding.lower().replace("-", "") != "utf8":
20+
sys.stdout = io.TextIOWrapper(sys.stdout.buffer, encoding="utf-8", errors="replace")
21+
1722

1823
def check_python() -> tuple[bool, str]:
1924
"""Check Python >= 3.13."""

tests/integration/apps/web/test_templates.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ def test_templates_exist(self):
3434

3535
def test_pages_render_without_errors(self, integration_client: TestClient):
3636
"""Test that pages render without template errors."""
37-
pages = ["/", "/about", "/contact"]
37+
pages = ["/demo/cineflow/", "/demo/cineflow/about", "/demo/cineflow/contact"]
3838

3939
for page in pages:
4040
response = integration_client.get(page)

0 commit comments

Comments
 (0)