Skip to content

Commit 32b8f91

Browse files
authored
Merge branch 'main' into build/sha2
2 parents fb6454d + b365d88 commit 32b8f91

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+2540
-1531
lines changed

Doc/library/sqlite3.rst

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1442,6 +1442,14 @@ Cursor objects
14421442
and there is no open transaction,
14431443
a transaction is implicitly opened before executing *sql*.
14441444

1445+
.. deprecated-removed:: 3.12 3.14
1446+
1447+
:exc:`DeprecationWarning` is emitted if
1448+
:ref:`named placeholders <sqlite3-placeholders>` are used
1449+
and *parameters* is a sequence instead of a :class:`dict`.
1450+
Starting with Python 3.14, :exc:`ProgrammingError` will
1451+
be raised instead.
1452+
14451453
Use :meth:`executescript` to execute multiple SQL statements.
14461454

14471455
.. method:: executemany(sql, parameters, /)
@@ -1476,6 +1484,15 @@ Cursor objects
14761484
# cur is an sqlite3.Cursor object
14771485
cur.executemany("INSERT INTO data VALUES(?)", rows)
14781486

1487+
.. deprecated-removed:: 3.12 3.14
1488+
1489+
:exc:`DeprecationWarning` is emitted if
1490+
:ref:`named placeholders <sqlite3-placeholders>` are used
1491+
and the items in *parameters* are sequences
1492+
instead of :class:`dict`\s.
1493+
Starting with Python 3.14, :exc:`ProgrammingError` will
1494+
be raised instead.
1495+
14791496
.. method:: executescript(sql_script, /)
14801497

14811498
Execute the SQL statements in *sql_script*.
@@ -1971,7 +1988,7 @@ question marks (qmark style) or named placeholders (named style).
19711988
For the qmark style, *parameters* must be a
19721989
:term:`sequence` whose length must match the number of placeholders,
19731990
or a :exc:`ProgrammingError` is raised.
1974-
For the named style, *parameters* should be
1991+
For the named style, *parameters* must be
19751992
an instance of a :class:`dict` (or a subclass),
19761993
which must contain keys for all named parameters;
19771994
any extra items are ignored.

Doc/library/zoneinfo.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ The following class methods are also available:
241241
.. warning::
242242

243243
Invoking this function may change the semantics of datetimes using
244-
``ZoneInfo`` in surprising ways; this modifies process-wide global state
244+
``ZoneInfo`` in surprising ways; this modifies module state
245245
and thus may have wide-ranging effects. Only use it if you know that you
246246
need to.
247247

Doc/whatsnew/3.12.rst

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -415,6 +415,13 @@ Deprecated
415415
and tailor them to your needs.
416416
(Contributed by Erlend E. Aasland in :gh:`90016`.)
417417

418+
* In :meth:`~sqlite3.Cursor.execute`, :exc:`DeprecationWarning` is now emitted
419+
when :ref:`named placeholders <sqlite3-placeholders>` are used together with
420+
parameters supplied as a :term:`sequence` instead of as a :class:`dict`.
421+
Starting from Python 3.14, using named placeholders with parameters supplied
422+
as a sequence will raise a :exc:`~sqlite3.ProgrammingError`.
423+
(Contributed by Erlend E. Aasland in :gh:`101698`.)
424+
418425
* The 3-arg signatures (type, value, traceback) of :meth:`~coroutine.throw`,
419426
:meth:`~generator.throw` and :meth:`~agen.athrow` are deprecated and
420427
may be removed in a future version of Python. Use the single-arg versions

Include/internal/pycore_global_objects_fini_generated.h

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Include/internal/pycore_global_strings.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ struct _Py_global_strings {
6363
STRUCT_FOR_ID(True)
6464
STRUCT_FOR_ID(WarningMessage)
6565
STRUCT_FOR_ID(_)
66+
STRUCT_FOR_ID(_WindowsConsoleIO)
6667
STRUCT_FOR_ID(__IOBase_closed)
6768
STRUCT_FOR_ID(__abc_tpflags__)
6869
STRUCT_FOR_ID(__abs__)
@@ -238,6 +239,7 @@ struct _Py_global_strings {
238239
STRUCT_FOR_ID(_get_sourcefile)
239240
STRUCT_FOR_ID(_handle_fromlist)
240241
STRUCT_FOR_ID(_initializing)
242+
STRUCT_FOR_ID(_io)
241243
STRUCT_FOR_ID(_is_text_encoding)
242244
STRUCT_FOR_ID(_length_)
243245
STRUCT_FOR_ID(_limbo)

Include/internal/pycore_import.h

Lines changed: 105 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,112 @@ struct _import_runtime_state {
3636
const char * pkgcontext;
3737
};
3838

39+
struct _import_state {
40+
/* cached sys.modules dictionary */
41+
PyObject *modules;
42+
/* This is the list of module objects for all legacy (single-phase init)
43+
extension modules ever loaded in this process (i.e. imported
44+
in this interpreter or in any other). Py_None stands in for
45+
modules that haven't actually been imported in this interpreter.
46+
47+
A module's index (PyModuleDef.m_base.m_index) is used to look up
48+
the corresponding module object for this interpreter, if any.
49+
(See PyState_FindModule().) When any extension module
50+
is initialized during import, its moduledef gets initialized by
51+
PyModuleDef_Init(), and the first time that happens for each
52+
PyModuleDef, its index gets set to the current value of
53+
a global counter (see _PyRuntimeState.imports.last_module_index).
54+
The entry for that index in this interpreter remains unset until
55+
the module is actually imported here. (Py_None is used as
56+
a placeholder.) Note that multi-phase init modules always get
57+
an index for which there will never be a module set.
58+
59+
This is initialized lazily in PyState_AddModule(), which is also
60+
where modules get added. */
61+
PyObject *modules_by_index;
62+
/* importlib module._bootstrap */
63+
PyObject *importlib;
64+
/* override for config->use_frozen_modules (for tests)
65+
(-1: "off", 1: "on", 0: no override) */
66+
int override_frozen_modules;
67+
#ifdef HAVE_DLOPEN
68+
int dlopenflags;
69+
#endif
70+
PyObject *import_func;
71+
};
72+
73+
#ifdef HAVE_DLOPEN
74+
# include <dlfcn.h>
75+
# if HAVE_DECL_RTLD_NOW
76+
# define _Py_DLOPEN_FLAGS RTLD_NOW
77+
# else
78+
# define _Py_DLOPEN_FLAGS RTLD_LAZY
79+
# endif
80+
# define DLOPENFLAGS_INIT .dlopenflags = _Py_DLOPEN_FLAGS,
81+
#else
82+
# define _Py_DLOPEN_FLAGS 0
83+
# define DLOPENFLAGS_INIT
84+
#endif
85+
86+
#define IMPORTS_INIT \
87+
{ \
88+
.override_frozen_modules = 0, \
89+
DLOPENFLAGS_INIT \
90+
}
91+
92+
extern void _PyImport_ClearCore(PyInterpreterState *interp);
93+
94+
extern Py_ssize_t _PyImport_GetNextModuleIndex(void);
95+
extern const char * _PyImport_ResolveNameWithPackageContext(const char *name);
96+
extern const char * _PyImport_SwapPackageContext(const char *newcontext);
97+
98+
extern int _PyImport_GetDLOpenFlags(PyInterpreterState *interp);
99+
extern void _PyImport_SetDLOpenFlags(PyInterpreterState *interp, int new_val);
100+
101+
extern PyObject * _PyImport_InitModules(PyInterpreterState *interp);
102+
extern PyObject * _PyImport_GetModules(PyInterpreterState *interp);
103+
extern void _PyImport_ClearModules(PyInterpreterState *interp);
104+
105+
extern void _PyImport_ClearModulesByIndex(PyInterpreterState *interp);
106+
107+
extern int _PyImport_InitDefaultImportFunc(PyInterpreterState *interp);
108+
extern int _PyImport_IsDefaultImportFunc(
109+
PyInterpreterState *interp,
110+
PyObject *func);
111+
112+
extern PyObject * _PyImport_GetImportlibLoader(
113+
PyInterpreterState *interp,
114+
const char *loader_name);
115+
extern PyObject * _PyImport_GetImportlibExternalLoader(
116+
PyInterpreterState *interp,
117+
const char *loader_name);
118+
extern PyObject * _PyImport_BlessMyLoader(
119+
PyInterpreterState *interp,
120+
PyObject *module_globals);
121+
extern PyObject * _PyImport_ImportlibModuleRepr(
122+
PyInterpreterState *interp,
123+
PyObject *module);
124+
125+
126+
extern PyStatus _PyImport_Init(void);
127+
extern void _PyImport_Fini(void);
128+
extern void _PyImport_Fini2(void);
129+
130+
extern PyStatus _PyImport_InitCore(
131+
PyThreadState *tstate,
132+
PyObject *sysmod,
133+
int importlib);
134+
extern PyStatus _PyImport_InitExternal(PyThreadState *tstate);
135+
extern void _PyImport_FiniCore(PyInterpreterState *interp);
136+
extern void _PyImport_FiniExternal(PyInterpreterState *interp);
137+
39138

40139
#ifdef HAVE_FORK
41140
extern PyStatus _PyImport_ReInitLock(void);
42141
#endif
43-
extern PyObject* _PyImport_BootstrapImp(PyThreadState *tstate);
142+
143+
144+
extern PyObject* _PyImport_GetBuiltinModuleNames(void);
44145

45146
struct _module_alias {
46147
const char *name; /* ASCII encoded string */
@@ -52,6 +153,9 @@ PyAPI_DATA(const struct _frozen *) _PyImport_FrozenStdlib;
52153
PyAPI_DATA(const struct _frozen *) _PyImport_FrozenTest;
53154
extern const struct _module_alias * _PyImport_FrozenAliases;
54155

156+
// for testing
157+
PyAPI_FUNC(int) _PyImport_ClearExtension(PyObject *name, PyObject *filename);
158+
55159
#ifdef __cplusplus
56160
}
57161
#endif

Include/internal/pycore_interp.h

Lines changed: 3 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ extern "C" {
2121
#include "pycore_function.h" // FUNC_MAX_WATCHERS
2222
#include "pycore_genobject.h" // struct _Py_async_gen_state
2323
#include "pycore_gc.h" // struct _gc_runtime_state
24+
#include "pycore_import.h" // struct _import_state
2425
#include "pycore_list.h" // struct _Py_list_state
2526
#include "pycore_global_objects.h" // struct _Py_interp_static_objects
2627
#include "pycore_tuple.h" // struct _Py_tuple_state
@@ -92,53 +93,24 @@ struct _is {
9293
struct _ceval_state ceval;
9394
struct _gc_runtime_state gc;
9495

95-
// sys.modules dictionary
96-
PyObject *modules;
97-
/* This is the list of module objects for all legacy (single-phase init)
98-
extension modules ever loaded in this process (i.e. imported
99-
in this interpreter or in any other). Py_None stands in for
100-
modules that haven't actually been imported in this interpreter.
101-
102-
A module's index (PyModuleDef.m_base.m_index) is used to look up
103-
the corresponding module object for this interpreter, if any.
104-
(See PyState_FindModule().) When any extension module
105-
is initialized during import, its moduledef gets initialized by
106-
PyModuleDef_Init(), and the first time that happens for each
107-
PyModuleDef, its index gets set to the current value of
108-
a global counter (see _PyRuntimeState.imports.last_module_index).
109-
The entry for that index in this interpreter remains unset until
110-
the module is actually imported here. (Py_None is used as
111-
a placeholder.) Note that multi-phase init modules always get
112-
an index for which there will never be a module set.
113-
114-
This is initialized lazily in _PyState_AddModule(), which is also
115-
where modules get added. */
116-
PyObject *modules_by_index;
96+
struct _import_state imports;
97+
11798
// Dictionary of the sys module
11899
PyObject *sysdict;
119100
// Dictionary of the builtins module
120101
PyObject *builtins;
121-
// importlib module
122-
PyObject *importlib;
123-
// override for config->use_frozen_modules (for tests)
124-
// (-1: "off", 1: "on", 0: no override)
125-
int override_frozen_modules;
126102

127103
PyObject *codec_search_path;
128104
PyObject *codec_search_cache;
129105
PyObject *codec_error_registry;
130106
int codecs_initialized;
131107

132108
PyConfig config;
133-
#ifdef HAVE_DLOPEN
134-
int dlopenflags;
135-
#endif
136109
unsigned long feature_flags;
137110

138111
PyObject *dict; /* Stores per-interpreter state */
139112

140113
PyObject *builtins_copy;
141-
PyObject *import_func;
142114
// Initialized to _PyEval_EvalFrameDefault().
143115
_PyFrameEvalFunction eval_frame;
144116

@@ -205,7 +177,6 @@ struct _is {
205177

206178
/* other API */
207179

208-
extern void _PyInterpreterState_ClearModules(PyInterpreterState *interp);
209180
extern void _PyInterpreterState_Clear(PyThreadState *tstate);
210181

211182

Include/internal/pycore_pylifecycle.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ PyAPI_FUNC(int) _Py_IsLocaleCoercionTarget(const char *ctype_loc);
3030
/* Various one-time initializers */
3131

3232
extern void _Py_InitVersion(void);
33-
extern PyStatus _PyImport_Init(void);
3433
extern PyStatus _PyFaulthandler_Init(int enable);
3534
extern int _PyTraceMalloc_Init(int enable);
3635
extern PyObject * _PyBuiltin_Init(PyInterpreterState *interp);
@@ -45,7 +44,6 @@ extern int _PyBuiltins_AddExceptions(PyObject * bltinmod);
4544
extern PyStatus _Py_HashRandomization_Init(const PyConfig *);
4645

4746
extern PyStatus _PyTime_Init(void);
48-
extern PyStatus _PyImportZip_Init(PyThreadState *tstate);
4947
extern PyStatus _PyGC_Init(PyInterpreterState *interp);
5048
extern PyStatus _PyAtExit_Init(PyInterpreterState *interp);
5149
extern int _Py_Deepfreeze_Init(void);
@@ -55,8 +53,6 @@ extern int _Py_Deepfreeze_Init(void);
5553
extern int _PySignal_Init(int install_signal_handlers);
5654
extern void _PySignal_Fini(void);
5755

58-
extern void _PyImport_Fini(void);
59-
extern void _PyImport_Fini2(void);
6056
extern void _PyGC_Fini(PyInterpreterState *interp);
6157
extern void _Py_HashRandomization_Fini(void);
6258
extern void _PyFaulthandler_Fini(void);

Include/internal/pycore_pystate.h

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -152,12 +152,6 @@ extern void _PySignal_AfterFork(void);
152152
#endif
153153

154154

155-
PyAPI_FUNC(int) _PyState_AddModule(
156-
PyThreadState *tstate,
157-
PyObject* module,
158-
PyModuleDef* def);
159-
160-
161155
PyAPI_FUNC(int) _PyOS_InterruptOccurred(PyThreadState *tstate);
162156

163157
#define HEAD_LOCK(runtime) \

Include/internal/pycore_runtime_init.h

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -97,23 +97,10 @@ extern "C" {
9797
._main_interpreter = _PyInterpreterState_INIT, \
9898
}
9999

100-
#ifdef HAVE_DLOPEN
101-
# include <dlfcn.h>
102-
# if HAVE_DECL_RTLD_NOW
103-
# define _Py_DLOPEN_FLAGS RTLD_NOW
104-
# else
105-
# define _Py_DLOPEN_FLAGS RTLD_LAZY
106-
# endif
107-
# define DLOPENFLAGS_INIT .dlopenflags = _Py_DLOPEN_FLAGS,
108-
#else
109-
# define _Py_DLOPEN_FLAGS 0
110-
# define DLOPENFLAGS_INIT
111-
#endif
112-
113100
#define _PyInterpreterState_INIT \
114101
{ \
115102
.id_refcount = -1, \
116-
DLOPENFLAGS_INIT \
103+
.imports = IMPORTS_INIT, \
117104
.ceval = { \
118105
.recursion_limit = Py_DEFAULT_RECURSION_LIMIT, \
119106
}, \

Include/internal/pycore_runtime_init_generated.h

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Include/internal/pycore_sysmodule.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@ extern void _PySys_ClearAuditHooks(PyThreadState *tstate);
2020

2121
PyAPI_FUNC(int) _PySys_SetAttr(PyObject *, PyObject *);
2222

23+
extern int _PySys_ClearAttrString(PyInterpreterState *interp,
24+
const char *name, int verbose);
25+
2326
#ifdef __cplusplus
2427
}
2528
#endif

Include/internal/pycore_unicodeobject_generated.h

Lines changed: 4 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)