Skip to content

Commit 11a287b

Browse files
committed
Add support for Python 3.14
Signed-off-by: Peter Bierma <[email protected]>
1 parent 32347d9 commit 11a287b

File tree

14 files changed

+508
-14
lines changed

14 files changed

+508
-14
lines changed

.github/workflows/build_wheels.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ jobs:
6868
- name: Build wheels
6969
uses: pypa/[email protected]
7070
env:
71-
CIBW_BUILD: "cp3{7..13}-${{ matrix.wheel_type }}"
71+
CIBW_BUILD: "cp3{7..14}-${{ matrix.wheel_type }}"
7272
CIBW_ARCHS_LINUX: auto aarch64
7373
CIBW_PRERELEASE_PYTHONS: True
7474
- uses: actions/upload-artifact@v4
@@ -78,7 +78,7 @@ jobs:
7878

7979
test_attaching_to_old_interpreters:
8080
needs: [build_wheels]
81-
runs-on: ubuntu-20.04
81+
runs-on: ubuntu-22.04
8282
strategy:
8383
fail-fast: false
8484
matrix:
@@ -116,11 +116,11 @@ jobs:
116116

117117
test_wheels:
118118
needs: [build_wheels]
119-
runs-on: ubuntu-20.04
119+
runs-on: ubuntu-22.04
120120
strategy:
121121
fail-fast: false
122122
matrix:
123-
python_version: ["3.7", "3.8", "3.9", "3.10", "3.11", "3.12", "3.13"]
123+
python_version: ["3.7", "3.8", "3.9", "3.10", "3.11", "3.12", "3.13", "3.14"]
124124
steps:
125125
- uses: actions/checkout@v4
126126
- name: Set up Python
@@ -154,11 +154,11 @@ jobs:
154154

155155
test_free_threading:
156156
needs: [build_wheels]
157-
runs-on: ubuntu-20.04
157+
runs-on: ubuntu-22.04
158158
strategy:
159159
fail-fast: false
160160
matrix:
161-
python_version: ["3.13"]
161+
python_version: ["3.13", "3.14"]
162162
steps:
163163
- uses: actions/checkout@v4
164164
- name: Set up Python

news/229.feature.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Add support for Python 3.14

src/pystack/_pystack/cpython/code.h

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,4 +197,43 @@ typedef struct
197197
} PyCodeObject;
198198
} // namespace Python3_13
199199

200+
namespace Python3_14 {
201+
typedef uint16_t _Py_CODEUNIT;
202+
203+
typedef struct {
204+
PyObject_VAR_HEAD
205+
PyObject *co_consts;
206+
PyObject *co_names;
207+
PyObject *co_exceptiontable;
208+
int co_flags;
209+
int co_argcount;
210+
int co_posonlyargcount;
211+
int co_kwonlyargcount;
212+
int co_stacksize;
213+
int co_firstlineno;
214+
int co_nlocalsplus;
215+
int co_framesize;
216+
int co_nlocals;
217+
int co_ncellvars;
218+
int co_nfreevars;
219+
uint32_t co_version;
220+
PyObject *co_localsplusnames;
221+
PyObject *co_localspluskinds;
222+
PyObject *co_filename;
223+
PyObject *co_name;
224+
PyObject *co_qualname;
225+
PyObject *co_linetable;
226+
PyObject *co_weakreflist;
227+
void *co_executors;
228+
void *_co_cached;
229+
uintptr_t _co_instrumentation_version;
230+
void *_co_monitoring;
231+
Py_ssize_t _co_unique_id;
232+
int _co_firsttraceable;
233+
void *co_extra;
234+
/* deal with co_tlbc somehow */
235+
char co_code_adaptive[1];
236+
} PyCodeObject;
237+
} // namespace Python3_14
238+
200239
} // namespace pystack

src/pystack/_pystack/cpython/frame.h

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,4 +126,29 @@ typedef struct _interpreter_frame
126126

127127
} // namespace Python3_12
128128

129+
namespace Python3_14 {
130+
131+
typedef union _PyStackRef {
132+
uintptr_t bits;
133+
} _PyStackRef;
134+
135+
typedef struct _interpreter_frame {
136+
_PyStackRef f_executable;
137+
void *previous;
138+
void *f_funcobj;
139+
PyObject *f_globals;
140+
PyObject *f_builtins;
141+
PyObject *f_locals;
142+
PyObject *frame_obj;
143+
_Py_CODEUNIT *instr_ptr;
144+
_PyStackRef stackpointer;
145+
/* int32_t tlbc_index; */
146+
uint16_t return_offset;
147+
char owner;
148+
uint8_t visited;
149+
void *localsplus[1];
150+
} PyFrameObject;
151+
152+
} // namespace Python3_14
153+
129154
} // namespace pystack

src/pystack/_pystack/cpython/gc.h

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,4 +82,27 @@ struct _gc_runtime_state
8282
};
8383

8484
} // namespace Python3_8
85+
86+
namespace Python3_14 {
87+
88+
struct _gc_runtime_state {
89+
PyObject *trash_delete_later;
90+
int trash_delete_nesting;
91+
int enabled;
92+
int debug;
93+
struct Python3_8::gc_generation young;
94+
struct Python3_8::gc_generation old[2];
95+
struct Python3_8::gc_generation permanent_generation;
96+
struct gc_generation_stats generation_stats[NUM_GENERATIONS];
97+
int collecting;
98+
PyObject *garbage;
99+
PyObject *callbacks;
100+
Py_ssize_t heap_size;
101+
Py_ssize_t work_to_do;
102+
int visited_space;
103+
int phase;
104+
};
105+
106+
} // namespace Python3_14
107+
85108
} // namespace pystack

src/pystack/_pystack/cpython/interpreter.h

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -338,4 +338,76 @@ typedef struct _is
338338
struct _import_state imports;
339339
} PyInterpreterState;
340340
} // namespace Python3_13
341+
342+
namespace Python3_14 {
343+
344+
struct _pythreadstate;
345+
346+
typedef struct {
347+
Python3_13::PyMutex mutex;
348+
unsigned long long thread;
349+
size_t level;
350+
} _PyRecursiveMutex;
351+
352+
struct _import_state {
353+
PyObject *modules;
354+
PyObject *modules_by_index;
355+
PyObject *importlib;
356+
int override_frozen_modules;
357+
int override_multi_interp_extensions_check;
358+
PyObject *import_func;
359+
_PyRecursiveMutex lock;
360+
/* diagnostic info in PyImport_ImportModuleLevelObject() */
361+
struct {
362+
int import_level;
363+
int64_t accumulated;
364+
int header;
365+
} find_and_load;
366+
};
367+
368+
struct _gil_runtime_state {
369+
unsigned long interval;
370+
struct _pythreadstate* last_holder;
371+
int locked;
372+
unsigned long switch_number;
373+
pthread_cond_t cond;
374+
pthread_cond_t mutex;
375+
#ifdef FORCE_SWITCHING
376+
pthread_cond_t switch_cond;
377+
pthread_cond_t switch_mutex;
378+
#endif
379+
};
380+
381+
typedef struct _is {
382+
struct _ceval_state ceval;
383+
void *_malloced;
384+
struct _is *next;
385+
int64_t id;
386+
Py_ssize_t id_refcount;
387+
int requires_idref;
388+
long _whence;
389+
int _initialized;
390+
int _ready;
391+
int finalizing;
392+
uintptr_t last_restart_version;
393+
struct pythreads {
394+
uint64_t next_unique_id;
395+
struct _pythreadstate *head;
396+
struct _pythreadstate *preallocated;
397+
struct _pythreadstate *main;
398+
Py_ssize_t count;
399+
size_t stacksize;
400+
} threads;
401+
void *runtime;
402+
struct _pythreadstate* _finalizing;
403+
unsigned long _finalizing_id;
404+
struct _gc_runtime_state gc;
405+
PyObject *sysdict;
406+
PyObject *builtins;
407+
struct _import_state imports;
408+
struct _gil_runtime_state _gil;
409+
} PyInterpreterState;
410+
411+
} // namespace Python3_14
412+
341413
} // namespace pystack

0 commit comments

Comments
 (0)