Skip to content

Commit 5551be7

Browse files
committed
Fix running on older Python versions
1 parent e115a10 commit 5551be7

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

mypyc/codegen/emitmodule.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
import json
99
import os
10+
import sys
1011
from collections.abc import Iterable
1112
from typing import Optional, TypeVar
1213

@@ -882,10 +883,12 @@ def emit_module_def_slots(self, emitter: Emitter, module_prefix: str) -> None:
882883

883884
emitter.emit_line(f"static PyModuleDef_Slot {name}[] = {{")
884885
emitter.emit_line(f"{{Py_mod_exec, {exec_name}}},")
885-
emitter.emit_line(
886-
"{Py_mod_multiple_interpreters, Py_MOD_MULTIPLE_INTERPRETERS_NOT_SUPPORTED},"
887-
)
888-
emitter.emit_line("{Py_mod_gil, Py_MOD_GIL_NOT_USED},")
886+
if sys.version_info >= (3, 12):
887+
emitter.emit_line(
888+
"{Py_mod_multiple_interpreters, Py_MOD_MULTIPLE_INTERPRETERS_NOT_SUPPORTED},"
889+
)
890+
if sys.version_info >= (3, 13):
891+
emitter.emit_line("{Py_mod_gil, Py_MOD_GIL_NOT_USED},")
889892
emitter.emit_line("{0, NULL},")
890893
emitter.emit_line("};")
891894

0 commit comments

Comments
 (0)