Skip to content

Commit 925a8b6

Browse files
committed
fix __module__ of function object
1 parent 401409d commit 925a8b6

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

extension.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -551,9 +551,11 @@ func (m Module) AddType(obj, init any, name, doc string) Object {
551551
*currentSlot = slot
552552
}
553553

554+
typeName := fmt.Sprintf("%s.%s", m.Name(), name)
555+
554556
totalSize := unsafe.Sizeof(wrapperType{})
555557
spec := &C.PyType_Spec{
556-
name: C.CString(name),
558+
name: C.CString(typeName),
557559
basicsize: C.int(totalSize),
558560
flags: C.Py_TPFLAGS_DEFAULT,
559561
slots: slotsPtr,

module.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,10 @@ func (m Module) AddObject(name string, obj Object) int {
3636
return r
3737
}
3838

39+
func (m Module) Name() string {
40+
return C.GoString(C.PyModule_GetName(m.obj))
41+
}
42+
3943
func CreateModule(name string) Module {
4044
mod := C.PyModule_New(AllocCStrDontFree(name))
4145
return newModule(mod)

0 commit comments

Comments
 (0)