Skip to content

Fix warning regarding undefined __module__ on GC Offset Base #1646

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 23, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/runtime/typemanager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -456,7 +456,7 @@ internal static PyType CreateMetatypeWithGCHandleOffset()
int size = Util.ReadInt32(Runtime.PyTypeType, TypeOffset.tp_basicsize)
+ IntPtr.Size // tp_clr_inst_offset
;
var result = new PyType(new TypeSpec("GC Offset Base", basicSize: size,
var result = new PyType(new TypeSpec("clr._internal.GCOffsetBase", basicSize: size,
new TypeSpec.Slot[]
{

Expand All @@ -480,7 +480,7 @@ internal static PyType CreateMetaType(Type impl, out SlotsHolder slotsHolder)

PyType gcOffsetBase = CreateMetatypeWithGCHandleOffset();

PyType type = AllocateTypeObject("CLR Metatype", metatype: gcOffsetBase);
PyType type = AllocateTypeObject("CLRMetatype", metatype: gcOffsetBase);

Util.WriteRef(type, TypeOffset.tp_base, new NewReference(gcOffsetBase).Steal());

Expand Down Expand Up @@ -509,7 +509,7 @@ internal static PyType CreateMetaType(Type impl, out SlotsHolder slotsHolder)
}

BorrowedReference dict = Util.ReadRef(type, TypeOffset.tp_dict);
using (var mod = Runtime.PyString_FromString("CLR"))
using (var mod = Runtime.PyString_FromString("clr._internal"))
Runtime.PyDict_SetItemString(dict, "__module__", mod.Borrow());

// The type has been modified after PyType_Ready has been called
Expand Down
2 changes: 1 addition & 1 deletion tests/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def is_clr_root_module(ob):


def is_clr_class(ob):
return type(ob).__name__ == 'CLR Metatype' # for now
return type(ob).__name__ == 'CLRMetatype' and type(ob).__module__ == 'clr._internal' # for now


class ClassicClass:
Expand Down