Skip to content

Fix Python 3.9/3.10 compatibility and a Windows-only test failure#9

Open
kenstephoang wants to merge 2 commits into
ksimback:mainfrom
kenstephoang:fix/py39-utc-compat-and-windows-test
Open

Fix Python 3.9/3.10 compatibility and a Windows-only test failure#9
kenstephoang wants to merge 2 commits into
ksimback:mainfrom
kenstephoang:fix/py39-utc-compat-and-windows-test

Conversation

@kenstephoang

Copy link
Copy Markdown

What

Two small, independent fixes found while running the skill and its test suite on Windows with Python 3.9–3.10.

1. datetime.UTC breaks the declared Python floor (>=3.9)

datetime.UTC was only added in Python 3.11, but pyproject.toml declares requires-python = ">=3.9". On 3.9/3.10, datetime.now(datetime.UTC) raises AttributeError, so both compile and the generated run-loop.py crash on a supported interpreter.

Fixed by using datetime.timezone.utc (available since 3.2):

  • scripts/looper.pycompiled_at timestamp
  • templates/run-loop.pyutc_now()

2. fixed_passes test fails on Windows only

tests/test_looper.py embeds sys.executable into a YAML double-quoted string. On Windows that path has backslashes (C:\Users\...), which are invalid YAML escape sequences (\U, \l, …), so test_fixed_passes_does_not_bypass_failed_programmatic_check fails at YAML parse time. The other fixtures already use Path(sys.executable).as_posix(); this aligns that one line.

Testing

python -m unittest discover -s tests7/7 pass on Windows (Python 3.14). Previously 6/7 (the fixed_passes test failed on Windows only).

Notes

No behavior change — timezone.utc is equivalent to UTC. Kept as two independent commits.

datetime.UTC was added in Python 3.11, but pyproject declares requires-python >=3.9. Replace datetime.now(UTC) with datetime.now(timezone.utc) in the compiler and the runner template so compile and run-loop work on Python 3.9 and 3.10 instead of raising AttributeError.
On Windows, sys.executable contains backslashes that are invalid escape sequences inside the YAML double-quoted check string, so the fixed_passes test failed at YAML parse time. Use Path(sys.executable).as_posix() to match the other fixtures and keep the embedded argv valid on Windows.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant