summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPablo Galindo <pablogsal@gmail.com>2022-01-14 21:20:56 (GMT)
committerPablo Galindo <pablogsal@gmail.com>2022-01-14 21:20:56 (GMT)
commit2402f1e1f80499a870a86d848e5228d527d9be1d (patch)
tree3c9a8c5f87659b1610c880a0cbb93872f6f7b856
parent01d4fe09763a6e55e38d338bf45e8c35e32a3581 (diff)
parentc5640ef87511c960e339af37b486678788be910a (diff)
downloadcpython-2402f1e1f80499a870a86d848e5228d527d9be1d.zip
cpython-2402f1e1f80499a870a86d848e5228d527d9be1d.tar.gz
cpython-2402f1e1f80499a870a86d848e5228d527d9be1d.tar.bz2
Merge remote-tracking branch 'upstream/main'
-rw-r--r--Doc/library/timeit.rst7
-rw-r--r--Doc/using/configure.rst3
-rw-r--r--Doc/whatsnew/3.11.rst10
-rw-r--r--Include/cpython/pystate.h42
-rw-r--r--Include/internal/pycore_ceval.h5
-rw-r--r--Include/internal/pycore_fileutils.h3
-rw-r--r--Include/internal/pycore_gc.h2
-rw-r--r--Include/internal/pycore_global_objects.h569
-rw-r--r--Include/internal/pycore_object.h13
-rw-r--r--Include/internal/pycore_runtime.h15
-rw-r--r--Include/internal/pycore_runtime_init.h630
-rw-r--r--Include/pyport.h16
-rw-r--r--Lib/ntpath.py2
-rw-r--r--Lib/test/test_embed.py28
-rw-r--r--Lib/test/test_functools.py6
-rw-r--r--Lib/test/test_ntpath.py34
-rw-r--r--Makefile.pre.in2
-rw-r--r--Misc/NEWS.d/next/Build/2022-01-09-11-24-54.bpo-45569.zCIENy.rst5
-rw-r--r--Misc/NEWS.d/next/Windows/2022-01-13-22-31-09.bpo-46362.f2cuEb.rst2
-rw-r--r--Modules/_hashopenssl.c2
-rw-r--r--Modules/_tracemalloc.c3
-rw-r--r--Modules/gcmodule.c26
-rw-r--r--Modules/getpath.c6
-rw-r--r--Modules/posixmodule.c45
-rw-r--r--PCbuild/pythoncore.vcxproj1
-rw-r--r--PCbuild/pythoncore.vcxproj.filters3
-rw-r--r--Python/ceval.c6
-rw-r--r--Python/fileutils.c37
-rw-r--r--Python/pylifecycle.c1
-rw-r--r--Python/pystate.c32
-rw-r--r--Tools/wasm/config.site-wasm32-emscripten12
-rwxr-xr-xconfigure36
-rw-r--r--configure.ac46
33 files changed, 918 insertions, 732 deletions
diff --git a/Doc/library/timeit.rst b/Doc/library/timeit.rst
index 7f1c41d..660a546 100644
--- a/Doc/library/timeit.rst
+++ b/Doc/library/timeit.rst
@@ -282,6 +282,13 @@ It is possible to provide a setup statement that is executed only once at the be
$ python -m timeit -s 'text = "sample string"; char = "g"' 'text.find(char)'
1000000 loops, best of 5: 0.342 usec per loop
+In the output, there are three fields. The loop count, which tells you how many
+times the statement body was run per timing loop repetition. The repetition
+count ('best of 5') which tells you how many times the timing loop was
+repeated, and finally the time the statement body took on average within the
+best repetition of the timing loop. That is, the time the fastest repetition
+took divided by the loop count.
+
::
>>> import timeit
diff --git a/Doc/using/configure.rst b/Doc/using/configure.rst
index 771ad3c..f1c156c 100644
--- a/Doc/using/configure.rst
+++ b/Doc/using/configure.rst
@@ -35,8 +35,7 @@ General Options
Define the size in bits of Python :class:`int` digits: 15 or 30 bits.
- By default, the number of bits is selected depending on ``sizeof(void*)``:
- 30 bits if ``void*`` size is 64-bit or larger, 15 bits otherwise.
+ By default, the digit size is 30.
Define the ``PYLONG_BITS_IN_DIGIT`` to ``15`` or ``30``.
diff --git a/Doc/whatsnew/3.11.rst b/Doc/whatsnew/3.11.rst
index 6a6c22c..96d6e26 100644
--- a/Doc/whatsnew/3.11.rst
+++ b/Doc/whatsnew/3.11.rst
@@ -622,6 +622,16 @@ Build Changes
like Pyodide.
(Contributed by Christian Heimes and Ethan Smith in :issue:`40280`.)
+* CPython will now use 30-bit digits by default for the Python :class:`int`
+ implementation. Previously, the default was to use 30-bit digits on platforms
+ with ``SIZEOF_VOID_P >= 8``, and 15-bit digits otherwise. It's still possible
+ to explicitly request use of 15-bit digits via either the
+ ``--enable-big-digits`` option to the configure script or (for Windows) the
+ ``PYLONG_BITS_IN_DIGIT`` variable in ``PC/pyconfig.h``, but this option may
+ be removed at some point in the future. (Contributed by Mark Dickinson in
+ :issue:`45569`.)
+
+
C API Changes
=============
diff --git a/Include/cpython/pystate.h b/Include/cpython/pystate.h
index bcb1bb2..a35e5b8 100644
--- a/Include/cpython/pystate.h
+++ b/Include/cpython/pystate.h
@@ -53,12 +53,19 @@ typedef struct _cframe {
} CFrame;
typedef struct _err_stackitem {
- /* This struct represents an entry on the exception stack, which is a
- * per-coroutine state. (Coroutine in the computer science sense,
- * including the thread and generators).
- * This ensures that the exception state is not impacted by "yields"
- * from an except handler.
+ /* This struct represents a single execution context where we might
+ * be currently handling an exception. It is a per-coroutine state
+ * (coroutine in the computer science sense, including the thread
+ * and generators).
+ *
+ * This is used as an entry on the exception stack, where each
+ * entry indicates if it is currently handling an exception.
+ * This ensures that the exception state is not impacted
+ * by "yields" from an except handler. The thread
+ * always has an entry (the bottom-most one).
*/
+
+ /* The exception currently being handled in this context, if any. */
PyObject *exc_value;
struct _err_stackitem *previous_item;
@@ -112,13 +119,9 @@ struct _ts {
PyObject *curexc_value;
PyObject *curexc_traceback;
- /* The exception currently being handled, if no coroutines/generators
- * are present. Always last element on the stack referred to be exc_info.
- */
- _PyErr_StackItem exc_state;
-
- /* Pointer to the top of the stack of the exceptions currently
- * being handled */
+ /* Pointer to the top of the exception stack for the exceptions
+ * we may be currently handling. (See _PyErr_StackItem above.)
+ * This is never NULL. */
_PyErr_StackItem *exc_info;
PyObject *dict; /* Stores per-thread state */
@@ -174,13 +177,26 @@ struct _ts {
/* Unique thread state id. */
uint64_t id;
- CFrame root_cframe;
PyTraceInfo trace_info;
_PyStackChunk *datastack_chunk;
PyObject **datastack_top;
PyObject **datastack_limit;
/* XXX signal handlers should also be here */
+
+ /* The following fields are here to avoid allocation during init.
+ The data is exposed through PyThreadState pointer fields.
+ These fields should not be accessed directly outside of init.
+
+ All other PyInterpreterState pointer fields are populated when
+ needed and default to NULL.
+ */
+
+ /* The thread's exception stack entry. (Always the last entry.) */
+ _PyErr_StackItem _exc_state;
+
+ /* The bottom-most frame on the stack. */
+ CFrame _root_cframe;
};
diff --git a/Include/internal/pycore_ceval.h b/Include/internal/pycore_ceval.h
index 20508d4..53d0b5c 100644
--- a/Include/internal/pycore_ceval.h
+++ b/Include/internal/pycore_ceval.h
@@ -12,9 +12,14 @@ extern "C" {
struct pyruntimestate;
struct _ceval_runtime_state;
+#ifndef Py_DEFAULT_RECURSION_LIMIT
+# define Py_DEFAULT_RECURSION_LIMIT 1000
+#endif
+
#include "pycore_interp.h" // PyInterpreterState.eval_frame
#include "pycore_pystate.h" // _PyThreadState_GET()
+
extern void _Py_FinishPendingCalls(PyThreadState *tstate);
extern void _PyEval_InitRuntimeState(struct _ceval_runtime_state *);
extern void _PyEval_InitState(struct _ceval_state *, PyThread_type_lock);
diff --git a/Include/internal/pycore_fileutils.h b/Include/internal/pycore_fileutils.h
index 61c11a8..3ce8108 100644
--- a/Include/internal/pycore_fileutils.h
+++ b/Include/internal/pycore_fileutils.h
@@ -235,6 +235,9 @@ extern int _Py_EncodeNonUnicodeWchar_InPlace(
extern int _Py_isabs(const wchar_t *path);
extern int _Py_abspath(const wchar_t *path, wchar_t **abspath_p);
+#ifdef MS_WINDOWS
+extern int _PyOS_getfullpathname(const wchar_t *path, wchar_t **abspath_p);
+#endif
extern wchar_t * _Py_join_relfile(const wchar_t *dirname,
const wchar_t *relfile);
extern int _Py_add_relfile(wchar_t *dirname,
diff --git a/Include/internal/pycore_gc.h b/Include/internal/pycore_gc.h
index a23dca8..56a23e9 100644
--- a/Include/internal/pycore_gc.h
+++ b/Include/internal/pycore_gc.h
@@ -134,6 +134,7 @@ struct _gc_runtime_state {
/* Current call-stack depth of tp_dealloc calls. */
int trash_delete_nesting;
+ /* Is automatic collection enabled? */
int enabled;
int debug;
/* linked lists of container objects */
@@ -161,6 +162,7 @@ struct _gc_runtime_state {
Py_ssize_t long_lived_pending;
};
+
extern void _PyGC_InitState(struct _gc_runtime_state *);
extern Py_ssize_t _PyGC_CollectNoFail(PyThreadState *tstate);
diff --git a/Include/internal/pycore_global_objects.h b/Include/internal/pycore_global_objects.h
index de7ab9b..acf0b2a 100644
--- a/Include/internal/pycore_global_objects.h
+++ b/Include/internal/pycore_global_objects.h
@@ -9,48 +9,10 @@ extern "C" {
#endif
-#define _PyObject_IMMORTAL_INIT(type) \
- { \
- .ob_refcnt = 999999999, \
- .ob_type = type, \
- }
-#define _PyVarObject_IMMORTAL_INIT(type, size) \
- { \
- .ob_base = _PyObject_IMMORTAL_INIT(type), \
- .ob_size = size, \
- }
-
-
-/* int objects */
-
+// These would be in pycore_long.h if it weren't for an include cycle.
#define _PY_NSMALLPOSINTS 257
#define _PY_NSMALLNEGINTS 5
-#define _PyLong_DIGIT_INIT(val) \
- { \
- _PyVarObject_IMMORTAL_INIT(&PyLong_Type, \
- ((val) == 0 ? 0 : ((val) > 0 ? 1 : -1))), \
- .ob_digit = { ((val) >= 0 ? (val) : -(val)) }, \
- }
-
-
-/* bytes objects */
-
-#define _PyBytes_SIMPLE_INIT(CH, LEN) \
- { \
- _PyVarObject_IMMORTAL_INIT(&PyBytes_Type, LEN), \
- .ob_shash = -1, \
- .ob_sval = { CH }, \
- }
-#define _PyBytes_CHAR_INIT(CH) \
- { \
- _PyBytes_SIMPLE_INIT(CH, 1) \
- }
-
-
-/**********************
- * the global objects *
- **********************/
// Only immutable objects should be considered runtime-global.
// All others must be per-interpreter.
@@ -77,535 +39,6 @@ struct _Py_global_objects {
} singletons;
};
-#define _Py_global_objects_INIT { \
- .singletons = { \
- .small_ints = { \
- _PyLong_DIGIT_INIT(-5), \
- _PyLong_DIGIT_INIT(-4), \
- _PyLong_DIGIT_INIT(-3), \
- _PyLong_DIGIT_INIT(-2), \
- _PyLong_DIGIT_INIT(-1), \
- _PyLong_DIGIT_INIT(0), \
- _PyLong_DIGIT_INIT(1), \
- _PyLong_DIGIT_INIT(2), \
- _PyLong_DIGIT_INIT(3), \
- _PyLong_DIGIT_INIT(4), \
- _PyLong_DIGIT_INIT(5), \
- _PyLong_DIGIT_INIT(6), \
- _PyLong_DIGIT_INIT(7), \
- _PyLong_DIGIT_INIT(8), \
- _PyLong_DIGIT_INIT(9), \
- _PyLong_DIGIT_INIT(10), \
- _PyLong_DIGIT_INIT(11), \
- _PyLong_DIGIT_INIT(12), \
- _PyLong_DIGIT_INIT(13), \
- _PyLong_DIGIT_INIT(14), \
- _PyLong_DIGIT_INIT(15), \
- _PyLong_DIGIT_INIT(16), \
- _PyLong_DIGIT_INIT(17), \
- _PyLong_DIGIT_INIT(18), \
- _PyLong_DIGIT_INIT(19), \
- _PyLong_DIGIT_INIT(20), \
- _PyLong_DIGIT_INIT(21), \
- _PyLong_DIGIT_INIT(22), \
- _PyLong_DIGIT_INIT(23), \
- _PyLong_DIGIT_INIT(24), \
- _PyLong_DIGIT_INIT(25), \
- _PyLong_DIGIT_INIT(26), \
- _PyLong_DIGIT_INIT(27), \
- _PyLong_DIGIT_INIT(28), \
- _PyLong_DIGIT_INIT(29), \
- _PyLong_DIGIT_INIT(30), \
- _PyLong_DIGIT_INIT(31), \
- _PyLong_DIGIT_INIT(32), \
- _PyLong_DIGIT_INIT(33), \
- _PyLong_DIGIT_INIT(34), \
- _PyLong_DIGIT_INIT(35), \
- _PyLong_DIGIT_INIT(36), \
- _PyLong_DIGIT_INIT(37), \
- _PyLong_DIGIT_INIT(38), \
- _PyLong_DIGIT_INIT(39), \
- _PyLong_DIGIT_INIT(40), \
- _PyLong_DIGIT_INIT(41), \
- _PyLong_DIGIT_INIT(42), \
- _PyLong_DIGIT_INIT(43), \
- _PyLong_DIGIT_INIT(44), \
- _PyLong_DIGIT_INIT(45), \
- _PyLong_DIGIT_INIT(46), \
- _PyLong_DIGIT_INIT(47), \
- _PyLong_DIGIT_INIT(48), \
- _PyLong_DIGIT_INIT(49), \
- _PyLong_DIGIT_INIT(50), \
- _PyLong_DIGIT_INIT(51), \
- _PyLong_DIGIT_INIT(52), \
- _PyLong_DIGIT_INIT(53), \
- _PyLong_DIGIT_INIT(54), \
- _PyLong_DIGIT_INIT(55), \
- _PyLong_DIGIT_INIT(56), \
- _PyLong_DIGIT_INIT(57), \
- _PyLong_DIGIT_INIT(58), \
- _PyLong_DIGIT_INIT(59), \
- _PyLong_DIGIT_INIT(60), \
- _PyLong_DIGIT_INIT(61), \
- _PyLong_DIGIT_INIT(62), \
- _PyLong_DIGIT_INIT(63), \
- _PyLong_DIGIT_INIT(64), \
- _PyLong_DIGIT_INIT(65), \
- _PyLong_DIGIT_INIT(66), \
- _PyLong_DIGIT_INIT(67), \
- _PyLong_DIGIT_INIT(68), \
- _PyLong_DIGIT_INIT(69), \
- _PyLong_DIGIT_INIT(70), \
- _PyLong_DIGIT_INIT(71), \
- _PyLong_DIGIT_INIT(72), \
- _PyLong_DIGIT_INIT(73), \
- _PyLong_DIGIT_INIT(74), \
- _PyLong_DIGIT_INIT(75), \
- _PyLong_DIGIT_INIT(76), \
- _PyLong_DIGIT_INIT(77), \
- _PyLong_DIGIT_INIT(78), \
- _PyLong_DIGIT_INIT(79), \
- _PyLong_DIGIT_INIT(80), \
- _PyLong_DIGIT_INIT(81), \
- _PyLong_DIGIT_INIT(82), \
- _PyLong_DIGIT_INIT(83), \
- _PyLong_DIGIT_INIT(84), \
- _PyLong_DIGIT_INIT(85), \
- _PyLong_DIGIT_INIT(86), \
- _PyLong_DIGIT_INIT(87), \
- _PyLong_DIGIT_INIT(88), \
- _PyLong_DIGIT_INIT(89), \
- _PyLong_DIGIT_INIT(90), \
- _PyLong_DIGIT_INIT(91), \
- _PyLong_DIGIT_INIT(92), \
- _PyLong_DIGIT_INIT(93), \
- _PyLong_DIGIT_INIT(94), \
- _PyLong_DIGIT_INIT(95), \
- _PyLong_DIGIT_INIT(96), \
- _PyLong_DIGIT_INIT(97), \
- _PyLong_DIGIT_INIT(98), \
- _PyLong_DIGIT_INIT(99), \
- _PyLong_DIGIT_INIT(100), \
- _PyLong_DIGIT_INIT(101), \
- _PyLong_DIGIT_INIT(102), \
- _PyLong_DIGIT_INIT(103), \
- _PyLong_DIGIT_INIT(104), \
- _PyLong_DIGIT_INIT(105), \
- _PyLong_DIGIT_INIT(106), \
- _PyLong_DIGIT_INIT(107), \
- _PyLong_DIGIT_INIT(108), \
- _PyLong_DIGIT_INIT(109), \
- _PyLong_DIGIT_INIT(110), \
- _PyLong_DIGIT_INIT(111), \
- _PyLong_DIGIT_INIT(112), \
- _PyLong_DIGIT_INIT(113), \
- _PyLong_DIGIT_INIT(114), \
- _PyLong_DIGIT_INIT(115), \
- _PyLong_DIGIT_INIT(116), \
- _PyLong_DIGIT_INIT(117), \
- _PyLong_DIGIT_INIT(118), \
- _PyLong_DIGIT_INIT(119), \
- _PyLong_DIGIT_INIT(120), \
- _PyLong_DIGIT_INIT(121), \
- _PyLong_DIGIT_INIT(122), \
- _PyLong_DIGIT_INIT(123), \
- _PyLong_DIGIT_INIT(124), \
- _PyLong_DIGIT_INIT(125), \
- _PyLong_DIGIT_INIT(126), \
- _PyLong_DIGIT_INIT(127), \
- _PyLong_DIGIT_INIT(128), \
- _PyLong_DIGIT_INIT(129), \
- _PyLong_DIGIT_INIT(130), \
- _PyLong_DIGIT_INIT(131), \
- _PyLong_DIGIT_INIT(132), \
- _PyLong_DIGIT_INIT(133), \
- _PyLong_DIGIT_INIT(134), \
- _PyLong_DIGIT_INIT(135), \
- _PyLong_DIGIT_INIT(136), \
- _PyLong_DIGIT_INIT(137), \
- _PyLong_DIGIT_INIT(138), \
- _PyLong_DIGIT_INIT(139), \
- _PyLong_DIGIT_INIT(140), \
- _PyLong_DIGIT_INIT(141), \
- _PyLong_DIGIT_INIT(142), \
- _PyLong_DIGIT_INIT(143), \
- _PyLong_DIGIT_INIT(144), \
- _PyLong_DIGIT_INIT(145), \
- _PyLong_DIGIT_INIT(146), \
- _PyLong_DIGIT_INIT(147), \
- _PyLong_DIGIT_INIT(148), \
- _PyLong_DIGIT_INIT(149), \
- _PyLong_DIGIT_INIT(150), \
- _PyLong_DIGIT_INIT(151), \
- _PyLong_DIGIT_INIT(152), \
- _PyLong_DIGIT_INIT(153), \
- _PyLong_DIGIT_INIT(154), \
- _PyLong_DIGIT_INIT(155), \
- _PyLong_DIGIT_INIT(156), \
- _PyLong_DIGIT_INIT(157), \
- _PyLong_DIGIT_INIT(158), \
- _PyLong_DIGIT_INIT(159), \
- _PyLong_DIGIT_INIT(160), \
- _PyLong_DIGIT_INIT(161), \
- _PyLong_DIGIT_INIT(162), \
- _PyLong_DIGIT_INIT(163), \
- _PyLong_DIGIT_INIT(164), \
- _PyLong_DIGIT_INIT(165), \
- _PyLong_DIGIT_INIT(166), \
- _PyLong_DIGIT_INIT(167), \
- _PyLong_DIGIT_INIT(168), \
- _PyLong_DIGIT_INIT(169), \
- _PyLong_DIGIT_INIT(170), \
- _PyLong_DIGIT_INIT(171), \
- _PyLong_DIGIT_INIT(172), \
- _PyLong_DIGIT_INIT(173), \
- _PyLong_DIGIT_INIT(174), \
- _PyLong_DIGIT_INIT(175), \
- _PyLong_DIGIT_INIT(176), \
- _PyLong_DIGIT_INIT(177), \
- _PyLong_DIGIT_INIT(178), \
- _PyLong_DIGIT_INIT(179), \
- _PyLong_DIGIT_INIT(180), \
- _PyLong_DIGIT_INIT(181), \
- _PyLong_DIGIT_INIT(182), \
- _PyLong_DIGIT_INIT(183), \
- _PyLong_DIGIT_INIT(184), \
- _PyLong_DIGIT_INIT(185), \
- _PyLong_DIGIT_INIT(186), \
- _PyLong_DIGIT_INIT(187), \
- _PyLong_DIGIT_INIT(188), \
- _PyLong_DIGIT_INIT(189), \
- _PyLong_DIGIT_INIT(190), \
- _PyLong_DIGIT_INIT(191), \
- _PyLong_DIGIT_INIT(192), \
- _PyLong_DIGIT_INIT(193), \
- _PyLong_DIGIT_INIT(194), \
- _PyLong_DIGIT_INIT(195), \
- _PyLong_DIGIT_INIT(196), \
- _PyLong_DIGIT_INIT(197), \
- _PyLong_DIGIT_INIT(198), \
- _PyLong_DIGIT_INIT(199), \
- _PyLong_DIGIT_INIT(200), \
- _PyLong_DIGIT_INIT(201), \
- _PyLong_DIGIT_INIT(202), \
- _PyLong_DIGIT_INIT(203), \
- _PyLong_DIGIT_INIT(204), \
- _PyLong_DIGIT_INIT(205), \
- _PyLong_DIGIT_INIT(206), \
- _PyLong_DIGIT_INIT(207), \
- _PyLong_DIGIT_INIT(208), \
- _PyLong_DIGIT_INIT(209), \
- _PyLong_DIGIT_INIT(210), \
- _PyLong_DIGIT_INIT(211), \
- _PyLong_DIGIT_INIT(212), \
- _PyLong_DIGIT_INIT(213), \
- _PyLong_DIGIT_INIT(214), \
- _PyLong_DIGIT_INIT(215), \
- _PyLong_DIGIT_INIT(216), \
- _PyLong_DIGIT_INIT(217), \
- _PyLong_DIGIT_INIT(218), \
- _PyLong_DIGIT_INIT(219), \
- _PyLong_DIGIT_INIT(220), \
- _PyLong_DIGIT_INIT(221), \
- _PyLong_DIGIT_INIT(222), \
- _PyLong_DIGIT_INIT(223), \
- _PyLong_DIGIT_INIT(224), \
- _PyLong_DIGIT_INIT(225), \
- _PyLong_DIGIT_INIT(226), \
- _PyLong_DIGIT_INIT(227), \
- _PyLong_DIGIT_INIT(228), \
- _PyLong_DIGIT_INIT(229), \
- _PyLong_DIGIT_INIT(230), \
- _PyLong_DIGIT_INIT(231), \
- _PyLong_DIGIT_INIT(232), \
- _PyLong_DIGIT_INIT(233), \
- _PyLong_DIGIT_INIT(234), \
- _PyLong_DIGIT_INIT(235), \
- _PyLong_DIGIT_INIT(236), \
- _PyLong_DIGIT_INIT(237), \
- _PyLong_DIGIT_INIT(238), \
- _PyLong_DIGIT_INIT(239), \
- _PyLong_DIGIT_INIT(240), \
- _PyLong_DIGIT_INIT(241), \
- _PyLong_DIGIT_INIT(242), \
- _PyLong_DIGIT_INIT(243), \
- _PyLong_DIGIT_INIT(244), \
- _PyLong_DIGIT_INIT(245), \
- _PyLong_DIGIT_INIT(246), \
- _PyLong_DIGIT_INIT(247), \
- _PyLong_DIGIT_INIT(248), \
- _PyLong_DIGIT_INIT(249), \
- _PyLong_DIGIT_INIT(250), \
- _PyLong_DIGIT_INIT(251), \
- _PyLong_DIGIT_INIT(252), \
- _PyLong_DIGIT_INIT(253), \
- _PyLong_DIGIT_INIT(254), \
- _PyLong_DIGIT_INIT(255), \
- _PyLong_DIGIT_INIT(256), \
- }, \
- \
- .bytes_empty = _PyBytes_SIMPLE_INIT(0, 0), \
- .bytes_characters = { \
- _PyBytes_CHAR_INIT(0), \
- _PyBytes_CHAR_INIT(1), \
- _PyBytes_CHAR_INIT(2), \
- _PyBytes_CHAR_INIT(3), \
- _PyBytes_CHAR_INIT(4), \
- _PyBytes_CHAR_INIT(5), \
- _PyBytes_CHAR_INIT(6), \
- _PyBytes_CHAR_INIT(7), \
- _PyBytes_CHAR_INIT(8), \
- _PyBytes_CHAR_INIT(9), \
- _PyBytes_CHAR_INIT(10), \
- _PyBytes_CHAR_INIT(11), \
- _PyBytes_CHAR_INIT(12), \
- _PyBytes_CHAR_INIT(13), \
- _PyBytes_CHAR_INIT(14), \
- _PyBytes_CHAR_INIT(15), \
- _PyBytes_CHAR_INIT(16), \
- _PyBytes_CHAR_INIT(17), \
- _PyBytes_CHAR_INIT(18), \
- _PyBytes_CHAR_INIT(19), \
- _PyBytes_CHAR_INIT(20), \
- _PyBytes_CHAR_INIT(21), \
- _PyBytes_CHAR_INIT(22), \
- _PyBytes_CHAR_INIT(23), \
- _PyBytes_CHAR_INIT(24), \
- _PyBytes_CHAR_INIT(25), \
- _PyBytes_CHAR_INIT(26), \
- _PyBytes_CHAR_INIT(27), \
- _PyBytes_CHAR_INIT(28), \
- _PyBytes_CHAR_INIT(29), \
- _PyBytes_CHAR_INIT(30), \
- _PyBytes_CHAR_INIT(31), \
- _PyBytes_CHAR_INIT(32), \
- _PyBytes_CHAR_INIT(33), \
- _PyBytes_CHAR_INIT(34), \
- _PyBytes_CHAR_INIT(35), \
- _PyBytes_CHAR_INIT(36), \
- _PyBytes_CHAR_INIT(37), \
- _PyBytes_CHAR_INIT(38), \
- _PyBytes_CHAR_INIT(39), \
- _PyBytes_CHAR_INIT(40), \
- _PyBytes_CHAR_INIT(41), \
- _PyBytes_CHAR_INIT(42), \
- _PyBytes_CHAR_INIT(43), \
- _PyBytes_CHAR_INIT(44), \
- _PyBytes_CHAR_INIT(45), \
- _PyBytes_CHAR_INIT(46), \
- _PyBytes_CHAR_INIT(47), \
- _PyBytes_CHAR_INIT(48), \
- _PyBytes_CHAR_INIT(49), \
- _PyBytes_CHAR_INIT(50), \
- _PyBytes_CHAR_INIT(51), \
- _PyBytes_CHAR_INIT(52), \
- _PyBytes_CHAR_INIT(53), \
- _PyBytes_CHAR_INIT(54), \
- _PyBytes_CHAR_INIT(55), \
- _PyBytes_CHAR_INIT(56), \
- _PyBytes_CHAR_INIT(57), \
- _PyBytes_CHAR_INIT(58), \
- _PyBytes_CHAR_INIT(59), \
- _PyBytes_CHAR_INIT(60), \
- _PyBytes_CHAR_INIT(61), \
- _PyBytes_CHAR_INIT(62), \
- _PyBytes_CHAR_INIT(63), \
- _PyBytes_CHAR_INIT(64), \
- _PyBytes_CHAR_INIT(65), \
- _PyBytes_CHAR_INIT(66), \
- _PyBytes_CHAR_INIT(67), \
- _PyBytes_CHAR_INIT(68), \
- _PyBytes_CHAR_INIT(69), \
- _PyBytes_CHAR_INIT(70), \
- _PyBytes_CHAR_INIT(71), \
- _PyBytes_CHAR_INIT(72), \
- _PyBytes_CHAR_INIT(73), \
- _PyBytes_CHAR_INIT(74), \
- _PyBytes_CHAR_INIT(75), \
- _PyBytes_CHAR_INIT(76), \
- _PyBytes_CHAR_INIT(77), \
- _PyBytes_CHAR_INIT(78), \
- _PyBytes_CHAR_INIT(79), \
- _PyBytes_CHAR_INIT(80), \
- _PyBytes_CHAR_INIT(81), \
- _PyBytes_CHAR_INIT(82), \
- _PyBytes_CHAR_INIT(83), \
- _PyBytes_CHAR_INIT(84), \
- _PyBytes_CHAR_INIT(85), \
- _PyBytes_CHAR_INIT(86), \
- _PyBytes_CHAR_INIT(87), \
- _PyBytes_CHAR_INIT(88), \
- _PyBytes_CHAR_INIT(89), \
- _PyBytes_CHAR_INIT(90), \
- _PyBytes_CHAR_INIT(91), \
- _PyBytes_CHAR_INIT(92), \
- _PyBytes_CHAR_INIT(93), \
- _PyBytes_CHAR_INIT(94), \
- _PyBytes_CHAR_INIT(95), \
- _PyBytes_CHAR_INIT(96), \
- _PyBytes_CHAR_INIT(97), \
- _PyBytes_CHAR_INIT(98), \
- _PyBytes_CHAR_INIT(99), \
- _PyBytes_CHAR_INIT(100), \
- _PyBytes_CHAR_INIT(101), \
- _PyBytes_CHAR_INIT(102), \
- _PyBytes_CHAR_INIT(103), \
- _PyBytes_CHAR_INIT(104), \
- _PyBytes_CHAR_INIT(105), \
- _PyBytes_CHAR_INIT(106), \
- _PyBytes_CHAR_INIT(107), \
- _PyBytes_CHAR_INIT(108), \
- _PyBytes_CHAR_INIT(109), \
- _PyBytes_CHAR_INIT(110), \
- _PyBytes_CHAR_INIT(111), \
- _PyBytes_CHAR_INIT(112), \
- _PyBytes_CHAR_INIT(113), \
- _PyBytes_CHAR_INIT(114), \
- _PyBytes_CHAR_INIT(115), \
- _PyBytes_CHAR_INIT(116), \
- _PyBytes_CHAR_INIT(117), \
- _PyBytes_CHAR_INIT(118), \
- _PyBytes_CHAR_INIT(119), \
- _PyBytes_CHAR_INIT(120), \
- _PyBytes_CHAR_INIT(121), \
- _PyBytes_CHAR_INIT(122), \
- _PyBytes_CHAR_INIT(123), \
- _PyBytes_CHAR_INIT(124), \
- _PyBytes_CHAR_INIT(125), \
- _PyBytes_CHAR_INIT(126), \
- _PyBytes_CHAR_INIT(127), \
- _PyBytes_CHAR_INIT(128), \
- _PyBytes_CHAR_INIT(129), \
- _PyBytes_CHAR_INIT(130), \
- _PyBytes_CHAR_INIT(131), \
- _PyBytes_CHAR_INIT(132), \
- _PyBytes_CHAR_INIT(133), \
- _PyBytes_CHAR_INIT(134), \
- _PyBytes_CHAR_INIT(135), \
- _PyBytes_CHAR_INIT(136), \
- _PyBytes_CHAR_INIT(137), \
- _PyBytes_CHAR_INIT(138), \
- _PyBytes_CHAR_INIT(139), \
- _PyBytes_CHAR_INIT(140), \
- _PyBytes_CHAR_INIT(141), \
- _PyBytes_CHAR_INIT(142), \
- _PyBytes_CHAR_INIT(143), \
- _PyBytes_CHAR_INIT(144), \
- _PyBytes_CHAR_INIT(145), \
- _PyBytes_CHAR_INIT(146), \
- _PyBytes_CHAR_INIT(147), \
- _PyBytes_CHAR_INIT(148), \
- _PyBytes_CHAR_INIT(149), \
- _PyBytes_CHAR_INIT(150), \
- _PyBytes_CHAR_INIT(151), \
- _PyBytes_CHAR_INIT(152), \
- _PyBytes_CHAR_INIT(153), \
- _PyBytes_CHAR_INIT(154), \
- _PyBytes_CHAR_INIT(155), \
- _PyBytes_CHAR_INIT(156), \
- _PyBytes_CHAR_INIT(157), \
- _PyBytes_CHAR_INIT(158), \
- _PyBytes_CHAR_INIT(159), \
- _PyBytes_CHAR_INIT(160), \
- _PyBytes_CHAR_INIT(161), \
- _PyBytes_CHAR_INIT(162), \
- _PyBytes_CHAR_INIT(163), \
- _PyBytes_CHAR_INIT(164), \
- _PyBytes_CHAR_INIT(165), \
- _PyBytes_CHAR_INIT(166), \
- _PyBytes_CHAR_INIT(167), \
- _PyBytes_CHAR_INIT(168), \
- _PyBytes_CHAR_INIT(169), \
- _PyBytes_CHAR_INIT(170), \
- _PyBytes_CHAR_INIT(171), \
- _PyBytes_CHAR_INIT(172), \
- _PyBytes_CHAR_INIT(173), \
- _PyBytes_CHAR_INIT(174), \
- _PyBytes_CHAR_INIT(175), \
- _PyBytes_CHAR_INIT(176), \
- _PyBytes_CHAR_INIT(177), \
- _PyBytes_CHAR_INIT(178), \
- _PyBytes_CHAR_INIT(179), \
- _PyBytes_CHAR_INIT(180), \
- _PyBytes_CHAR_INIT(181), \
- _PyBytes_CHAR_INIT(182), \
- _PyBytes_CHAR_INIT(183), \
- _PyBytes_CHAR_INIT(184), \
- _PyBytes_CHAR_INIT(185), \
- _PyBytes_CHAR_INIT(186), \
- _PyBytes_CHAR_INIT(187), \
- _PyBytes_CHAR_INIT(188), \
- _PyBytes_CHAR_INIT(189), \
- _PyBytes_CHAR_INIT(190), \
- _PyBytes_CHAR_INIT(191), \
- _PyBytes_CHAR_INIT(192), \
- _PyBytes_CHAR_INIT(193), \
- _PyBytes_CHAR_INIT(194), \
- _PyBytes_CHAR_INIT(195), \
- _PyBytes_CHAR_INIT(196), \
- _PyBytes_CHAR_INIT(197), \
- _PyBytes_CHAR_INIT(198), \
- _PyBytes_CHAR_INIT(199), \
- _PyBytes_CHAR_INIT(200), \
- _PyBytes_CHAR_INIT(201), \
- _PyBytes_CHAR_INIT(202), \
- _PyBytes_CHAR_INIT(203), \
- _PyBytes_CHAR_INIT(204), \
- _PyBytes_CHAR_INIT(205), \
- _PyBytes_CHAR_INIT(206), \
- _PyBytes_CHAR_INIT(207), \
- _PyBytes_CHAR_INIT(208), \
- _PyBytes_CHAR_INIT(209), \
- _PyBytes_CHAR_INIT(210), \
- _PyBytes_CHAR_INIT(211), \
- _PyBytes_CHAR_INIT(212), \
- _PyBytes_CHAR_INIT(213), \
- _PyBytes_CHAR_INIT(214), \
- _PyBytes_CHAR_INIT(215), \
- _PyBytes_CHAR_INIT(216), \
- _PyBytes_CHAR_INIT(217), \
- _PyBytes_CHAR_INIT(218), \
- _PyBytes_CHAR_INIT(219), \
- _PyBytes_CHAR_INIT(220), \
- _PyBytes_CHAR_INIT(221), \
- _PyBytes_CHAR_INIT(222), \
- _PyBytes_CHAR_INIT(223), \
- _PyBytes_CHAR_INIT(224), \
- _PyBytes_CHAR_INIT(225), \
- _PyBytes_CHAR_INIT(226), \
- _PyBytes_CHAR_INIT(227), \
- _PyBytes_CHAR_INIT(228), \
- _PyBytes_CHAR_INIT(229), \
- _PyBytes_CHAR_INIT(230), \
- _PyBytes_CHAR_INIT(231), \
- _PyBytes_CHAR_INIT(232), \
- _PyBytes_CHAR_INIT(233), \
- _PyBytes_CHAR_INIT(234), \
- _PyBytes_CHAR_INIT(235), \
- _PyBytes_CHAR_INIT(236), \
- _PyBytes_CHAR_INIT(237), \
- _PyBytes_CHAR_INIT(238), \
- _PyBytes_CHAR_INIT(239), \
- _PyBytes_CHAR_INIT(240), \
- _PyBytes_CHAR_INIT(241), \
- _PyBytes_CHAR_INIT(242), \
- _PyBytes_CHAR_INIT(243), \
- _PyBytes_CHAR_INIT(244), \
- _PyBytes_CHAR_INIT(245), \
- _PyBytes_CHAR_INIT(246), \
- _PyBytes_CHAR_INIT(247), \
- _PyBytes_CHAR_INIT(248), \
- _PyBytes_CHAR_INIT(249), \
- _PyBytes_CHAR_INIT(250), \
- _PyBytes_CHAR_INIT(251), \
- _PyBytes_CHAR_INIT(252), \
- _PyBytes_CHAR_INIT(253), \
- _PyBytes_CHAR_INIT(254), \
- _PyBytes_CHAR_INIT(255), \
- }, \
- }, \
-}
-
#ifdef __cplusplus
}
diff --git a/Include/internal/pycore_object.h b/Include/internal/pycore_object.h
index 9041a4d..0348563 100644
--- a/Include/internal/pycore_object.h
+++ b/Include/internal/pycore_object.h
@@ -12,6 +12,19 @@ extern "C" {
#include "pycore_interp.h" // PyInterpreterState.gc
#include "pycore_pystate.h" // _PyInterpreterState_GET()
+
+#define _PyObject_IMMORTAL_INIT(type) \
+ { \
+ .ob_refcnt = 999999999, \
+ .ob_type = type, \
+ }
+#define _PyVarObject_IMMORTAL_INIT(type, size) \
+ { \
+ .ob_base = _PyObject_IMMORTAL_INIT(type), \
+ .ob_size = size, \
+ }
+
+
PyAPI_FUNC(int) _PyType_CheckConsistency(PyTypeObject *type);
PyAPI_FUNC(int) _PyDict_CheckConsistency(PyObject *mp, int check_content);
diff --git a/Include/internal/pycore_runtime.h b/Include/internal/pycore_runtime.h
index a66a3cf..038e6f8 100644
--- a/Include/internal/pycore_runtime.h
+++ b/Include/internal/pycore_runtime.h
@@ -148,21 +148,6 @@ typedef struct pyruntimestate {
PyInterpreterState _main_interpreter;
} _PyRuntimeState;
-#define _PyThreadState_INIT \
- { \
- ._static = 1, \
- }
-#define _PyInterpreterState_INIT \
- { \
- ._static = 1, \
- ._initial_thread = _PyThreadState_INIT, \
- }
-#define _PyRuntimeState_INIT \
- { \
- .global_objects = _Py_global_objects_INIT, \
- ._main_interpreter = _PyInterpreterState_INIT, \
- }
-
/* other API */
diff --git a/Include/internal/pycore_runtime_init.h b/Include/internal/pycore_runtime_init.h
new file mode 100644
index 0000000..72ca346
--- /dev/null
+++ b/Include/internal/pycore_runtime_init.h
@@ -0,0 +1,630 @@
+#ifndef Py_INTERNAL_RUNTIME_INIT_H
+#define Py_INTERNAL_RUNTIME_INIT_H
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#ifndef Py_BUILD_CORE
+# error "this header requires Py_BUILD_CORE define"
+#endif
+
+#include "pycore_object.h"
+
+
+/* The static initializers defined here should only be used
+ in the runtime init code (in pystate.c and pylifecycle.c). */
+
+
+#define _PyRuntimeState_INIT \
+ { \
+ .gilstate = { \
+ .check_enabled = 1, \
+ /* A TSS key must be initialized with Py_tss_NEEDS_INIT \
+ in accordance with the specification. */ \
+ .autoTSSkey = Py_tss_NEEDS_INIT, \
+ }, \
+ .interpreters = { \
+ /* This prevents interpreters from getting created \
+ until _PyInterpreterState_Enable() is called. */ \
+ .next_id = -1, \
+ }, \
+ .global_objects = _Py_global_objects_INIT, \
+ ._main_interpreter = _PyInterpreterState_INIT, \
+ }
+
+#ifdef HAVE_DLOPEN
+# include <dlfcn.h>
+# if HAVE_DECL_RTLD_NOW
+# define _Py_DLOPEN_FLAGS RTLD_NOW
+# else
+# define _Py_DLOPEN_FLAGS RTLD_LAZY
+# endif
+# define DLOPENFLAGS_INIT .dlopenflags = _Py_DLOPEN_FLAGS,
+#else
+# define _Py_DLOPEN_FLAGS 0
+# define DLOPENFLAGS_INIT
+#endif
+
+#define _PyInterpreterState_INIT \
+ { \
+ ._static = 1, \
+ .id_refcount = -1, \
+ DLOPENFLAGS_INIT \
+ .ceval = { \
+ .recursion_limit = Py_DEFAULT_RECURSION_LIMIT, \
+ }, \
+ .gc = { \
+ .enabled = 1, \
+ .generations = { \
+ /* .head is set in _PyGC_InitState(). */ \
+ { .threshold = 700, }, \
+ { .threshold = 10, }, \
+ { .threshold = 10, }, \
+ }, \
+ }, \
+ ._initial_thread = _PyThreadState_INIT, \
+ }
+
+#define _PyThreadState_INIT \
+ { \
+ ._static = 1, \
+ .recursion_limit = Py_DEFAULT_RECURSION_LIMIT, \
+ .context_ver = 1, \
+ }
+
+
+// global objects
+
+#define _PyLong_DIGIT_INIT(val) \
+ { \
+ _PyVarObject_IMMORTAL_INIT(&PyLong_Type, \
+ ((val) == 0 ? 0 : ((val) > 0 ? 1 : -1))), \
+ .ob_digit = { ((val) >= 0 ? (val) : -(val)) }, \
+ }
+
+
+#define _PyBytes_SIMPLE_INIT(CH, LEN) \
+ { \
+ _PyVarObject_IMMORTAL_INIT(&PyBytes_Type, LEN), \
+ .ob_shash = -1, \
+ .ob_sval = { CH }, \
+ }
+#define _PyBytes_CHAR_INIT(CH) \
+ { \
+ _PyBytes_SIMPLE_INIT(CH, 1) \
+ }
+
+#define _Py_global_objects_INIT { \
+ .singletons = { \
+ .small_ints = { \
+ _PyLong_DIGIT_INIT(-5), \
+ _PyLong_DIGIT_INIT(-4), \
+ _PyLong_DIGIT_INIT(-3), \
+ _PyLong_DIGIT_INIT(-2), \
+ _PyLong_DIGIT_INIT(-1), \
+ _PyLong_DIGIT_INIT(0), \
+ _PyLong_DIGIT_INIT(1), \
+ _PyLong_DIGIT_INIT(2), \
+ _PyLong_DIGIT_INIT(3), \
+ _PyLong_DIGIT_INIT(4), \
+ _PyLong_DIGIT_INIT(5), \
+ _PyLong_DIGIT_INIT(6), \
+ _PyLong_DIGIT_INIT(7), \
+ _PyLong_DIGIT_INIT(8), \
+ _PyLong_DIGIT_INIT(9), \
+ _PyLong_DIGIT_INIT(10), \
+ _PyLong_DIGIT_INIT(11), \
+ _PyLong_DIGIT_INIT(12), \
+ _PyLong_DIGIT_INIT(13), \
+ _PyLong_DIGIT_INIT(14), \
+ _PyLong_DIGIT_INIT(15), \
+ _PyLong_DIGIT_INIT(16), \
+ _PyLong_DIGIT_INIT(17), \
+ _PyLong_DIGIT_INIT(18), \
+ _PyLong_DIGIT_INIT(19), \
+ _PyLong_DIGIT_INIT(20), \
+ _PyLong_DIGIT_INIT(21), \
+ _PyLong_DIGIT_INIT(22), \
+ _PyLong_DIGIT_INIT(23), \
+ _PyLong_DIGIT_INIT(24), \
+ _PyLong_DIGIT_INIT(25), \
+ _PyLong_DIGIT_INIT(26), \
+ _PyLong_DIGIT_INIT(27), \
+ _PyLong_DIGIT_INIT(28), \
+ _PyLong_DIGIT_INIT(29), \
+ _PyLong_DIGIT_INIT(30), \
+ _PyLong_DIGIT_INIT(31), \
+ _PyLong_DIGIT_INIT(32), \
+ _PyLong_DIGIT_INIT(33), \
+ _PyLong_DIGIT_INIT(34), \
+ _PyLong_DIGIT_INIT(35), \
+ _PyLong_DIGIT_INIT(36), \
+ _PyLong_DIGIT_INIT(37), \
+ _PyLong_DIGIT_INIT(38), \
+ _PyLong_DIGIT_INIT(39), \
+ _PyLong_DIGIT_INIT(40), \
+ _PyLong_DIGIT_INIT(41), \
+ _PyLong_DIGIT_INIT(42), \
+ _PyLong_DIGIT_INIT(43), \
+ _PyLong_DIGIT_INIT(44), \
+ _PyLong_DIGIT_INIT(45), \
+ _PyLong_DIGIT_INIT(46), \
+ _PyLong_DIGIT_INIT(47), \
+ _PyLong_DIGIT_INIT(48), \
+ _PyLong_DIGIT_INIT(49), \
+ _PyLong_DIGIT_INIT(50), \
+ _PyLong_DIGIT_INIT(51), \
+ _PyLong_DIGIT_INIT(52), \
+ _PyLong_DIGIT_INIT(53), \
+ _PyLong_DIGIT_INIT(54), \
+ _PyLong_DIGIT_INIT(55), \
+ _PyLong_DIGIT_INIT(56), \
+ _PyLong_DIGIT_INIT(57), \
+ _PyLong_DIGIT_INIT(58), \
+ _PyLong_DIGIT_INIT(59), \
+ _PyLong_DIGIT_INIT(60), \
+ _PyLong_DIGIT_INIT(61), \
+ _PyLong_DIGIT_INIT(62), \
+ _PyLong_DIGIT_INIT(63), \
+ _PyLong_DIGIT_INIT(64), \
+ _PyLong_DIGIT_INIT(65), \
+ _PyLong_DIGIT_INIT(66), \
+ _PyLong_DIGIT_INIT(67), \
+ _PyLong_DIGIT_INIT(68), \
+ _PyLong_DIGIT_INIT(69), \
+ _PyLong_DIGIT_INIT(70), \
+ _PyLong_DIGIT_INIT(71), \
+ _PyLong_DIGIT_INIT(72), \
+ _PyLong_DIGIT_INIT(73), \
+ _PyLong_DIGIT_INIT(74), \
+ _PyLong_DIGIT_INIT(75), \
+ _PyLong_DIGIT_INIT(76), \
+ _PyLong_DIGIT_INIT(77), \
+ _PyLong_DIGIT_INIT(78), \
+ _PyLong_DIGIT_INIT(79), \
+ _PyLong_DIGIT_INIT(80), \
+ _PyLong_DIGIT_INIT(81), \
+ _PyLong_DIGIT_INIT(82), \
+ _PyLong_DIGIT_INIT(83), \
+ _PyLong_DIGIT_INIT(84), \
+ _PyLong_DIGIT_INIT(85), \
+ _PyLong_DIGIT_INIT(86), \
+ _PyLong_DIGIT_INIT(87), \
+ _PyLong_DIGIT_INIT(88), \
+ _PyLong_DIGIT_INIT(89), \
+ _PyLong_DIGIT_INIT(90), \
+ _PyLong_DIGIT_INIT(91), \
+ _PyLong_DIGIT_INIT(92), \
+ _PyLong_DIGIT_INIT(93), \
+ _PyLong_DIGIT_INIT(94), \
+ _PyLong_DIGIT_INIT(95), \
+ _PyLong_DIGIT_INIT(96), \
+ _PyLong_DIGIT_INIT(97), \
+ _PyLong_DIGIT_INIT(98), \
+ _PyLong_DIGIT_INIT(99), \
+ _PyLong_DIGIT_INIT(100), \
+ _PyLong_DIGIT_INIT(101), \
+ _PyLong_DIGIT_INIT(102), \
+ _PyLong_DIGIT_INIT(103), \
+ _PyLong_DIGIT_INIT(104), \
+ _PyLong_DIGIT_INIT(105), \
+ _PyLong_DIGIT_INIT(106), \
+ _PyLong_DIGIT_INIT(107), \
+ _PyLong_DIGIT_INIT(108), \
+ _PyLong_DIGIT_INIT(109), \
+ _PyLong_DIGIT_INIT(110), \
+ _PyLong_DIGIT_INIT(111), \
+ _PyLong_DIGIT_INIT(112), \
+ _PyLong_DIGIT_INIT(113), \
+ _PyLong_DIGIT_INIT(114), \
+ _PyLong_DIGIT_INIT(115), \
+ _PyLong_DIGIT_INIT(116), \
+ _PyLong_DIGIT_INIT(117), \
+ _PyLong_DIGIT_INIT(118), \
+ _PyLong_DIGIT_INIT(119), \
+ _PyLong_DIGIT_INIT(120), \
+ _PyLong_DIGIT_INIT(121), \
+ _PyLong_DIGIT_INIT(122), \
+ _PyLong_DIGIT_INIT(123), \
+ _PyLong_DIGIT_INIT(124), \
+ _PyLong_DIGIT_INIT(125), \
+ _PyLong_DIGIT_INIT(126), \
+ _PyLong_DIGIT_INIT(127), \
+ _PyLong_DIGIT_INIT(128), \
+ _PyLong_DIGIT_INIT(129), \
+ _PyLong_DIGIT_INIT(130), \
+ _PyLong_DIGIT_INIT(131), \
+ _PyLong_DIGIT_INIT(132), \
+ _PyLong_DIGIT_INIT(133), \
+ _PyLong_DIGIT_INIT(134), \
+ _PyLong_DIGIT_INIT(135), \
+ _PyLong_DIGIT_INIT(136), \
+ _PyLong_DIGIT_INIT(137), \
+ _PyLong_DIGIT_INIT(138), \
+ _PyLong_DIGIT_INIT(139), \
+ _PyLong_DIGIT_INIT(140), \
+ _PyLong_DIGIT_INIT(141), \
+ _PyLong_DIGIT_INIT(142), \
+ _PyLong_DIGIT_INIT(143), \
+ _PyLong_DIGIT_INIT(144), \
+ _PyLong_DIGIT_INIT(145), \
+ _PyLong_DIGIT_INIT(146), \
+ _PyLong_DIGIT_INIT(147), \
+ _PyLong_DIGIT_INIT(148), \
+ _PyLong_DIGIT_INIT(149), \
+ _PyLong_DIGIT_INIT(150), \
+ _PyLong_DIGIT_INIT(151), \
+ _PyLong_DIGIT_INIT(152), \
+ _PyLong_DIGIT_INIT(153), \
+ _PyLong_DIGIT_INIT(154), \
+ _PyLong_DIGIT_INIT(155), \
+ _PyLong_DIGIT_INIT(156), \
+ _PyLong_DIGIT_INIT(157), \
+ _PyLong_DIGIT_INIT(158), \
+ _PyLong_DIGIT_INIT(159), \
+ _PyLong_DIGIT_INIT(160), \
+ _PyLong_DIGIT_INIT(161), \
+ _PyLong_DIGIT_INIT(162), \
+ _PyLong_DIGIT_INIT(163), \
+ _PyLong_DIGIT_INIT(164), \
+ _PyLong_DIGIT_INIT(165), \
+ _PyLong_DIGIT_INIT(166), \
+ _PyLong_DIGIT_INIT(167), \
+ _PyLong_DIGIT_INIT(168), \
+ _PyLong_DIGIT_INIT(169), \
+ _PyLong_DIGIT_INIT(170), \
+ _PyLong_DIGIT_INIT(171), \
+ _PyLong_DIGIT_INIT(172), \
+ _PyLong_DIGIT_INIT(173), \
+ _PyLong_DIGIT_INIT(174), \
+ _PyLong_DIGIT_INIT(175), \
+ _PyLong_DIGIT_INIT(176), \
+ _PyLong_DIGIT_INIT(177), \
+ _PyLong_DIGIT_INIT(178), \
+ _PyLong_DIGIT_INIT(179), \
+ _PyLong_DIGIT_INIT(180), \
+ _PyLong_DIGIT_INIT(181), \
+ _PyLong_DIGIT_INIT(182), \
+ _PyLong_DIGIT_INIT(183), \
+ _PyLong_DIGIT_INIT(184), \
+ _PyLong_DIGIT_INIT(185), \
+ _PyLong_DIGIT_INIT(186), \
+ _PyLong_DIGIT_INIT(187), \
+ _PyLong_DIGIT_INIT(188), \
+ _PyLong_DIGIT_INIT(189), \
+ _PyLong_DIGIT_INIT(190), \
+ _PyLong_DIGIT_INIT(191), \
+ _PyLong_DIGIT_INIT(192), \
+ _PyLong_DIGIT_INIT(193), \
+ _PyLong_DIGIT_INIT(194), \
+ _PyLong_DIGIT_INIT(195), \
+ _PyLong_DIGIT_INIT(196), \
+ _PyLong_DIGIT_INIT(197), \
+ _PyLong_DIGIT_INIT(198), \
+ _PyLong_DIGIT_INIT(199), \
+ _PyLong_DIGIT_INIT(200), \
+ _PyLong_DIGIT_INIT(201), \
+ _PyLong_DIGIT_INIT(202), \
+ _PyLong_DIGIT_INIT(203), \
+ _PyLong_DIGIT_INIT(204), \
+ _PyLong_DIGIT_INIT(205), \
+ _PyLong_DIGIT_INIT(206), \
+ _PyLong_DIGIT_INIT(207), \
+ _PyLong_DIGIT_INIT(208), \
+ _PyLong_DIGIT_INIT(209), \
+ _PyLong_DIGIT_INIT(210), \
+ _PyLong_DIGIT_INIT(211), \
+ _PyLong_DIGIT_INIT(212), \
+ _PyLong_DIGIT_INIT(213), \
+ _PyLong_DIGIT_INIT(214), \
+ _PyLong_DIGIT_INIT(215), \
+ _PyLong_DIGIT_INIT(216), \
+ _PyLong_DIGIT_INIT(217), \
+ _PyLong_DIGIT_INIT(218), \
+ _PyLong_DIGIT_INIT(219), \
+ _PyLong_DIGIT_INIT(220), \
+ _PyLong_DIGIT_INIT(221), \
+ _PyLong_DIGIT_INIT(222), \
+ _PyLong_DIGIT_INIT(223), \
+ _PyLong_DIGIT_INIT(224), \
+ _PyLong_DIGIT_INIT(225), \
+ _PyLong_DIGIT_INIT(226), \
+ _PyLong_DIGIT_INIT(227), \
+ _PyLong_DIGIT_INIT(228), \
+ _PyLong_DIGIT_INIT(229), \
+ _PyLong_DIGIT_INIT(230), \
+ _PyLong_DIGIT_INIT(231), \
+ _PyLong_DIGIT_INIT(232), \
+ _PyLong_DIGIT_INIT(233), \
+ _PyLong_DIGIT_INIT(234), \
+ _PyLong_DIGIT_INIT(235), \
+ _PyLong_DIGIT_INIT(236), \
+ _PyLong_DIGIT_INIT(237), \
+ _PyLong_DIGIT_INIT(238), \
+ _PyLong_DIGIT_INIT(239), \
+ _PyLong_DIGIT_INIT(240), \
+ _PyLong_DIGIT_INIT(241), \
+ _PyLong_DIGIT_INIT(242), \
+ _PyLong_DIGIT_INIT(243), \
+ _PyLong_DIGIT_INIT(244), \
+ _PyLong_DIGIT_INIT(245), \
+ _PyLong_DIGIT_INIT(246), \
+ _PyLong_DIGIT_INIT(247), \
+ _PyLong_DIGIT_INIT(248), \
+ _PyLong_DIGIT_INIT(249), \
+ _PyLong_DIGIT_INIT(250), \
+ _PyLong_DIGIT_INIT(251), \
+ _PyLong_DIGIT_INIT(252), \
+ _PyLong_DIGIT_INIT(253), \
+ _PyLong_DIGIT_INIT(254), \
+ _PyLong_DIGIT_INIT(255), \
+ _PyLong_DIGIT_INIT(256), \
+ }, \
+ \
+ .bytes_empty = _PyBytes_SIMPLE_INIT(0, 0), \
+ .bytes_characters = { \
+ _PyBytes_CHAR_INIT(0), \
+ _PyBytes_CHAR_INIT(1), \
+ _PyBytes_CHAR_INIT(2), \
+ _PyBytes_CHAR_INIT(3), \
+ _PyBytes_CHAR_INIT(4), \
+ _PyBytes_CHAR_INIT(5), \
+ _PyBytes_CHAR_INIT(6), \
+ _PyBytes_CHAR_INIT(7), \
+ _PyBytes_CHAR_INIT(8), \
+ _PyBytes_CHAR_INIT(9), \
+ _PyBytes_CHAR_INIT(10), \
+ _PyBytes_CHAR_INIT(11), \
+ _PyBytes_CHAR_INIT(12), \
+ _PyBytes_CHAR_INIT(13), \
+ _PyBytes_CHAR_INIT(14), \
+ _PyBytes_CHAR_INIT(15), \
+ _PyBytes_CHAR_INIT(16), \
+ _PyBytes_CHAR_INIT(17), \
+ _PyBytes_CHAR_INIT(18), \
+ _PyBytes_CHAR_INIT(19), \
+ _PyBytes_CHAR_INIT(20), \
+ _PyBytes_CHAR_INIT(21), \
+ _PyBytes_CHAR_INIT(22), \
+ _PyBytes_CHAR_INIT(23), \
+ _PyBytes_CHAR_INIT(24), \
+ _PyBytes_CHAR_INIT(25), \
+ _PyBytes_CHAR_INIT(26), \
+ _PyBytes_CHAR_INIT(27), \
+ _PyBytes_CHAR_INIT(28), \
+ _PyBytes_CHAR_INIT(29), \
+ _PyBytes_CHAR_INIT(30), \
+ _PyBytes_CHAR_INIT(31), \
+ _PyBytes_CHAR_INIT(32), \
+ _PyBytes_CHAR_INIT(33), \
+ _PyBytes_CHAR_INIT(34), \
+ _PyBytes_CHAR_INIT(35), \
+ _PyBytes_CHAR_INIT(36), \
+ _PyBytes_CHAR_INIT(37), \
+ _PyBytes_CHAR_INIT(38), \
+ _PyBytes_CHAR_INIT(39), \
+ _PyBytes_CHAR_INIT(40), \
+ _PyBytes_CHAR_INIT(41), \
+ _PyBytes_CHAR_INIT(42), \
+ _PyBytes_CHAR_INIT(43), \
+ _PyBytes_CHAR_INIT(44), \
+ _PyBytes_CHAR_INIT(45), \
+ _PyBytes_CHAR_INIT(46), \
+ _PyBytes_CHAR_INIT(47), \
+ _PyBytes_CHAR_INIT(48), \
+ _PyBytes_CHAR_INIT(49), \
+ _PyBytes_CHAR_INIT(50), \
+ _PyBytes_CHAR_INIT(51), \
+ _PyBytes_CHAR_INIT(52), \
+ _PyBytes_CHAR_INIT(53), \
+ _PyBytes_CHAR_INIT(54), \
+ _PyBytes_CHAR_INIT(55), \
+ _PyBytes_CHAR_INIT(56), \
+ _PyBytes_CHAR_INIT(57), \
+ _PyBytes_CHAR_INIT(58), \
+ _PyBytes_CHAR_INIT(59), \
+ _PyBytes_CHAR_INIT(60), \
+ _PyBytes_CHAR_INIT(61), \
+ _PyBytes_CHAR_INIT(62), \
+ _PyBytes_CHAR_INIT(63), \
+ _PyBytes_CHAR_INIT(64), \
+ _PyBytes_CHAR_INIT(65), \
+ _PyBytes_CHAR_INIT(66), \
+ _PyBytes_CHAR_INIT(67), \
+ _PyBytes_CHAR_INIT(68), \
+ _PyBytes_CHAR_INIT(69), \
+ _PyBytes_CHAR_INIT(70), \
+ _PyBytes_CHAR_INIT(71), \
+ _PyBytes_CHAR_INIT(72), \
+ _PyBytes_CHAR_INIT(73), \
+ _PyBytes_CHAR_INIT(74), \
+ _PyBytes_CHAR_INIT(75), \
+ _PyBytes_CHAR_INIT(76), \
+ _PyBytes_CHAR_INIT(77), \
+ _PyBytes_CHAR_INIT(78), \
+ _PyBytes_CHAR_INIT(79), \
+ _PyBytes_CHAR_INIT(80), \
+ _PyBytes_CHAR_INIT(81), \
+ _PyBytes_CHAR_INIT(82), \
+ _PyBytes_CHAR_INIT(83), \
+ _PyBytes_CHAR_INIT(84), \
+ _PyBytes_CHAR_INIT(85), \
+ _PyBytes_CHAR_INIT(86), \
+ _PyBytes_CHAR_INIT(87), \
+ _PyBytes_CHAR_INIT(88), \
+ _PyBytes_CHAR_INIT(89), \
+ _PyBytes_CHAR_INIT(90), \
+ _PyBytes_CHAR_INIT(91), \
+ _PyBytes_CHAR_INIT(92), \
+ _PyBytes_CHAR_INIT(93), \
+ _PyBytes_CHAR_INIT(94), \
+ _PyBytes_CHAR_INIT(95), \
+ _PyBytes_CHAR_INIT(96), \
+ _PyBytes_CHAR_INIT(97), \
+ _PyBytes_CHAR_INIT(98), \
+ _PyBytes_CHAR_INIT(99), \
+ _PyBytes_CHAR_INIT(100), \
+ _PyBytes_CHAR_INIT(101), \
+ _PyBytes_CHAR_INIT(102), \
+ _PyBytes_CHAR_INIT(103), \
+ _PyBytes_CHAR_INIT(104), \
+ _PyBytes_CHAR_INIT(105), \
+ _PyBytes_CHAR_INIT(106), \
+ _PyBytes_CHAR_INIT(107), \
+ _PyBytes_CHAR_INIT(108), \
+ _PyBytes_CHAR_INIT(109), \
+ _PyBytes_CHAR_INIT(110), \
+ _PyBytes_CHAR_INIT(111), \
+ _PyBytes_CHAR_INIT(112), \
+ _PyBytes_CHAR_INIT(113), \
+ _PyBytes_CHAR_INIT(114), \
+ _PyBytes_CHAR_INIT(115), \
+ _PyBytes_CHAR_INIT(116), \
+ _PyBytes_CHAR_INIT(117), \
+ _PyBytes_CHAR_INIT(118), \
+ _PyBytes_CHAR_INIT(119), \
+ _PyBytes_CHAR_INIT(120), \
+ _PyBytes_CHAR_INIT(121), \
+ _PyBytes_CHAR_INIT(122), \
+ _PyBytes_CHAR_INIT(123), \
+ _PyBytes_CHAR_INIT(124), \
+ _PyBytes_CHAR_INIT(125), \
+ _PyBytes_CHAR_INIT(126), \
+ _PyBytes_CHAR_INIT(127), \
+ _PyBytes_CHAR_INIT(128), \
+ _PyBytes_CHAR_INIT(129), \
+ _PyBytes_CHAR_INIT(130), \
+ _PyBytes_CHAR_INIT(131), \
+ _PyBytes_CHAR_INIT(132), \
+ _PyBytes_CHAR_INIT(133), \
+ _PyBytes_CHAR_INIT(134), \
+ _PyBytes_CHAR_INIT(135), \
+ _PyBytes_CHAR_INIT(136), \
+ _PyBytes_CHAR_INIT(137), \
+ _PyBytes_CHAR_INIT(138), \
+ _PyBytes_CHAR_INIT(139), \
+ _PyBytes_CHAR_INIT(140), \
+ _PyBytes_CHAR_INIT(141), \
+ _PyBytes_CHAR_INIT(142), \
+ _PyBytes_CHAR_INIT(143), \
+ _PyBytes_CHAR_INIT(144), \
+ _PyBytes_CHAR_INIT(145), \
+ _PyBytes_CHAR_INIT(146), \
+ _PyBytes_CHAR_INIT(147), \
+ _PyBytes_CHAR_INIT(148), \
+ _PyBytes_CHAR_INIT(149), \
+ _PyBytes_CHAR_INIT(150), \
+ _PyBytes_CHAR_INIT(151), \
+ _PyBytes_CHAR_INIT(152), \
+ _PyBytes_CHAR_INIT(153), \
+ _PyBytes_CHAR_INIT(154), \
+ _PyBytes_CHAR_INIT(155), \
+ _PyBytes_CHAR_INIT(156), \
+ _PyBytes_CHAR_INIT(157), \
+ _PyBytes_CHAR_INIT(158), \
+ _PyBytes_CHAR_INIT(159), \
+ _PyBytes_CHAR_INIT(160), \
+ _PyBytes_CHAR_INIT(161), \
+ _PyBytes_CHAR_INIT(162), \
+ _PyBytes_CHAR_INIT(163), \
+ _PyBytes_CHAR_INIT(164), \
+ _PyBytes_CHAR_INIT(165), \
+ _PyBytes_CHAR_INIT(166), \
+ _PyBytes_CHAR_INIT(167), \
+ _PyBytes_CHAR_INIT(168), \
+ _PyBytes_CHAR_INIT(169), \
+ _PyBytes_CHAR_INIT(170), \
+ _PyBytes_CHAR_INIT(171), \
+ _PyBytes_CHAR_INIT(172), \
+ _PyBytes_CHAR_INIT(173), \
+ _PyBytes_CHAR_INIT(174), \
+ _PyBytes_CHAR_INIT(175), \
+ _PyBytes_CHAR_INIT(176), \
+ _PyBytes_CHAR_INIT(177), \
+ _PyBytes_CHAR_INIT(178), \
+ _PyBytes_CHAR_INIT(179), \
+ _PyBytes_CHAR_INIT(180), \
+ _PyBytes_CHAR_INIT(181), \
+ _PyBytes_CHAR_INIT(182), \
+ _PyBytes_CHAR_INIT(183), \
+ _PyBytes_CHAR_INIT(184), \
+ _PyBytes_CHAR_INIT(185), \
+ _PyBytes_CHAR_INIT(186), \
+ _PyBytes_CHAR_INIT(187), \
+ _PyBytes_CHAR_INIT(188), \
+ _PyBytes_CHAR_INIT(189), \
+ _PyBytes_CHAR_INIT(190), \
+ _PyBytes_CHAR_INIT(191), \
+ _PyBytes_CHAR_INIT(192), \
+ _PyBytes_CHAR_INIT(193), \
+ _PyBytes_CHAR_INIT(194), \
+ _PyBytes_CHAR_INIT(195), \
+ _PyBytes_CHAR_INIT(196), \
+ _PyBytes_CHAR_INIT(197), \
+ _PyBytes_CHAR_INIT(198), \
+ _PyBytes_CHAR_INIT(199), \
+ _PyBytes_CHAR_INIT(200), \
+ _PyBytes_CHAR_INIT(201), \
+ _PyBytes_CHAR_INIT(202), \
+ _PyBytes_CHAR_INIT(203), \
+ _PyBytes_CHAR_INIT(204), \
+ _PyBytes_CHAR_INIT(205), \
+ _PyBytes_CHAR_INIT(206), \
+ _PyBytes_CHAR_INIT(207), \
+ _PyBytes_CHAR_INIT(208), \
+ _PyBytes_CHAR_INIT(209), \
+ _PyBytes_CHAR_INIT(210), \
+ _PyBytes_CHAR_INIT(211), \
+ _PyBytes_CHAR_INIT(212), \
+ _PyBytes_CHAR_INIT(213), \
+ _PyBytes_CHAR_INIT(214), \
+ _PyBytes_CHAR_INIT(215), \
+ _PyBytes_CHAR_INIT(216), \
+ _PyBytes_CHAR_INIT(217), \
+ _PyBytes_CHAR_INIT(218), \
+ _PyBytes_CHAR_INIT(219), \
+ _PyBytes_CHAR_INIT(220), \
+ _PyBytes_CHAR_INIT(221), \
+ _PyBytes_CHAR_INIT(222), \
+ _PyBytes_CHAR_INIT(223), \
+ _PyBytes_CHAR_INIT(224), \
+ _PyBytes_CHAR_INIT(225), \
+ _PyBytes_CHAR_INIT(226), \
+ _PyBytes_CHAR_INIT(227), \
+ _PyBytes_CHAR_INIT(228), \
+ _PyBytes_CHAR_INIT(229), \
+ _PyBytes_CHAR_INIT(230), \
+ _PyBytes_CHAR_INIT(231), \
+ _PyBytes_CHAR_INIT(232), \
+ _PyBytes_CHAR_INIT(233), \
+ _PyBytes_CHAR_INIT(234), \
+ _PyBytes_CHAR_INIT(235), \
+ _PyBytes_CHAR_INIT(236), \
+ _PyBytes_CHAR_INIT(237), \
+ _PyBytes_CHAR_INIT(238), \
+ _PyBytes_CHAR_INIT(239), \
+ _PyBytes_CHAR_INIT(240), \
+ _PyBytes_CHAR_INIT(241), \
+ _PyBytes_CHAR_INIT(242), \
+ _PyBytes_CHAR_INIT(243), \
+ _PyBytes_CHAR_INIT(244), \
+ _PyBytes_CHAR_INIT(245), \
+ _PyBytes_CHAR_INIT(246), \
+ _PyBytes_CHAR_INIT(247), \
+ _PyBytes_CHAR_INIT(248), \
+ _PyBytes_CHAR_INIT(249), \
+ _PyBytes_CHAR_INIT(250), \
+ _PyBytes_CHAR_INIT(251), \
+ _PyBytes_CHAR_INIT(252), \
+ _PyBytes_CHAR_INIT(253), \
+ _PyBytes_CHAR_INIT(254), \
+ _PyBytes_CHAR_INIT(255), \
+ }, \
+ }, \
+}
+
+
+#ifdef __cplusplus
+}
+#endif
+#endif /* !Py_INTERNAL_RUNTIME_INIT_H */
diff --git a/Include/pyport.h b/Include/pyport.h
index 81b1bde..d27b3dd 100644
--- a/Include/pyport.h
+++ b/Include/pyport.h
@@ -85,20 +85,12 @@ Used in: Py_SAFE_DOWNCAST
#define PY_INT32_T int32_t
#define PY_INT64_T int64_t
-/* If PYLONG_BITS_IN_DIGIT is not defined then we'll use 30-bit digits if all
- the necessary integer types are available, and we're on a 64-bit platform
- (as determined by SIZEOF_VOID_P); otherwise we use 15-bit digits.
-
- From pyodide: WASM has 32 bit pointers but has native 64 bit arithmetic
- so it is more efficient to use 30 bit digits.
+/* PYLONG_BITS_IN_DIGIT describes the number of bits per "digit" (limb) in the
+ * PyLongObject implementation (longintrepr.h). It's currently either 30 or 15,
+ * defaulting to 30. The 15-bit digit option may be removed in the future.
*/
-
#ifndef PYLONG_BITS_IN_DIGIT
-#if SIZEOF_VOID_P >= 8 || defined(__wasm__)
-# define PYLONG_BITS_IN_DIGIT 30
-#else
-# define PYLONG_BITS_IN_DIGIT 15
-#endif
+#define PYLONG_BITS_IN_DIGIT 30
#endif
/* uintptr_t is the C9X name for an unsigned integral type such that a
diff --git a/Lib/ntpath.py b/Lib/ntpath.py
index 58483a0..041ebc7 100644
--- a/Lib/ntpath.py
+++ b/Lib/ntpath.py
@@ -551,7 +551,7 @@ else: # use native Windows method on Windows
def abspath(path):
"""Return the absolute version of a path."""
try:
- return normpath(_getfullpathname(path))
+ return _getfullpathname(normpath(path))
except (OSError, ValueError):
return _abspath_fallback(path)
diff --git a/Lib/test/test_embed.py b/Lib/test/test_embed.py
index dd43669..9fed0a5 100644
--- a/Lib/test/test_embed.py
+++ b/Lib/test/test_embed.py
@@ -1404,6 +1404,34 @@ class InitConfigTests(EmbeddingTestsMixin, unittest.TestCase):
api=API_COMPAT, env=env,
ignore_stderr=True, cwd=tmpdir)
+ @unittest.skipUnless(MS_WINDOWS, 'specific to Windows')
+ def test_getpath_abspath_win32(self):
+ # Check _Py_abspath() is passed a backslashed path not to fall back to
+ # GetFullPathNameW() on startup, which (re-)normalizes the path overly.
+ # Currently, _Py_normpath() doesn't trim trailing dots and spaces.
+ CASES = [
+ ("C:/a. . .", "C:\\a. . ."),
+ ("C:\\a. . .", "C:\\a. . ."),
+ ("\\\\?\\C:////a////b. . .", "\\\\?\\C:\\a\\b. . ."),
+ ("//a/b/c. . .", "\\\\a\\b\\c. . ."),
+ ("\\\\a\\b\\c. . .", "\\\\a\\b\\c. . ."),
+ ("a. . .", f"{os.getcwd()}\\a"), # relpath gets fully normalized
+ ]
+ out, err = self.run_embedded_interpreter(
+ "test_init_initialize_config",
+ env={**remove_python_envvars(),
+ "PYTHONPATH": os.path.pathsep.join(c[0] for c in CASES)}
+ )
+ self.assertEqual(err, "")
+ try:
+ out = json.loads(out)
+ except json.JSONDecodeError:
+ self.fail(f"fail to decode stdout: {out!r}")
+
+ results = out['config']["module_search_paths"]
+ for (_, expected), result in zip(CASES, results):
+ self.assertEqual(result, expected)
+
def test_global_pathconfig(self):
# Test C API functions getting the path configuration:
#
diff --git a/Lib/test/test_functools.py b/Lib/test/test_functools.py
index 70ae8e0..d527e31 100644
--- a/Lib/test/test_functools.py
+++ b/Lib/test/test_functools.py
@@ -1414,7 +1414,7 @@ class TestLRU:
def test_lru_star_arg_handling(self):
# Test regression that arose in ea064ff3c10f
- @functools.lru_cache()
+ @self.module.lru_cache()
def f(*args):
return args
@@ -1426,11 +1426,11 @@ class TestLRU:
# lru_cache was leaking when one of the arguments
# wasn't cacheable.
- @functools.lru_cache(maxsize=None)
+ @self.module.lru_cache(maxsize=None)
def infinite_cache(o):
pass
- @functools.lru_cache(maxsize=10)
+ @self.module.lru_cache(maxsize=10)
def limited_cache(o):
pass
diff --git a/Lib/test/test_ntpath.py b/Lib/test/test_ntpath.py
index cc29881..99a77e3 100644
--- a/Lib/test/test_ntpath.py
+++ b/Lib/test/test_ntpath.py
@@ -613,6 +613,40 @@ class TestNtpath(NtpathTestCase):
@unittest.skipUnless(nt, "abspath requires 'nt' module")
def test_abspath(self):
tester('ntpath.abspath("C:\\")', "C:\\")
+ tester('ntpath.abspath("\\\\?\\C:////spam////eggs. . .")', "\\\\?\\C:\\spam\\eggs")
+ tester('ntpath.abspath("\\\\.\\C:////spam////eggs. . .")', "\\\\.\\C:\\spam\\eggs")
+ tester('ntpath.abspath("//spam//eggs. . .")', "\\\\spam\\eggs")
+ tester('ntpath.abspath("\\\\spam\\\\eggs. . .")', "\\\\spam\\eggs")
+ tester('ntpath.abspath("C:/spam. . .")', "C:\\spam")
+ tester('ntpath.abspath("C:\\spam. . .")', "C:\\spam")
+ tester('ntpath.abspath("C:/nul")', "\\\\.\\nul")
+ tester('ntpath.abspath("C:\\nul")', "\\\\.\\nul")
+ tester('ntpath.abspath("//..")', "\\\\")
+ tester('ntpath.abspath("//../")', "\\\\..\\")
+ tester('ntpath.abspath("//../..")', "\\\\..\\")
+ tester('ntpath.abspath("//../../")', "\\\\..\\..\\")
+ tester('ntpath.abspath("//../../../")', "\\\\..\\..\\")
+ tester('ntpath.abspath("//../../../..")', "\\\\..\\..\\")
+ tester('ntpath.abspath("//../../../../")', "\\\\..\\..\\")
+ tester('ntpath.abspath("//server")', "\\\\server")
+ tester('ntpath.abspath("//server/")', "\\\\server\\")
+ tester('ntpath.abspath("//server/..")', "\\\\server\\")
+ tester('ntpath.abspath("//server/../")', "\\\\server\\..\\")
+ tester('ntpath.abspath("//server/../..")', "\\\\server\\..\\")
+ tester('ntpath.abspath("//server/../../")', "\\\\server\\..\\")
+ tester('ntpath.abspath("//server/../../..")', "\\\\server\\..\\")
+ tester('ntpath.abspath("//server/../../../")', "\\\\server\\..\\")
+ tester('ntpath.abspath("//server/share")', "\\\\server\\share")
+ tester('ntpath.abspath("//server/share/")', "\\\\server\\share\\")
+ tester('ntpath.abspath("//server/share/..")', "\\\\server\\share\\")
+ tester('ntpath.abspath("//server/share/../")', "\\\\server\\share\\")
+ tester('ntpath.abspath("//server/share/../..")', "\\\\server\\share\\")
+ tester('ntpath.abspath("//server/share/../../")', "\\\\server\\share\\")
+ tester('ntpath.abspath("C:\\nul. . .")', "\\\\.\\nul")
+ tester('ntpath.abspath("//... . .")', "\\\\")
+ tester('ntpath.abspath("//.. . . .")', "\\\\")
+ tester('ntpath.abspath("//../... . .")', "\\\\..\\")
+ tester('ntpath.abspath("//../.. . . .")', "\\\\..\\")
with os_helper.temp_cwd(os_helper.TESTFN) as cwd_dir: # bpo-31047
tester('ntpath.abspath("")', cwd_dir)
tester('ntpath.abspath(" ")', cwd_dir + "\\ ")
diff --git a/Makefile.pre.in b/Makefile.pre.in
index a84badcd..0b4d9a5 100644
--- a/Makefile.pre.in
+++ b/Makefile.pre.in
@@ -1651,6 +1651,7 @@ PYTHON_HEADERS= \
$(srcdir)/Include/internal/pycore_pymem.h \
$(srcdir)/Include/internal/pycore_pystate.h \
$(srcdir)/Include/internal/pycore_runtime.h \
+ $(srcdir)/Include/internal/pycore_runtime_init.h \
$(srcdir)/Include/internal/pycore_sliceobject.h \
$(srcdir)/Include/internal/pycore_strhex.h \
$(srcdir)/Include/internal/pycore_structseq.h \
@@ -2398,6 +2399,7 @@ clean-retain-profile: pycremoval
-rm -f Lib/lib2to3/*Grammar*.pickle
-rm -f _bootstrap_python
-rm -f python.html python*.js python.data
+ -rm -rf $(WASM_STDLIB)
-rm -f Programs/_testembed Programs/_freeze_module
-rm -f Python/deepfreeze/*.[co]
-rm -f Python/frozen_modules/*.h
diff --git a/Misc/NEWS.d/next/Build/2022-01-09-11-24-54.bpo-45569.zCIENy.rst b/Misc/NEWS.d/next/Build/2022-01-09-11-24-54.bpo-45569.zCIENy.rst
new file mode 100644
index 0000000..69716cd
--- /dev/null
+++ b/Misc/NEWS.d/next/Build/2022-01-09-11-24-54.bpo-45569.zCIENy.rst
@@ -0,0 +1,5 @@
+The build now defaults to using 30-bit digits for Python integers. Previously
+either 15-bit or 30-bit digits would be selected, depending on the platform.
+15-bit digits may still be selected using the ``--enable-big-digits=15`` option
+to the ``configure`` script, or by defining ``PYLONG_BITS_IN_DIGIT`` in
+``pyconfig.h``.
diff --git a/Misc/NEWS.d/next/Windows/2022-01-13-22-31-09.bpo-46362.f2cuEb.rst b/Misc/NEWS.d/next/Windows/2022-01-13-22-31-09.bpo-46362.f2cuEb.rst
new file mode 100644
index 0000000..0b59cd2
--- /dev/null
+++ b/Misc/NEWS.d/next/Windows/2022-01-13-22-31-09.bpo-46362.f2cuEb.rst
@@ -0,0 +1,2 @@
+os.path.abspath("C:\CON") is now fixed to return "\\.\CON", not the same path.
+The regression was true of all legacy DOS devices such as COM1, LPT1, or NUL. \ No newline at end of file
diff --git a/Modules/_hashopenssl.c b/Modules/_hashopenssl.c
index eeea61a..fb155b2 100644
--- a/Modules/_hashopenssl.c
+++ b/Modules/_hashopenssl.c
@@ -883,7 +883,7 @@ py_evp_fromname(PyObject *module, const char *digestname, PyObject *data_obj,
goto exit;
}
-#if defined(EVP_MD_CTX_FLAG_NON_FIPS_ALLOW) && OPENSSL_VERSION_NUMBER >= 0x30000000L
+#if defined(EVP_MD_CTX_FLAG_NON_FIPS_ALLOW) && OPENSSL_VERSION_NUMBER < 0x30000000L
// In OpenSSL 1.1.1 the non FIPS allowed flag is context specific while
// in 3.0.0 it is a different EVP_MD provider.
if (!usedforsecurity) {
diff --git a/Modules/_tracemalloc.c b/Modules/_tracemalloc.c
index b838439..14bad00 100644
--- a/Modules/_tracemalloc.c
+++ b/Modules/_tracemalloc.c
@@ -1242,6 +1242,9 @@ tracemalloc_copy_domain(_Py_hashtable_t *domains,
_Py_hashtable_t *traces = (_Py_hashtable_t *)value;
_Py_hashtable_t *traces2 = tracemalloc_copy_traces(traces);
+ if (traces2 == NULL) {
+ return -1;
+ }
if (_Py_hashtable_set(domains2, TO_PTR(domain), traces2) < 0) {
_Py_hashtable_destroy(traces2);
return -1;
diff --git a/Modules/gcmodule.c b/Modules/gcmodule.c
index e22f031..16f8c2b 100644
--- a/Modules/gcmodule.c
+++ b/Modules/gcmodule.c
@@ -139,24 +139,20 @@ get_gc_state(void)
void
_PyGC_InitState(GCState *gcstate)
{
- gcstate->enabled = 1; /* automatic collection enabled? */
-
-#define _GEN_HEAD(n) GEN_HEAD(gcstate, n)
- struct gc_generation generations[NUM_GENERATIONS] = {
- /* PyGC_Head, threshold, count */
- {{(uintptr_t)_GEN_HEAD(0), (uintptr_t)_GEN_HEAD(0)}, 700, 0},
- {{(uintptr_t)_GEN_HEAD(1), (uintptr_t)_GEN_HEAD(1)}, 10, 0},
- {{(uintptr_t)_GEN_HEAD(2), (uintptr_t)_GEN_HEAD(2)}, 10, 0},
- };
+#define INIT_HEAD(GEN) \
+ do { \
+ GEN.head._gc_next = (uintptr_t)&GEN.head; \
+ GEN.head._gc_prev = (uintptr_t)&GEN.head; \
+ } while (0)
+
for (int i = 0; i < NUM_GENERATIONS; i++) {
- gcstate->generations[i] = generations[i];
+ assert(gcstate->generations[i].count == 0);
+ INIT_HEAD(gcstate->generations[i]);
};
gcstate->generation0 = GEN_HEAD(gcstate, 0);
- struct gc_generation permanent_generation = {
- {(uintptr_t)&gcstate->permanent_generation.head,
- (uintptr_t)&gcstate->permanent_generation.head}, 0, 0
- };
- gcstate->permanent_generation = permanent_generation;
+ INIT_HEAD(gcstate->permanent_generation);
+
+#undef INIT_HEAD
}
diff --git a/Modules/getpath.c b/Modules/getpath.c
index fdfe929..5c646c9 100644
--- a/Modules/getpath.c
+++ b/Modules/getpath.c
@@ -59,7 +59,7 @@ getpath_abspath(PyObject *Py_UNUSED(self), PyObject *args)
{
PyObject *r = NULL;
PyObject *pathobj;
- const wchar_t *path;
+ wchar_t *path;
if (!PyArg_ParseTuple(args, "U", &pathobj)) {
return NULL;
}
@@ -67,8 +67,8 @@ getpath_abspath(PyObject *Py_UNUSED(self), PyObject *args)
path = PyUnicode_AsWideCharString(pathobj, &len);
if (path) {
wchar_t *abs;
- if (_Py_abspath(path, &abs) == 0 && abs) {
- r = PyUnicode_FromWideChar(_Py_normpath(abs, -1), -1);
+ if (_Py_abspath((const wchar_t *)_Py_normpath(path, -1), &abs) == 0 && abs) {
+ r = PyUnicode_FromWideChar(abs, -1);
PyMem_RawFree((void *)abs);
} else {
PyErr_SetString(PyExc_OSError, "failed to make path absolute");
diff --git a/Modules/posixmodule.c b/Modules/posixmodule.c
index 904f8bf..7b5c3ef 100644
--- a/Modules/posixmodule.c
+++ b/Modules/posixmodule.c
@@ -4240,6 +4240,48 @@ os_listdir_impl(PyObject *module, path_t *path)
}
#ifdef MS_WINDOWS
+int
+_PyOS_getfullpathname(const wchar_t *path, wchar_t **abspath_p)
+{
+ wchar_t woutbuf[MAX_PATH], *woutbufp = woutbuf;
+ DWORD result;
+
+ result = GetFullPathNameW(path,
+ Py_ARRAY_LENGTH(woutbuf), woutbuf,
+ NULL);
+ if (!result) {
+ return -1;
+ }
+
+ if (result >= Py_ARRAY_LENGTH(woutbuf)) {
+ if ((size_t)result <= (size_t)PY_SSIZE_T_MAX / sizeof(wchar_t)) {
+ woutbufp = PyMem_RawMalloc((size_t)result * sizeof(wchar_t));
+ }
+ else {
+ woutbufp = NULL;
+ }
+ if (!woutbufp) {
+ *abspath_p = NULL;
+ return 0;
+ }
+
+ result = GetFullPathNameW(path, result, woutbufp, NULL);
+ if (!result) {
+ PyMem_RawFree(woutbufp);
+ return -1;
+ }
+ }
+
+ if (woutbufp != woutbuf) {
+ *abspath_p = woutbufp;
+ return 0;
+ }
+
+ *abspath_p = _PyMem_RawWcsdup(woutbufp);
+ return 0;
+}
+
+
/* A helper function for abspath on win32 */
/*[clinic input]
os._getfullpathname
@@ -4255,8 +4297,7 @@ os__getfullpathname_impl(PyObject *module, path_t *path)
{
wchar_t *abspath;
- /* _Py_abspath() is implemented with GetFullPathNameW() on Windows */
- if (_Py_abspath(path->wide, &abspath) < 0) {
+ if (_PyOS_getfullpathname(path->wide, &abspath) < 0) {
return win32_error_object("GetFullPathNameW", path->object);
}
if (abspath == NULL) {
diff --git a/PCbuild/pythoncore.vcxproj b/PCbuild/pythoncore.vcxproj
index 83ae2f0..12eac8e 100644
--- a/PCbuild/pythoncore.vcxproj
+++ b/PCbuild/pythoncore.vcxproj
@@ -233,6 +233,7 @@
<ClInclude Include="..\Include\internal\pycore_pymem.h" />
<ClInclude Include="..\Include\internal\pycore_pystate.h" />
<ClInclude Include="..\Include\internal\pycore_runtime.h" />
+ <ClInclude Include="..\Include\internal\pycore_runtime_init.h" />
<ClInclude Include="..\Include\internal\pycore_sliceobject.h" />
<ClInclude Include="..\Include\internal\pycore_strhex.h" />
<ClInclude Include="..\Include\internal\pycore_structseq.h" />
diff --git a/PCbuild/pythoncore.vcxproj.filters b/PCbuild/pythoncore.vcxproj.filters
index cc0a2b0..4a50207 100644
--- a/PCbuild/pythoncore.vcxproj.filters
+++ b/PCbuild/pythoncore.vcxproj.filters
@@ -609,6 +609,9 @@
<ClInclude Include="..\Include\internal\pycore_runtime.h">
<Filter>Include\internal</Filter>
</ClInclude>
+ <ClInclude Include="..\Include\internal\pycore_runtime_init.h">
+ <Filter>Include\internal</Filter>
+ </ClInclude>
<ClInclude Include="..\Include\internal\pycore_sliceobject.h">
<Filter>Include\internal</Filter>
</ClInclude>
diff --git a/Python/ceval.c b/Python/ceval.c
index d33cd4e..70a7750 100644
--- a/Python/ceval.c
+++ b/Python/ceval.c
@@ -737,10 +737,6 @@ Py_MakePendingCalls(void)
/* The interpreter's recursion limit */
-#ifndef Py_DEFAULT_RECURSION_LIMIT
-# define Py_DEFAULT_RECURSION_LIMIT 1000
-#endif
-
void
_PyEval_InitRuntimeState(struct _ceval_runtime_state *ceval)
{
@@ -752,8 +748,6 @@ _PyEval_InitRuntimeState(struct _ceval_runtime_state *ceval)
void
_PyEval_InitState(struct _ceval_state *ceval, PyThread_type_lock pending_lock)
{
- ceval->recursion_limit = Py_DEFAULT_RECURSION_LIMIT;
-
struct _pending_calls *pending = &ceval->pending;
assert(pending->lock == NULL);
diff --git a/Python/fileutils.c b/Python/fileutils.c
index 151c6fe..9a71b83 100644
--- a/Python/fileutils.c
+++ b/Python/fileutils.c
@@ -2049,42 +2049,7 @@ _Py_abspath(const wchar_t *path, wchar_t **abspath_p)
}
#ifdef MS_WINDOWS
- wchar_t woutbuf[MAX_PATH], *woutbufp = woutbuf;
- DWORD result;
-
- result = GetFullPathNameW(path,
- Py_ARRAY_LENGTH(woutbuf), woutbuf,
- NULL);
- if (!result) {
- return -1;
- }
-
- if (result >= Py_ARRAY_LENGTH(woutbuf)) {
- if ((size_t)result <= (size_t)PY_SSIZE_T_MAX / sizeof(wchar_t)) {
- woutbufp = PyMem_RawMalloc((size_t)result * sizeof(wchar_t));
- }
- else {
- woutbufp = NULL;
- }
- if (!woutbufp) {
- *abspath_p = NULL;
- return 0;
- }
-
- result = GetFullPathNameW(path, result, woutbufp, NULL);
- if (!result) {
- PyMem_RawFree(woutbufp);
- return -1;
- }
- }
-
- if (woutbufp != woutbuf) {
- *abspath_p = woutbufp;
- return 0;
- }
-
- *abspath_p = _PyMem_RawWcsdup(woutbufp);
- return 0;
+ return _PyOS_getfullpathname(path, abspath_p);
#else
wchar_t cwd[MAXPATHLEN + 1];
cwd[Py_ARRAY_LENGTH(cwd) - 1] = 0;
diff --git a/Python/pylifecycle.c b/Python/pylifecycle.c
index 284cfac..8bcad67 100644
--- a/Python/pylifecycle.c
+++ b/Python/pylifecycle.c
@@ -20,6 +20,7 @@
#include "pycore_pyerrors.h" // _PyErr_Occurred()
#include "pycore_pylifecycle.h" // _PyErr_Print()
#include "pycore_pystate.h" // _PyThreadState_GET()
+#include "pycore_runtime_init.h" // _PyRuntimeState_INIT
#include "pycore_sliceobject.h" // _PySlice_Fini()
#include "pycore_structseq.h" // _PyStructSequence_InitState()
#include "pycore_sysmodule.h" // _PySys_ClearAuditHooks()
diff --git a/Python/pystate.c b/Python/pystate.c
index a18a159..4b698f2 100644
--- a/Python/pystate.c
+++ b/Python/pystate.c
@@ -10,6 +10,7 @@
#include "pycore_pylifecycle.h"
#include "pycore_pymem.h" // _PyMem_SetDefaultAllocator()
#include "pycore_pystate.h" // _PyThreadState_GET()
+#include "pycore_runtime_init.h" // _PyRuntimeState_INIT
#include "pycore_sysmodule.h"
/* --------------------------------------------------------------------------
@@ -110,17 +111,7 @@ init_runtime(_PyRuntimeState *runtime,
PyPreConfig_InitPythonConfig(&runtime->preconfig);
- runtime->gilstate.check_enabled = 1;
-
- /* A TSS key must be initialized with Py_tss_NEEDS_INIT
- in accordance with the specification. */
- Py_tss_t initial = Py_tss_NEEDS_INIT;
- runtime->gilstate.autoTSSkey = initial;
-
runtime->interpreters.mutex = interpreters_mutex;
- // This prevents interpreters from getting created
- // until _PyInterpreterState_Enable() is called.
- runtime->interpreters.next_id = -1;
runtime->xidregistry.mutex = xidregistry_mutex;
@@ -290,7 +281,6 @@ init_interpreter(PyInterpreterState *interp,
assert(id > 0 || (id == 0 && interp == runtime->interpreters.main));
interp->id = id;
- interp->id_refcount = -1;
assert(runtime->interpreters.head == interp);
assert(next != NULL || (interp == runtime->interpreters.main));
@@ -300,14 +290,6 @@ init_interpreter(PyInterpreterState *interp,
_PyGC_InitState(&interp->gc);
PyConfig_InitPythonConfig(&interp->config);
_PyType_InitCache(interp);
- interp->eval_frame = NULL;
-#ifdef HAVE_DLOPEN
-#if HAVE_DECL_RTLD_NOW
- interp->dlopenflags = RTLD_NOW;
-#else
- interp->dlopenflags = RTLD_LAZY;
-#endif
-#endif
interp->_initialized = 1;
}
@@ -784,21 +766,19 @@ init_threadstate(PyThreadState *tstate,
next->prev = tstate;
}
tstate->next = next;
- tstate->prev = NULL;
+ assert(tstate->prev == NULL);
tstate->thread_id = PyThread_get_thread_ident();
#ifdef PY_HAVE_THREAD_NATIVE_ID
tstate->native_thread_id = PyThread_get_thread_native_id();
#endif
- tstate->context_ver = 1;
-
tstate->recursion_limit = interp->ceval.recursion_limit,
tstate->recursion_remaining = interp->ceval.recursion_limit,
- tstate->exc_info = &tstate->exc_state;
+ tstate->exc_info = &tstate->_exc_state;
- tstate->cframe = &tstate->root_cframe;
+ tstate->cframe = &tstate->_root_cframe;
tstate->datastack_chunk = NULL;
tstate->datastack_top = NULL;
tstate->datastack_limit = NULL;
@@ -1036,10 +1016,10 @@ PyThreadState_Clear(PyThreadState *tstate)
Py_CLEAR(tstate->curexc_value);
Py_CLEAR(tstate->curexc_traceback);
- Py_CLEAR(tstate->exc_state.exc_value);
+ Py_CLEAR(tstate->_exc_state.exc_value);
/* The stack of exception states should contain just this thread. */
- if (verbose && tstate->exc_info != &tstate->exc_state) {
+ if (verbose && tstate->exc_info != &tstate->_exc_state) {
fprintf(stderr,
"PyThreadState_Clear: warning: thread still has a generator\n");
}
diff --git a/Tools/wasm/config.site-wasm32-emscripten b/Tools/wasm/config.site-wasm32-emscripten
index ce9dec7..c15e4fc 100644
--- a/Tools/wasm/config.site-wasm32-emscripten
+++ b/Tools/wasm/config.site-wasm32-emscripten
@@ -45,9 +45,10 @@ ac_cv_func_socketpair=no
ac_cv_func_utimensat=no
ac_cv_func_sigaction=no
-# Untested syscalls in emscripten
+# Untested or failing syscalls in emscripten
ac_cv_func_openat=no
ac_cv_func_mkdirat=no
+ac_cv_func_faccessat=no
ac_cv_func_fchownat=no
ac_cv_func_renameat=no
ac_cv_func_linkat=no
@@ -71,5 +72,10 @@ ac_cv_header_sys_ioctl_h=no
# sockets are supported, but only in non-blocking mode
# ac_cv_header_sys_socket_h=no
-# Unsupported functionality
-#undef HAVE_PTHREAD_H
+# aborts with bad ioctl
+ac_cv_func_openpty=no
+ac_cv_func_forkpty=no
+
+# To use dlopen, you need to use Emscripten's linking support,
+# see https://github.com/emscripten-core/emscripten/wiki/Linking)
+ac_cv_func_dlopen=no
diff --git a/configure b/configure
index ccbf4fc..1dee645 100755
--- a/configure
+++ b/configure
@@ -1730,7 +1730,7 @@ Optional Features:
Doc/library/socket.rst (default is yes if supported)
--enable-big-digits[=15|30]
use big digits (30 or 15 bits) for Python longs
- (default is system-dependent)]
+ (default is 30)]
--disable-test-modules don't build nor install test modules
Optional Packages:
@@ -6577,7 +6577,13 @@ fi
$as_echo "$LDLIBRARY" >&6; }
# LIBRARY_DEPS, LINK_PYTHON_OBJS and LINK_PYTHON_DEPS variable
-LIBRARY_DEPS='$(PY3LIBRARY) $(EXPORTSYMS)'
+case $ac_sys_system/$ac_sys_emscripten_target in #(
+ Emscripten/browser) :
+ LIBRARY_DEPS='$(PY3LIBRARY) $(WASM_STDLIB)' ;; #(
+ *) :
+ LIBRARY_DEPS='$(PY3LIBRARY) $(EXPORTSYMS)'
+ ;;
+esac
LINK_PYTHON_DEPS='$(LIBRARY_DEPS)'
if test "$PY_ENABLE_SHARED" = 1 || test "$enable_framework" ; then
LIBRARY_DEPS="\$(LDLIBRARY) $LIBRARY_DEPS"
@@ -7669,14 +7675,14 @@ fi
case $ac_sys_system/$ac_sys_emscripten_target in #(
Emscripten/browser) :
- LDFLAGS_NODIST="$(LDFLAGS_NODIST) -s ASSERTIONS=1 -s ALLOW_MEMORY_GROWTH=1 --preload-file \$(WASM_ASSETS_DIR)"
+ LDFLAGS_NODIST="$LDFLAGS_NODIST -s ASSERTIONS=1 -s ALLOW_MEMORY_GROWTH=1 --preload-file \$(WASM_ASSETS_DIR)"
WASM_ASSETS_DIR=".\$(prefix)"
WASM_STDLIB="\$(WASM_ASSETS_DIR)/local/lib/python\$(VERSION)/os.py"
;; #(
Emscripten/node) :
- LDFLAGS_NODIST="$(LDFLAGS_NODIST) -s ASSERTIONS=1 -s ALLOW_MEMORY_GROWTH=1 -s NODERAWFS=1 -s EXIT_RUNTIME=1 -s USE_PTHREADS -s PROXY_TO_PTHREAD"
- CFLAGS_NODIST="$(CFLAGS_NODIST) -pthread"
+ LDFLAGS_NODIST="$LDFLAGS_NODIST -s ASSERTIONS=1 -s ALLOW_MEMORY_GROWTH=1 -s NODERAWFS=1 -s EXIT_RUNTIME=1 -s USE_PTHREADS -s PROXY_TO_PTHREAD"
+ CFLAGS_NODIST="$CFLAGS_NODIST -pthread"
;; #(
WASI) :
@@ -21294,23 +21300,27 @@ $as_echo "yes" >&6; }
fi
-case $ac_sys_system in #(
- AIX) :
+case $ac_sys_system/$ac_sys_emscripten_target in #(
+ AIX/*) :
py_stdlib_not_available="_scproxy spwd" ;; #(
- VxWorks*) :
+ VxWorks*/*) :
py_stdlib_not_available="_scproxy _crypt termios grp" ;; #(
- Darwin) :
+ Darwin/*) :
py_stdlib_not_available="ossaudiodev spwd" ;; #(
- CYGWIN*) :
+ CYGWIN*/*) :
py_stdlib_not_available="_scproxy nis" ;; #(
- QNX*) :
+ QNX*/*) :
py_stdlib_not_available="_scproxy nis" ;; #(
- FreeBSD*) :
+ FreeBSD*/*) :
py_stdlib_not_available="_scproxy spwd" ;; #(
- Emscripten) :
+ Emscripten/browser) :
py_stdlib_not_available="_ctypes _curses _curses_panel _dbm _gdbm _multiprocessing _posixshmem _posixsubprocess _scproxy _tkinter _xxsubinterpreters fcntl grp nis ossaudiodev resource readline spwd syslog termios"
;; #(
+ Emscripten/node) :
+
+ py_stdlib_not_available="_ctypes _curses _curses_panel _dbm _gdbm _scproxy _tkinter nis ossaudiodev spwd syslog"
+ ;; #(
*) :
py_stdlib_not_available="_scproxy"
;;
diff --git a/configure.ac b/configure.ac
index 89041b2..7b084a2 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1354,7 +1354,10 @@ fi
AC_MSG_RESULT($LDLIBRARY)
# LIBRARY_DEPS, LINK_PYTHON_OBJS and LINK_PYTHON_DEPS variable
-LIBRARY_DEPS='$(PY3LIBRARY) $(EXPORTSYMS)'
+AS_CASE([$ac_sys_system/$ac_sys_emscripten_target],
+ [Emscripten/browser], [LIBRARY_DEPS='$(PY3LIBRARY) $(WASM_STDLIB)'],
+ [LIBRARY_DEPS='$(PY3LIBRARY) $(EXPORTSYMS)']
+)
LINK_PYTHON_DEPS='$(LIBRARY_DEPS)'
if test "$PY_ENABLE_SHARED" = 1 || test "$enable_framework" ; then
LIBRARY_DEPS="\$(LDLIBRARY) $LIBRARY_DEPS"
@@ -1839,13 +1842,13 @@ fi
# WASM flags
AS_CASE([$ac_sys_system/$ac_sys_emscripten_target],
[Emscripten/browser], [
- LDFLAGS_NODIST="$(LDFLAGS_NODIST) -s ASSERTIONS=1 -s ALLOW_MEMORY_GROWTH=1 --preload-file \$(WASM_ASSETS_DIR)"
+ LDFLAGS_NODIST="$LDFLAGS_NODIST -s ASSERTIONS=1 -s ALLOW_MEMORY_GROWTH=1 --preload-file \$(WASM_ASSETS_DIR)"
WASM_ASSETS_DIR=".\$(prefix)"
WASM_STDLIB="\$(WASM_ASSETS_DIR)/local/lib/python\$(VERSION)/os.py"
],
[Emscripten/node], [
- LDFLAGS_NODIST="$(LDFLAGS_NODIST) -s ASSERTIONS=1 -s ALLOW_MEMORY_GROWTH=1 -s NODERAWFS=1 -s EXIT_RUNTIME=1 -s USE_PTHREADS -s PROXY_TO_PTHREAD"
- CFLAGS_NODIST="$(CFLAGS_NODIST) -pthread"
+ LDFLAGS_NODIST="$LDFLAGS_NODIST -s ASSERTIONS=1 -s ALLOW_MEMORY_GROWTH=1 -s NODERAWFS=1 -s EXIT_RUNTIME=1 -s USE_PTHREADS -s PROXY_TO_PTHREAD"
+ CFLAGS_NODIST="$CFLAGS_NODIST -pthread"
],
[WASI], [
AC_DEFINE([_WASI_EMULATED_SIGNAL], [1], [Define to 1 if you want to emulate signals on WASI])
@@ -5081,7 +5084,7 @@ AC_CHECK_DECLS([RTLD_LAZY, RTLD_NOW, RTLD_GLOBAL, RTLD_LOCAL, RTLD_NODELETE, RTL
# determine what size digit to use for Python's longs
AC_MSG_CHECKING([digit size for Python's longs])
AC_ARG_ENABLE(big-digits,
-AS_HELP_STRING([--enable-big-digits@<:@=15|30@:>@],[use big digits (30 or 15 bits) for Python longs (default is system-dependent)]]),
+AS_HELP_STRING([--enable-big-digits@<:@=15|30@:>@],[use big digits (30 or 15 bits) for Python longs (default is 30)]]),
[case $enable_big_digits in
yes)
enable_big_digits=30 ;;
@@ -6336,14 +6339,14 @@ AC_SUBST(TEST_MODULES)
dnl Modules that are not available on some platforms
dnl AIX has shadow passwords, but access is not via getspent()
dnl VxWorks does not provide crypt() function
-AS_CASE([$ac_sys_system],
- [AIX], [py_stdlib_not_available="_scproxy spwd"],
- [VxWorks*], [py_stdlib_not_available="_scproxy _crypt termios grp"],
- [Darwin], [py_stdlib_not_available="ossaudiodev spwd"],
- [CYGWIN*], [py_stdlib_not_available="_scproxy nis"],
- [QNX*], [py_stdlib_not_available="_scproxy nis"],
- [FreeBSD*], [py_stdlib_not_available="_scproxy spwd"],
- [Emscripten], [
+AS_CASE([$ac_sys_system/$ac_sys_emscripten_target],
+ [AIX/*], [py_stdlib_not_available="_scproxy spwd"],
+ [VxWorks*/*], [py_stdlib_not_available="_scproxy _crypt termios grp"],
+ [Darwin/*], [py_stdlib_not_available="ossaudiodev spwd"],
+ [CYGWIN*/*], [py_stdlib_not_available="_scproxy nis"],
+ [QNX*/*], [py_stdlib_not_available="_scproxy nis"],
+ [FreeBSD*/*], [py_stdlib_not_available="_scproxy spwd"],
+ [Emscripten/browser], [
py_stdlib_not_available="m4_normalize([
_ctypes
_curses
@@ -6367,6 +6370,23 @@ AS_CASE([$ac_sys_system],
termios
])"
],
+ dnl Some modules like _posixsubprocess do not work. We build them anyway
+ dnl so imports in tests do not fail.
+ [Emscripten/node], [
+ py_stdlib_not_available="m4_normalize([
+ _ctypes
+ _curses
+ _curses_panel
+ _dbm
+ _gdbm
+ _scproxy
+ _tkinter
+ nis
+ ossaudiodev
+ spwd
+ syslog
+ ])"
+ ],
[py_stdlib_not_available="_scproxy"]
)