Skip to content

Python 3.11 #1955

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 14 commits into from
Nov 2, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Define slots before initialization
  • Loading branch information
filmor committed Oct 28, 2022
commit 8668579834623a1ef196840b8f2a93407f52701b
1 change: 1 addition & 0 deletions src/runtime/PythonTypes/PyType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ private static StolenReference FromSpec(TypeSpec spec, PyTuple? bases = null)
using var nativeSpec = new NativeTypeSpec(spec);
var basesRef = bases is null ? default : bases.Reference;
var result = Runtime.PyType_FromSpecWithBases(in nativeSpec, basesRef);
// Runtime.PyErr_Print();
return result.StealOrThrow();
}
}
Expand Down
23 changes: 13 additions & 10 deletions src/runtime/TypeManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -475,17 +475,20 @@ 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("clr._internal.GCOffsetBase", basicSize: size,
new TypeSpec.Slot[]
{

},
TypeFlags.Default | TypeFlags.HeapType | TypeFlags.HaveGC),
bases: new PyTuple(new[] { py_type }));

SetRequiredSlots(result, seen: new HashSet<string>());

Runtime.PyType_Modified(result);
var slots = new[] {
new TypeSpec.Slot(TypeSlotID.tp_traverse, subtype_traverse),
new TypeSpec.Slot(TypeSlotID.tp_clear, subtype_clear)
};
Comment on lines +479 to +482
Copy link
Member

@lostmsu lostmsu Oct 18, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This creates multiple sources of truth. Does editing post creation not work?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It doesn't. Python 3.11 rejects creating a type that has HAVE_GC set but not these slots. Rightly so :)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we have this array shared with the other place that used to use this function?

var result = new PyType(
new TypeSpec(
"clr._internal.GCOffsetBase",
basicSize: size,
slots: slots,
TypeFlags.Default | TypeFlags.HeapType | TypeFlags.HaveGC
),
bases: new PyTuple(new[] { py_type })
);

return result;
}
Expand Down
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy