FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Merge pull request #2611 from pythonnet/python3.14 · gwl78/pythonnet@8cb4b35 · GitHub

Repository navigation

Commit 8cb4b35

Browse files
authored
Merge pull request pythonnet#2611 from pythonnet/python3.14
Python 3.14
2 parents 1b43410 + cebfd15 commit 8cb4b35

14 files changed

Lines changed: 591 additions & 213 deletions

File tree

‎.github/workflows/main.yml‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,13 @@ jobs:
3636

3737
- category: macos
3838
platform: x64
39-
instance: macos-13
39+
instance: macos-14
4040

41-
python: ["3.10", "3.11", "3.12", "3.13"]
41+
- category: macos
42+
platform: arm64
43+
instance: macos-14-arm64
44+
45+
python: ["3.10", "3.11", "3.12", "3.13", "3.14"]
4246

4347
steps:
4448
- name: Set Environment on macOS

‎pyproject.toml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ dependencies = [
1313
"clr_loader>=0.2.7,<0.3.0"
1414
]
1515

16-
requires-python = ">=3.10, <3.14"
16+
requires-python = ">=3.10, <3.15"
1717

1818
classifiers = [
1919
"Development Status :: 5 - Production/Stable",

‎requirements.txt‎

Lines changed: 0 additions & 14 deletions
This file was deleted.

‎src/runtime/CollectionWrappers/ListWrapper.cs‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,14 @@ public T this[int index]
1414
{
1515
get
1616
{
17+
using var _ = Py.GIL();
1718
var item = Runtime.PyList_GetItem(pyObject, index);
1819
var pyItem = new PyObject(item);
1920
return pyItem.As<T>()!;
2021
}
2122
set
2223
{
24+
using var _ = Py.GIL();
2325
var pyItem = value.ToPython();
2426
var result = Runtime.PyList_SetItem(pyObject, index, new NewReference(pyItem).Steal());
2527
if (result == -1)
@@ -37,6 +39,7 @@ public void Insert(int index, T item)
3739
if (IsReadOnly)
3840
throw new InvalidOperationException("Collection is read-only");
3941

42+
using var _ = Py.GIL();
4043
var pyItem = item.ToPython();
4144

4245
int result = Runtime.PyList_Insert(pyObject, index, pyItem);

‎src/runtime/CollectionWrappers/SequenceWrapper.cs‎

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,14 @@ public int Count
1414
{
1515
get
1616
{
17-
var size = Runtime.PySequence_Size(pyObject.Reference);
18-
if (size == -1)
17+
nint size = -1;
1918
{
20-
Runtime.CheckExceptionOccurred();
19+
using var _ = Py.GIL();
20+
size = Runtime.PySequence_Size(pyObject.Reference);
21+
if (size == -1)
22+
{
23+
Runtime.CheckExceptionOccurred();
24+
}
2125
}
2226

2327
return checked((int)size);
@@ -38,6 +42,7 @@ public void Clear()
3842
{
3943
if (IsReadOnly)
4044
throw new NotImplementedException();
45+
using var _ = Py.GIL();
4146
int result = Runtime.PySequence_DelSlice(pyObject, 0, Count);
4247
if (result == -1)
4348
{
@@ -77,12 +82,16 @@ protected bool removeAt(int index)
7782
if (index >= Count || index < 0)
7883
return false;
7984

80-
int result = Runtime.PySequence_DelItem(pyObject, index);
8185

82-
if (result == 0)
83-
return true;
86+
{
87+
using var _ = Py.GIL();
88+
int result = Runtime.PySequence_DelItem(pyObject, index);
89+
90+
if (result == 0)
91+
return true;
8492

85-
Runtime.CheckExceptionOccurred();
93+
Runtime.CheckExceptionOccurred();
94+
}
8695
return false;
8796
}
8897

‎src/runtime/Native/PyIdentifier_.cs‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,6 @@ static class PyIdentifier
1313
public static BorrowedReference __doc__ => new(f__doc__);
1414
static IntPtr f__class__;
1515
public static BorrowedReference __class__ => new(f__class__);
16-
static IntPtr f__clear_reentry_guard__;
17-
public static BorrowedReference __clear_reentry_guard__ => new(f__clear_reentry_guard__);
1816
static IntPtr f__module__;
1917
public static BorrowedReference __module__ => new(f__module__);
2018
static IntPtr f__file__;
@@ -24,6 +22,8 @@ static class PyIdentifier
2422
static IntPtr f__self__;
2523
public static BorrowedReference __self__ => new(f__self__);
2624
static IntPtr f__annotations__;
25+
public static BorrowedReference __dictoffset__ => new(f__dictoffset__);
26+
static IntPtr f__dictoffset__;
2727
public static BorrowedReference __annotations__ => new(f__annotations__);
2828
static IntPtr f__init__;
2929
public static BorrowedReference __init__ => new(f__init__);
@@ -51,12 +51,12 @@ static partial class InternString
5151
"__dict__",
5252
"__doc__",
5353
"__class__",
54-
"__clear_reentry_guard__",
5554
"__module__",
5655
"__file__",
5756
"__slots__",
5857
"__self__",
5958
"__annotations__",
59+
"__dictoffset__",
6060
"__init__",
6161
"__repr__",
6262
"__import__",

‎src/runtime/Native/PyIdentifier_.tt‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,12 @@
77
"__dict__",
88
"__doc__",
99
"__class__",
10-
"__clear_reentry_guard__",
1110
"__module__",
1211
"__file__",
1312
"__slots__",
1413
"__self__",
1514
"__annotations__",
15+
"__dictoffset__",
1616

1717
"__init__",
1818
"__repr__",

‎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
internal static int tp_setattro { get; private set; }
7878
internal static int tp_str { get; private set; }
7979
internal static int tp_traverse { get; private set; }
80+
// Special case: Only available in Python 3.14 onwards, set to -1 by default
81+
internal static int ht_token { get; private set; } = -1;
8082

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

9193
var sourceProperty = 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+
throw new Exception($"No offset defined for necessary slot {offsetProperty.Name}");
104+
}
105+
}
106+
92107
int value = (int)sourceProperty.GetValue(offsets, null);
93108
value += extraHeadOffset;
94109
offsetProperty.SetValue(obj: null, value: value, index: null);
Lines changed: 153 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,153 @@
1+
2+
// Auto-generated by geninterop.py.
3+
// DO NOT MODIFY BY HAND.
4+
5+
// Python 3.14: ABI flags: ''
6+
7+
// ReSharper disable InconsistentNaming
8+
// ReSharper disable IdentifierTypo
9+
10+
using System;
11+
using System.Diagnostics.CodeAnalysis;
12+
using System.Runtime.InteropServices;
13+
14+
using Python.Runtime.Native;
15+
16+
namespace Python.Runtime
17+
{
18+
[SuppressMessage("Style", "IDE1006:Naming Styles",
19+
Justification = "Following CPython",
20+
Scope = "type")]
21+
22+
[StructLayout(LayoutKind.Sequential)]
23+
internal class TypeOffset314 : GeneratedTypeOffsets, ITypeOffsets
24+
{
25+
public TypeOffset314() { }
26+
// Auto-generated from PyHeapTypeObject in Python.h
27+
public int ob_refcnt_full { get; private set; }
28+
public int ob_type { get; private set; }
29+
public int ob_size { get; private set; }
30+
public int tp_name { get; private set; }
31+
public int tp_basicsize { get; private set; }
32+
public int tp_itemsize { get; private set; }
33+
public int tp_dealloc { get; private set; }
34+
public int tp_vectorcall_offset { get; private set; }
35+
public int tp_getattr { get; private set; }
36+
public int tp_setattr { get; private set; }
37+
public int tp_as_async { get; private set; }
38+
public int tp_repr { get; private set; }
39+
public int tp_as_number { get; private set; }
40+
public int tp_as_sequence { get; private set; }
41+
public int tp_as_mapping { get; private set; }
42+
public int tp_hash { get; private set; }
43+
public int tp_call { get; private set; }
44+
public int tp_str { get; private set; }
45+
public int tp_getattro { get; private set; }
46+
public int tp_setattro { get; private set; }
47+
public int tp_as_buffer { get; private set; }
48+
public int tp_flags { get; private set; }
49+
public int tp_doc { get; private set; }
50+
public int tp_traverse { get; private set; }
51+
public int tp_clear { get; private set; }
52+
public int tp_richcompare { get; private set; }
53+
public int tp_weaklistoffset { get; private set; }
54+
public int tp_iter { get; private set; }
55+
public int tp_iternext { get; private set; }
56+
public int tp_methods { get; private set; }
57+
public int tp_members { get; private set; }
58+
public int tp_getset { get; private set; }
59+
public int tp_base { get; private set; }
60+
public int tp_dict { get; private set; }
61+
public int tp_descr_get { get; private set; }
62+
public int tp_descr_set { get; private set; }
63+
public int tp_dictoffset { get; private set; }
64+
public int tp_init { get; private set; }
65+
public int tp_alloc { get; private set; }
66+
public int tp_new { get; private set; }
67+
public int tp_free { get; private set; }
68+
public int tp_is_gc { get; private set; }
69+
public int tp_bases { get; private set; }
70+
public int tp_mro { get; private set; }
71+
public int tp_cache { get; private set; }
72+
public int tp_subclasses { get; private set; }
73+
public int tp_weaklist { get; private set; }
74+
public int tp_del { get; private set; }
75+
public int tp_version_tag { get; private set; }
76+
public int tp_finalize { get; private set; }
77+
public int tp_vectorcall { get; private set; }
78+
// This is an error in our generator:
79+
//
80+
// The fields below are actually not pointers (like we incorrectly
81+
// assume for all other fields) but instead a char (1 byte) and a short
82+
// (2 bytes). By dropping one of the fields, we still get the correct
83+
// overall size of the struct.
84+
public int tp_watched { get; private set; }
85+
// public int tp_versions_used { get; private set; }
86+
public int am_await { get; private set; }
87+
public int am_aiter { get; private set; }
88+
public int am_anext { get; private set; }
89+
public int am_send { get; private set; }
90+
public int nb_add { get; private set; }
91+
public int nb_subtract { get; private set; }
92+
public int nb_multiply { get; private set; }
93+
public int nb_remainder { get; private set; }
94+
public int nb_divmod { get; private set; }
95+
public int nb_power { get; private set; }
96+
public int nb_negative { get; private set; }
97+
public int nb_positive { get; private set; }
98+
public int nb_absolute { get; private set; }
99+
public int nb_bool { get; private set; }
100+
public int nb_invert { get; private set; }
101+
public int nb_lshift { get; private set; }
102+
public int nb_rshift { get; private set; }
103+
public int nb_and { get; private set; }
104+
public int nb_xor { get; private set; }
105+
public int nb_or { get; private set; }
106+
public int nb_int { get; private set; }
107+
public int nb_reserved { get; private set; }
108+
public int nb_float { get; private set; }
109+
public int nb_inplace_add { get; private set; }
110+
public int nb_inplace_subtract { get; private set; }
111+
public int nb_inplace_multiply { get; private set; }
112+
public int nb_inplace_remainder { get; private set; }
113+
public int nb_inplace_power { get; private set; }
114+
public int nb_inplace_lshift { get; private set; }
115+
public int nb_inplace_rshift { get; private set; }
116+
public int nb_inplace_and { get; private set; }
117+
public int nb_inplace_xor { get; private set; }
118+
public int nb_inplace_or { get; private set; }
119+
public int nb_floor_divide { get; private set; }
120+
public int nb_true_divide { get; private set; }
121+
public int nb_inplace_floor_divide { get; private set; }
122+
public int nb_inplace_true_divide { get; private set; }
123+
public int nb_index { get; private set; }
124+
public int nb_matrix_multiply { get; private set; }
125+
public int nb_inplace_matrix_multiply { get; private set; }
126+
public int mp_length { get; private set; }
127+
public int mp_subscript { get; private set; }
128+
public int mp_ass_subscript { get; private set; }
129+
public int sq_length { get; private set; }
130+
public int sq_concat { get; private set; }
131+
public int sq_repeat { get; private set; }
132+
public int sq_item { get; private set; }
133+
public int was_sq_slice { get; private set; }
134+
public int sq_ass_item { get; private set; }
135+
public int was_sq_ass_slice { get; private set; }
136+
public int sq_contains { get; private set; }
137+
public int sq_inplace_concat { get; private set; }
138+
public int sq_inplace_repeat { get; private set; }
139+
public int bf_getbuffer { get; private set; }
140+
public int bf_releasebuffer { get; private set; }
141+
public int name { get; private set; }
142+
public int ht_slots { get; private set; }
143+
public int qualname { get; private set; }
144+
public int ht_cached_keys { get; private set; }
145+
public int ht_module { get; private set; }
146+
public int _ht_tpname { get; private set; }
147+
public int ht_token { get; private set; }
148+
public int spec_cache_getitem { get; private set; }
149+
public int getitem_version { get; private set; }
150+
public int init { get; private set; }
151+
}
152+
}
153+

‎src/runtime/PythonEngine.cs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ public static string PythonPath
135135
}
136136

137137
public static Version MinSupportedVersion => new(3, 7);
138-
public static Version MaxSupportedVersion => new(3, 13, int.MaxValue, int.MaxValue);
138+
public static Version MaxSupportedVersion => new(3, 14, int.MaxValue, int.MaxValue);
139139
public static bool IsSupportedVersion(Version version) => version >= MinSupportedVersion && version <= MaxSupportedVersion;
140140

141141
public static string Version

0 commit comments

Comments
 (0)

Back | FazBrowse Home | New Git URL