Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit2533df1

Browse files
committed
Set ht_token to NULL in Python 3.14
1 parentdfe8fff commit2533df1

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

‎src/runtime/Native/TypeOffset.cs‎

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,8 @@ static partial class TypeOffset
7777
internalstaticinttp_setattro{get;privateset;}
7878
internalstaticinttp_str{get;privateset;}
7979
internalstaticinttp_traverse{get;privateset;}
80+
// Special case: Only available in Python 3.14 onwards, set to -1 by default
81+
internalstaticintht_token{get;privateset;}=-1;
8082

8183
internalstaticvoidUse(ITypeOffsetsoffsets,intextraHeadOffset)
8284
{
@@ -89,6 +91,19 @@ internal static void Use(ITypeOffsets offsets, int extraHeadOffset)
8991
slotNames.Add(offsetProperty.Name);
9092

9193
varsourceProperty=typeof(ITypeOffsets).GetProperty(offsetProperty.Name);
94+
if(sourceProperty==null)
95+
{
96+
if((int)offsetProperty.GetValue(null)==-1)
97+
{
98+
// Skip, this is an optional offset value
99+
continue;
100+
}
101+
else
102+
{
103+
thrownewException($"No offset defined for necessary slot{offsetProperty.Name}");
104+
}
105+
}
106+
92107
intvalue=(int)sourceProperty.GetValue(offsets,null);
93108
value+=extraHeadOffset;
94109
offsetProperty.SetValue(obj:null,value:value,index:null);

‎src/runtime/TypeManager.cs‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -618,6 +618,11 @@ internal static PyType AllocateTypeObject(string name, PyType metatype)
618618
Util.WriteIntPtr(type,TypeOffset.tp_traverse,subtype_traverse);
619619
Util.WriteIntPtr(type,TypeOffset.tp_clear,subtype_clear);
620620

621+
// This is a new mechanism in Python 3.14. We should eventually use it to implement
622+
// a nicer type check, but for now we just need to ensure that it is set to NULL.
623+
if(TypeOffset.ht_token!=-1)
624+
Util.WriteIntPtr(type,TypeOffset.ht_token,IntPtr.Zero);
625+
621626
InheritSubstructs(type.Reference.DangerousGetAddress());
622627

623628
returntype;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp