Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/runez/_inspect.py
Original file line number Diff line number Diff line change
Expand Up @@ -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}

Expand Down
11 changes: 11 additions & 0 deletions tests/test_pyenv.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Loading