diff --git a/NEWS.rst b/NEWS.rst index b86a669d2..71a10467d 100644 --- a/NEWS.rst +++ b/NEWS.rst @@ -5,6 +5,7 @@ Unreleased Bug Fixes ------------------------------ +* Fixed a crash on Python 3.12.6. * Keyword objects can now be compared to each other with `<` etc. 0.29.0 (released 2024-05-20) diff --git a/hy/compat.py b/hy/compat.py index f81ca7191..a77f4834d 100644 --- a/hy/compat.py +++ b/hy/compat.py @@ -6,6 +6,7 @@ PY3_10 = sys.version_info >= (3, 10) PY3_11 = sys.version_info >= (3, 11) PY3_12 = sys.version_info >= (3, 12) +PY3_12_6 = sys.version_info >= (3, 12, 6) PYPY = platform.python_implementation() == "PyPy" PYODIDE = platform.system() == "Emscripten" diff --git a/hy/importer.py b/hy/importer.py index 554281e14..463df6870 100644 --- a/hy/importer.py +++ b/hy/importer.py @@ -99,7 +99,7 @@ def _get_code_from_file(run_name, fname=None, hy_src_check=lambda x: x.endswith( source = f.read().decode("utf-8") code = compile(source, fname, "exec") - return (code, fname) + return code if hy.compat.PY3_12_6 else (code, fname) importlib.machinery.SOURCE_SUFFIXES.insert(0, ".hy")