Skip to content

Commit de8b572

Browse files
committed
Fix: accept any object for '__module__' in 'PyCFunction_NewEx'.
1 parent 778b2c9 commit de8b572

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

graalpython/lib-graalpython/python_cext.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -704,7 +704,7 @@ def AddFunction(primary, name, cfunc, cwrapper, wrapper, doc, isclass=False, iss
704704
owner = to_java(primary)
705705
if isinstance(owner, moduletype):
706706
# module case, we create the bound function-or-method
707-
func = PyCFunction_NewEx(name, cfunc, cwrapper, wrapper, owner, owner, doc)
707+
func = PyCFunction_NewEx(name, cfunc, cwrapper, wrapper, owner, owner.__name__, doc)
708708
object.__setattr__(owner, name, func)
709709
else:
710710
func = wrapper(CreateFunction(name, cfunc, cwrapper, owner))
@@ -728,7 +728,7 @@ def PyCFunction_NewEx(name, cfunc, cwrapper, wrapper, self, module, doc):
728728
PyTruffle_SetAttr(func, "__name__", name)
729729
PyTruffle_SetAttr(func, "__doc__", doc)
730730
method = PyTruffle_BuiltinMethod(self, func)
731-
PyTruffle_SetAttr(method, "__module__", module.__name__)
731+
PyTruffle_SetAttr(method, "__module__", to_java(module))
732732
return method
733733

734734

0 commit comments

Comments
 (0)