Skip to content

Commit a802c16

Browse files
committed
fix: add flag
1 parent ca8ffad commit a802c16

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

mypyc/codegen/emitmodule.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
import os
1010
import sys
1111
from collections.abc import Iterable
12-
from typing import Optional, TypeVar
12+
from typing import List, Optional, TypeVar
1313

1414
from mypy.build import (
1515
BuildResult,
@@ -911,15 +911,19 @@ def emit_module_methods(
911911
if fn.class_name is not None or fn.name == TOP_LEVEL_NAME:
912912
continue
913913
name = short_id_from_name(fn.name, fn.decl.shortname, fn.line)
914+
flags: List[str] = []
914915
if is_fastcall_supported(fn, emitter.capi_version):
915-
flag = "METH_FASTCALL"
916+
flags.append("METH_FASTCALL")
916917
else:
917-
flag = "METH_VARARGS"
918+
flags.append("METH_VARARGS")
919+
flags.append("METH_KEYWORDS")
920+
if fn.decl.is_async:
921+
flags.append("METH_COROUTINE")
918922
emitter.emit_line(
919923
(
920-
'{{"{name}", (PyCFunction){prefix}{cname}, {flag} | METH_KEYWORDS, '
924+
'{{"{name}", (PyCFunction){prefix}{cname}, {flags}, '
921925
"NULL /* docstring */}},"
922-
).format(name=name, cname=fn.cname(emitter.names), prefix=PREFIX, flag=flag)
926+
).format(name=name, cname=fn.cname(emitter.names), prefix=PREFIX, flags=" | ".join(flags))
923927
)
924928
emitter.emit_line("{NULL, NULL, 0, NULL}")
925929
emitter.emit_line("};")

0 commit comments

Comments
 (0)