Nuitka
The Python compiler
Loading...
Searching...
No Matches
prelude.h
1// Copyright 2025, Kay Hayen, mailto:kay.hayen@gmail.com find license text at end of file
2
3#ifndef __NUITKA_PRELUDE_H__
4#define __NUITKA_PRELUDE_H__
5
6#ifdef __NUITKA_NO_ASSERT__
7#undef NDEBUG
8#define NDEBUG
9#endif
10
11#include "nuitka/debug_settings.h"
12
13#if defined(_WIN32)
14// Note: Keep this separate line, must be included before other Windows headers.
15#include <windows.h>
16#endif
17
18/* Include the CPython version numbers, and define our own take of what version
19 * numbers should be.
20 */
21#include <patchlevel.h>
22
23/* Use a hex version of our own to compare for versions. We do not care about pre-releases */
24#if PY_MICRO_VERSION < 16
25#define PYTHON_VERSION (PY_MAJOR_VERSION * 256 + PY_MINOR_VERSION * 16 + PY_MICRO_VERSION)
26#else
27#define PYTHON_VERSION (PY_MAJOR_VERSION * 256 + PY_MINOR_VERSION * 16 + 15)
28#endif
29
30/* This is needed or else we can't create modules name "proc" or "func". For
31 * Python3, the name collision can't happen, so we can limit it to Python2.
32 spell-checker: ignore initproc,initfunc
33 */
34#define initproc python_init_proc
35#define initfunc python_init_func
36#define initstate python_initstate
37
38// Python 3.11 headers give these warnings
39#if defined(_MSC_VER)
40#pragma warning(push)
41#pragma warning(disable : 4200)
42#pragma warning(disable : 4244)
43#endif
44
45/* Include the relevant Python C-API header files. */
46#include <Python.h>
47#include <frameobject.h>
48#include <marshal.h>
49#include <methodobject.h>
50#include <osdefs.h>
51#include <structseq.h>
52
53#if PYTHON_VERSION < 0x3a0
54#include <pydebug.h>
55#endif
56
57/* A way to not give warnings about things that are declared, but might not
58 * be used like in-line helper functions in headers or static per module
59 * variables from headers.
60 */
61#ifdef __GNUC__
62#define NUITKA_MAY_BE_UNUSED __attribute__((__unused__))
63#else
64#define NUITKA_MAY_BE_UNUSED
65#endif
66
67// We are not following the 3.10 change to an inline function. At least
68// not immediately.
69#if PYTHON_VERSION >= 0x3a0 && PYTHON_VERSION < 0x3c0
70#undef Py_REFCNT
71#define Py_REFCNT(ob) (_PyObject_CAST(ob)->ob_refcnt)
72#endif
73
74// We are using this new macro on old code too.
75#ifndef Py_SET_REFCNT
76#define Py_SET_REFCNT(ob, refcnt) Py_REFCNT(ob) = refcnt
77#endif
78
79#if defined(_WIN32)
80// Windows is too difficult for API redefines.
81#define MIN_PYCORE_PYTHON_VERSION 0x380
82#else
83#define MIN_PYCORE_PYTHON_VERSION 0x371
84#endif
85
86#if PYTHON_VERSION >= MIN_PYCORE_PYTHON_VERSION
87#define NUITKA_USE_PYCORE_THREAD_STATE
88#endif
89
90#ifdef NUITKA_USE_PYCORE_THREAD_STATE
91#undef Py_BUILD_CORE
92#define Py_BUILD_CORE
93#undef _PyGC_FINALIZED
94
95#if PYTHON_VERSION < 0x380
96#undef Py_ATOMIC_H
97#include <pyatomic.h>
98#undef Py_INTERNAL_PYSTATE_H
99#include <internal/pystate.h>
100#undef Py_STATE_H
101#include <pystate.h>
102
103extern _PyRuntimeState _PyRuntime;
104#else
105
106#if PYTHON_VERSION >= 0x3c0
107#include <internal/pycore_runtime.h>
108#include <internal/pycore_typevarobject.h>
109
110static inline size_t Nuitka_static_builtin_index_get(PyTypeObject *self) { return (size_t)self->tp_subclasses - 1; }
111
112// Changed internal type access for Python3.13
113#if PYTHON_VERSION < 0x3d0
114#define managed_static_type_state static_builtin_state
115
116static inline managed_static_type_state *Nuitka_static_builtin_state_get(PyInterpreterState *interp,
117 PyTypeObject *self) {
118 return &(interp->types.builtins[Nuitka_static_builtin_index_get(self)]);
119}
120#else
121static inline managed_static_type_state *Nuitka_static_builtin_state_get(PyInterpreterState *interp,
122 PyTypeObject *self) {
123 return &(interp->types.builtins.initialized[Nuitka_static_builtin_index_get(self)]);
124}
125#endif
126
127NUITKA_MAY_BE_UNUSED static inline managed_static_type_state *Nuitka_PyStaticType_GetState(PyInterpreterState *interp,
128 PyTypeObject *self) {
129 assert(self->tp_flags & _Py_TPFLAGS_STATIC_BUILTIN);
130 return Nuitka_static_builtin_state_get(interp, self);
131}
132
133#define _PyStaticType_GetState(interp, self) Nuitka_PyStaticType_GetState(interp, self)
134#endif
135
136#include <internal/pycore_pystate.h>
137#endif
138
139#if PYTHON_VERSION >= 0x390
140#include <internal/pycore_ceval.h>
141#include <internal/pycore_interp.h>
142#include <internal/pycore_runtime.h>
143#endif
144
145#if PYTHON_VERSION >= 0x380
146#include <cpython/initconfig.h>
147#include <internal/pycore_initconfig.h>
148#include <internal/pycore_pathconfig.h>
149#include <internal/pycore_pyerrors.h>
150#endif
151
152#if PYTHON_VERSION >= 0x3a0
153#include <internal/pycore_long.h>
154#include <internal/pycore_unionobject.h>
155#endif
156
157#if PYTHON_VERSION >= 0x3b0
158#include <internal/pycore_dict.h>
159#include <internal/pycore_frame.h>
160#include <internal/pycore_gc.h>
161#endif
162
163// Uncompiled generator integration requires these.
164#if PYTHON_VERSION >= 0x3b0
165#if PYTHON_VERSION >= 0x3d0
166#include <internal/pycore_opcode_utils.h>
167#include <opcode_ids.h>
168#else
169#include <internal/pycore_opcode.h>
170#endif
171// Clashes with our helper names.
172#undef CALL_FUNCTION
173#endif
174
175#if PYTHON_VERSION >= 0x3c0
176#include <cpython/code.h>
177#endif
178
179#if PYTHON_VERSION < 0x3c0
180// Make sure we go the really fast variant, spell-checker: ignore gilstate
181#undef PyThreadState_GET
182#define _PyThreadState_Current _PyRuntime.gilstate.tstate_current
183#define PyThreadState_GET() ((PyThreadState *)_Py_atomic_load_relaxed(&_PyThreadState_Current))
184#endif
185
186#if PYTHON_VERSION >= 0x380
187#undef _PyObject_LookupSpecial
188#include <internal/pycore_object.h>
189#else
190#include <objimpl.h>
191#endif
192
193#if PYTHON_VERSION >= 0x3d0
194#include <internal/pycore_critical_section.h>
195#include <internal/pycore_freelist.h>
196#include <internal/pycore_intrinsics.h>
197#include <internal/pycore_modsupport.h>
198#include <internal/pycore_parking_lot.h>
199#include <internal/pycore_pyatomic_ft_wrappers.h>
200#include <internal/pycore_setobject.h>
201#include <internal/pycore_time.h>
202#endif
203
204#if PYTHON_VERSION >= 0x3e0
205#include <internal/pycore_interpframe.h>
206#include <internal/pycore_tuple.h>
207#include <internal/pycore_typedefs.h>
208#include <internal/pycore_unicodeobject.h>
209#endif
210
211#undef Py_BUILD_CORE
212
213#endif
214
215#if defined(_MSC_VER)
216#pragma warning(pop)
217#endif
218
219/* See above. */
220#if PYTHON_VERSION < 0x300
221#undef initproc
222#undef initfunc
223#undef initstate
224#endif
225
226/* Type bool */
227#ifndef __cplusplus
228#include <stdbool.h>
229#endif
230
231/* Include the C header files most often used. */
232#include <stdio.h>
233
234#include "hedley.h"
235
236/* Use annotations for branch prediction. They still make sense as the L1
237 * cache space is saved.
238 */
239
240#define likely(x) HEDLEY_LIKELY(x)
241#define unlikely(x) HEDLEY_UNLIKELY(x)
242
243/* A way to indicate that a specific function won't return, so the C compiler
244 * can create better code.
245 */
246
247#define NUITKA_NO_RETURN HEDLEY_NO_RETURN
248
249/* This is used to indicate code control flows we know cannot happen. */
250#ifndef __NUITKA_NO_ASSERT__
251#define NUITKA_CANNOT_GET_HERE(NAME) \
252 PRINT_FORMAT("%s : %s\n", __FUNCTION__, #NAME); \
253 abort();
254#else
255#define NUITKA_CANNOT_GET_HERE(NAME) abort();
256#endif
257
258#define NUITKA_ERROR_EXIT(NAME) \
259 PRINT_FORMAT("%s : %s\n", __FUNCTION__, #NAME); \
260 abort();
261
262#if defined(_MSC_VER)
263/* Using "_alloca" extension due to MSVC restrictions for array variables
264 * on the local stack.
265 */
266#include <malloc.h>
267#define NUITKA_DYNAMIC_ARRAY_DECL(VARIABLE_NAME, ELEMENT_TYPE, COUNT) \
268 ELEMENT_TYPE *VARIABLE_NAME = (ELEMENT_TYPE *)_alloca(sizeof(ELEMENT_TYPE) * (COUNT));
269#else
270#define NUITKA_DYNAMIC_ARRAY_DECL(VARIABLE_NAME, ELEMENT_TYPE, COUNT) ELEMENT_TYPE VARIABLE_NAME[COUNT];
271#endif
272
273/* Python3 removed PyInt instead of renaming PyLong, and PyObject_Str instead
274 * of renaming PyObject_Unicode. Define this to be easily portable.
275 */
276#if PYTHON_VERSION >= 0x300
277#define PyInt_AsLong PyLong_AsLong
278#define PyInt_FromSsize_t PyLong_FromSsize_t
279
280#define PyNumber_Int PyNumber_Long
281
282#define PyObject_Unicode PyObject_Str
283
284#endif
285
286/* String handling that uses the proper version of strings for Python3 or not,
287 * which makes it easier to write portable code.
288 */
289#if PYTHON_VERSION < 0x300
290#define PyUnicode_GET_LENGTH(x) (PyUnicode_GET_SIZE(x))
291#define Nuitka_String_AsString PyString_AsString
292#define Nuitka_String_AsString_Unchecked PyString_AS_STRING
293#define Nuitka_String_Check PyString_Check
294#define Nuitka_String_CheckExact PyString_CheckExact
295NUITKA_MAY_BE_UNUSED static inline bool Nuitka_StringOrUnicode_CheckExact(PyObject *value) {
296 return PyString_CheckExact(value) || PyUnicode_CheckExact(value);
297}
298#define Nuitka_StringObject PyStringObject
299#define Nuitka_String_FromString PyString_FromString
300#define Nuitka_String_FromStringAndSize PyString_FromStringAndSize
301#define Nuitka_String_FromFormat PyString_FromFormat
302#define PyUnicode_CHECK_INTERNED (0)
303NUITKA_MAY_BE_UNUSED static Py_UNICODE *Nuitka_UnicodeAsWideString(PyObject *str, Py_ssize_t *size) {
304 PyObject *unicode;
305
306 if (!PyUnicode_Check(str)) {
307 // Leaking memory, but for usages its acceptable to
308 // achieve that the pointer remains valid.
309 unicode = PyObject_Unicode(str);
310 } else {
311 unicode = str;
312 }
313
314 if (size != NULL) {
315 *size = (Py_ssize_t)PyUnicode_GET_LENGTH(unicode);
316 }
317
318 return PyUnicode_AsUnicode(unicode);
319}
320#else
321#define Nuitka_String_AsString _PyUnicode_AsString
322
323// Note: This private stuff from file "Objects/unicodeobject.c"
324// spell-checker: ignore unicodeobject
325#define _PyUnicode_UTF8(op) (((PyCompactUnicodeObject *)(op))->utf8)
326#define PyUnicode_UTF8(op) \
327 (assert(PyUnicode_IS_READY(op)), \
328 PyUnicode_IS_COMPACT_ASCII(op) ? ((char *)((PyASCIIObject *)(op) + 1)) : _PyUnicode_UTF8(op))
329#ifdef __NUITKA_NO_ASSERT__
330#define Nuitka_String_AsString_Unchecked PyUnicode_UTF8
331#else
332NUITKA_MAY_BE_UNUSED static char const *Nuitka_String_AsString_Unchecked(PyObject *object) {
333 char const *result = PyUnicode_UTF8(object);
334 assert(result != NULL);
335 return result;
336}
337#endif
338#define Nuitka_String_Check PyUnicode_Check
339#define Nuitka_String_CheckExact PyUnicode_CheckExact
340#define Nuitka_StringOrUnicode_CheckExact PyUnicode_CheckExact
341#define Nuitka_StringObject PyUnicodeObject
342#define Nuitka_String_FromString PyUnicode_FromString
343#define Nuitka_String_FromStringAndSize PyUnicode_FromStringAndSize
344#define Nuitka_String_FromFormat PyUnicode_FromFormat
345#define Nuitka_UnicodeAsWideString PyUnicode_AsWideCharString
346#endif
347
348// Wrap the type lookup for debug mode, to identify errors, and potentially
349// to make our own enhancement later on. For now only verify it is not being
350// called with an error set, which 3.9 asserts against in core code.
351#ifdef __NUITKA_NO_ASSERT__
352#define Nuitka_TypeLookup(x, y) _PyType_Lookup(x, y)
353#else
354NUITKA_MAY_BE_UNUSED static PyObject *Nuitka_TypeLookup(PyTypeObject *type, PyObject *name) {
355 return _PyType_Lookup(type, name);
356}
357
358#endif
359
360/* With the idea to reduce the amount of exported symbols in the DLLs, make it
361 * clear that the module "init" function should of course be exported, but not
362 * for executable, where we call it ourselves from the main code.
363 */
364
365#if PYTHON_VERSION < 0x300
366#define NUITKA_MODULE_ENTRY_FUNCTION void
367#else
368#define NUITKA_MODULE_ENTRY_FUNCTION PyObject *
369#endif
370
371#if PYTHON_VERSION < 0x300
372typedef long Py_hash_t;
373#endif
374
375/* These two express if a directly called function should be exported (C level)
376 * or if it can be local to the file.
377 */
378#define NUITKA_CROSS_MODULE
379#define NUITKA_LOCAL_MODULE static
380
381/* Due to ABI issues, it seems that on Windows the symbols used by
382 * "_PyObject_GC_TRACK" were not exported before 3.8 and we need to use a
383 * function that does it instead.
384 *
385 * The Python 3.7.0 release on at Linux doesn't work this way either, was
386 * a bad CPython release apparently and between 3.7.3 and 3.7.4 these have
387 * become runtime incompatible.
388 */
389#if (defined(_WIN32) || defined(__MSYS__)) && PYTHON_VERSION < 0x380
390#define Nuitka_GC_Track PyObject_GC_Track
391#define Nuitka_GC_UnTrack PyObject_GC_UnTrack
392#undef _PyObject_GC_TRACK
393#undef _PyObject_GC_UNTRACK
394#elif PYTHON_VERSION == 0x370
395#define Nuitka_GC_Track PyObject_GC_Track
396#define Nuitka_GC_UnTrack PyObject_GC_UnTrack
397#undef _PyObject_GC_TRACK
398#undef _PyObject_GC_UNTRACK
399#elif _NUITKA_MODULE_MODE && PYTHON_VERSION >= 0x370 && PYTHON_VERSION < 0x380
400#define Nuitka_GC_Track PyObject_GC_Track
401#define Nuitka_GC_UnTrack PyObject_GC_UnTrack
402#undef _PyObject_GC_TRACK
403#undef _PyObject_GC_UNTRACK
404#undef PyThreadState_GET
405#define PyThreadState_GET PyThreadState_Get
406#else
407#define Nuitka_GC_Track _PyObject_GC_TRACK
408#define Nuitka_GC_UnTrack _PyObject_GC_UNTRACK
409#endif
410
411#if _NUITKA_EXPERIMENTAL_FAST_THREAD_GET && PYTHON_VERSION >= 0x300 && PYTHON_VERSION < 0x370
412// We are careful, access without locking under the assumption that we hold
413// the GIL over uses of this or the same thread continues to execute code of
414// ours.
415#undef PyThreadState_GET
416extern PyThreadState *_PyThreadState_Current;
417#define PyThreadState_GET() (_PyThreadState_Current)
418#endif
419
420#ifndef _NUITKA_FULL_COMPAT
421// Remove useless recursion control guards, except for testing mode, we do not
422// want them and we have no need for them as we are achieving deeper recursion
423// anyway.
424#undef Py_EnterRecursiveCall
425#define Py_EnterRecursiveCall(arg) (0)
426#undef Py_LeaveRecursiveCall
427#define Py_LeaveRecursiveCall()
428#endif
429
430#if PYTHON_VERSION < 0x300
431#define TP_RICHCOMPARE(t) (PyType_HasFeature((t), Py_TPFLAGS_HAVE_RICHCOMPARE) ? (t)->tp_richcompare : NULL)
432#else
433#define TP_RICHCOMPARE(t) ((t)->tp_richcompare)
434#endif
435
436// For older Python we need to define this ourselves.
437#ifndef Py_ABS
438#define Py_ABS(x) ((x) < 0 ? -(x) : (x))
439#endif
440
441#ifndef Py_MIN
442#define Py_MIN(x, y) (((x) > (y)) ? (y) : (x))
443#endif
444
445#ifndef Py_MAX
446#define Py_MAX(x, y) (((x) > (y)) ? (x) : (y))
447#endif
448
449#ifndef Py_SET_SIZE
450#define Py_SET_SIZE(op, size) ((PyVarObject *)(op))->ob_size = size
451#endif
452
453#ifndef PyFloat_SET_DOUBLE
454#define PyFloat_SET_DOUBLE(op, value) ((PyFloatObject *)(op))->ob_fval = value
455#endif
456
457#ifndef Py_NewRef
458static inline PyObject *_Py_NewRef(PyObject *obj) {
459 Py_INCREF(obj);
460 return obj;
461}
462
463static inline PyObject *_Py_XNewRef(PyObject *obj) {
464 Py_XINCREF(obj);
465 return obj;
466}
467
468#define Py_NewRef(obj) _Py_NewRef((PyObject *)(obj))
469#define Py_XNewRef(obj) _Py_XNewRef((PyObject *)(obj))
470#endif
471
472// For older Python, we don't have a feature "CLASS" anymore, that's implied now.
473#if PYTHON_VERSION < 0x300
474#define NuitkaType_HasFeatureClass(descr) (PyType_HasFeature(Py_TYPE(descr), Py_TPFLAGS_HAVE_CLASS))
475#else
476#define NuitkaType_HasFeatureClass(descr) (1)
477#endif
478
479// For pre-3.13, lets allow ourselves to use them as well, these do play
480// nice with no-GIL Python.
481#if PYTHON_VERSION < 0x3d0
482#define FT_ATOMIC_LOAD_PTR(value) value
483#define FT_ATOMIC_STORE_PTR(value, new_value) value = new_value
484#define FT_ATOMIC_LOAD_SSIZE(value) value
485#define FT_ATOMIC_LOAD_SSIZE_ACQUIRE(value) value
486#define FT_ATOMIC_LOAD_SSIZE_RELAXED(value) value
487#define FT_ATOMIC_STORE_PTR(value, new_value) value = new_value
488#define FT_ATOMIC_LOAD_PTR_ACQUIRE(value) value
489#define FT_ATOMIC_LOAD_UINTPTR_ACQUIRE(value) value
490#define FT_ATOMIC_LOAD_PTR_RELAXED(value) value
491#define FT_ATOMIC_LOAD_UINT8(value) value
492#define FT_ATOMIC_STORE_UINT8(value, new_value) value = new_value
493#define FT_ATOMIC_LOAD_UINT8_RELAXED(value) value
494#define FT_ATOMIC_LOAD_UINT16_RELAXED(value) value
495#define FT_ATOMIC_LOAD_UINT32_RELAXED(value) value
496#define FT_ATOMIC_LOAD_ULONG_RELAXED(value) value
497#define FT_ATOMIC_STORE_PTR_RELAXED(value, new_value) value = new_value
498#define FT_ATOMIC_STORE_PTR_RELEASE(value, new_value) value = new_value
499#define FT_ATOMIC_STORE_UINTPTR_RELEASE(value, new_value) value = new_value
500#define FT_ATOMIC_STORE_SSIZE_RELAXED(value, new_value) value = new_value
501#define FT_ATOMIC_STORE_UINT8_RELAXED(value, new_value) value = new_value
502#define FT_ATOMIC_STORE_UINT16_RELAXED(value, new_value) value = new_value
503#define FT_ATOMIC_STORE_UINT32_RELAXED(value, new_value) value = new_value
504
505#define Py_BEGIN_CRITICAL_SECTION(mut) {
506#define Py_BEGIN_CRITICAL_SECTION2(m1, m2) {
507#define Py_BEGIN_CRITICAL_SECTION_MUT(mut) {
508#define Py_BEGIN_CRITICAL_SECTION2_MUT(m1, m2) {
509#define Py_END_CRITICAL_SECTION() }
510
511#define Py_BEGIN_CRITICAL_SECTION_SEQUENCE_FAST(original) {
512#define Py_END_CRITICAL_SECTION_SEQUENCE_FAST() }
513#define _Py_CRITICAL_SECTION_ASSERT_MUTEX_LOCKED(mutex)
514#define _Py_CRITICAL_SECTION_ASSERT_OBJECT_LOCKED(op)
515
516#endif
517
518// Our replacement for "PyType_IsSubtype"
519extern bool Nuitka_Type_IsSubtype(PyTypeObject *a, PyTypeObject *b);
520
521#include "nuitka/allocator.h"
522#include "nuitka/exceptions.h"
523
524// The digit types
525#if PYTHON_VERSION < 0x300
526#include <longintrepr.h>
527
528#if PYTHON_VERSION < 0x270
529// Not present in Python2.6 yet, spell-checker: ignore sdigit
530typedef signed int sdigit;
531#endif
532#endif
533
534// A long value that represents a signed digit on the helper interface.
535typedef long nuitka_digit;
536
537#include "nuitka/helpers.h"
538
539#include "nuitka/compiled_frame.h"
540
541#include "nuitka/compiled_cell.h"
542
543#include "nuitka/compiled_function.h"
544
545/* Sentinel PyObject to be used for all our call iterator endings. */
546extern PyObject *Nuitka_sentinel_value;
547
548/* Value to use for __compiled__ value of all modules. */
549extern PyObject *Nuitka_dunder_compiled_value;
550
551#include "nuitka/compiled_generator.h"
552
553#include "nuitka/compiled_method.h"
554
555#if PYTHON_VERSION >= 0x350
556#include "nuitka/compiled_coroutine.h"
557#endif
558
559#if PYTHON_VERSION >= 0x360
560#include "nuitka/compiled_asyncgen.h"
561#endif
562
563#include "nuitka/filesystem_paths.h"
564#include "nuitka/safe_string_ops.h"
565
566#include "nuitka/jit_sources.h"
567
568#if _NUITKA_EXPERIMENTAL_WRITEABLE_CONSTANTS
569#include "nuitka_data_decoder.h"
570#else
571#define DECODE(x) assert(x)
572#define UN_TRANSLATE(x) (x)
573#endif
574
575#if _NUITKA_EXPERIMENTAL_FILE_TRACING
576#include "nuitka_file_tracer.h"
577#else
578#if PYTHON_VERSION < 0x300
579#define TRACE_FILE_OPEN(tstate, x, y, z, r) (false)
580#else
581#define TRACE_FILE_OPEN(tstate, x, y, z, a, b, c, d, e, r) (false)
582#endif
583#define TRACE_FILE_READ(tstate, x, y) (false)
584
585#define TRACE_FILE_EXISTS(tstate, x, y) (false)
586#define TRACE_FILE_ISFILE(tstate, x, y) (false)
587#define TRACE_FILE_ISDIR(tstate, x, y) (false)
588
589#define TRACE_FILE_LISTDIR(tstate, x, y) (false)
590
591#define TRACE_FILE_STAT(tstate, x, y, z, r) (false)
592
593#endif
594
595#if _NUITKA_EXPERIMENTAL_INIT_PROGRAM
596#include "nuitka_init_program.h"
597#else
598#define NUITKA_INIT_PROGRAM_EARLY(argc, argv)
599#define NUITKA_INIT_PROGRAM_LATE(module_name)
600#endif
601
602#if _NUITKA_EXPERIMENTAL_EXIT_PROGRAM
603#include "nuitka_exit_program.h"
604#else
605#define NUITKA_FINALIZE_PROGRAM(tstate)
606#endif
607
608// Only Python3.9+ has a more precise check, while making the old one slow.
609#ifndef PyCFunction_CheckExact
610#define PyCFunction_CheckExact PyCFunction_Check
611#endif
612
613#ifdef _NUITKA_EXPERIMENTAL_DUMP_C_TRACEBACKS
614extern void INIT_C_BACKTRACES(void);
615extern void DUMP_C_BACKTRACE(void);
616#endif
617
618#if _NUITKA_PLUGIN_THEMIDA_ENABLED
619#include "nuitka_themida.h"
620#endif
621
622#endif
623
624// Part of "Nuitka", an optimizing Python compiler that is compatible and
625// integrates with CPython, but also works on its own.
626//
627// Licensed under the Apache License, Version 2.0 (the "License");
628// you may not use this file except in compliance with the License.
629// You may obtain a copy of the License at
630//
631// http://www.apache.org/licenses/LICENSE-2.0
632//
633// Unless required by applicable law or agreed to in writing, software
634// distributed under the License is distributed on an "AS IS" BASIS,
635// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
636// See the License for the specific language governing permissions and
637// limitations under the License.