From 871714236b0b478dbf8b6396bf50bae030d4c2d2 Mon Sep 17 00:00:00 2001 From: Zoran Simic Date: Mon, 4 May 2026 14:35:36 -0700 Subject: [PATCH] No em-dashes in _inspect.py --- src/runez/_inspect.py | 2 +- tests/test_pyenv.py | 11 +++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/src/runez/_inspect.py b/src/runez/_inspect.py index bf91c5e..363e2cc 100644 --- a/src/runez/_inspect.py +++ b/src/runez/_inspect.py @@ -6,7 +6,7 @@ def simple_inspection(): - # `Py_GIL_DISABLED` is None on regular CPython builds and 1 on freethreaded builds — normalize to bool + # `Py_GIL_DISABLED` is None on regular CPython builds and 1 on freethreaded builds, normalize to bool freethreading = bool(sysconfig.get_config_var("Py_GIL_DISABLED")) return {"version": ".".join(str(s) for s in sys.version_info[:3]), "machine": platform.machine(), "freethreading": freethreading} diff --git a/tests/test_pyenv.py b/tests/test_pyenv.py index 52e18aa..5b8eb83 100644 --- a/tests/test_pyenv.py +++ b/tests/test_pyenv.py @@ -243,6 +243,17 @@ def test_inspect(): assert '"version":' in r.output +def test_inspect_is_ascii_only(): + # `_inspect.py` may be invoked by arbitrary (possibly Py2) python binaries, so it must stay + # ASCII-only: a stray non-ASCII byte raises SyntaxError under Py2 unless an encoding is declared. + import runez._inspect + + inspect_path = runez.to_path(runez._inspect.__file__) + src_text = inspect_path.read_text() + src_bytes = inspect_path.read_bytes() + assert src_bytes.decode("ascii") == src_text # raises UnicodeDecodeError if any non-ASCII byte sneaks in + + def test_invoker(): import runez.pyenv