Skip to content

Commit 28ba5d9

Browse files
committed
Merge remote-tracking branch 'upstream/main' into reduce_dependencty_on_compiler
2 parents 482742a + ab0e601 commit 28ba5d9

File tree

94 files changed

+1027
-380
lines changed

Some content is hidden

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

94 files changed

+1027
-380
lines changed

.github/CODEOWNERS

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,8 @@ Python/pythonrun.c @iritkatriel
6060
# bytecode.
6161
**/*import*.c @brettcannon @encukou @ericsnowcurrently @ncoghlan @warsaw
6262
**/*import*.py @brettcannon @encukou @ericsnowcurrently @ncoghlan @warsaw
63+
**/importlib/resources/* @jaraco @warsaw @brettcannon
64+
**/importlib/metadata/* @jaraco @warsaw
6365

6466
# Dates and times
6567
**/*datetime* @pganssle @abalkin

Doc/library/cgi.rst

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,12 @@
1919
The :mod:`cgi` module is deprecated
2020
(see :pep:`PEP 594 <594#cgi>` for details and alternatives).
2121

22+
The :class:`FieldStorage` class can typically be replaced with
23+
:func:`urllib.parse.parse_qsl` for ``GET`` and ``HEAD`` requests,
24+
and the :mod:`email.message` module or
25+
`multipart <https://pypi.org/project/multipart/>`_ for ``POST`` and ``PUT``.
26+
Most :ref:`utility functions <functions-in-cgi-module>` have replacements.
27+
2228
--------------
2329

2430
Support module for Common Gateway Interface (CGI) scripts.
@@ -293,6 +299,12 @@ algorithms implemented in this module in other circumstances.
293299
``sys.stdin``). The *keep_blank_values*, *strict_parsing* and *separator* parameters are
294300
passed to :func:`urllib.parse.parse_qs` unchanged.
295301

302+
.. deprecated-removed:: 3.11 3.13
303+
This function, like the rest of the :mod:`cgi` module, is deprecated.
304+
It can be replaced by calling :func:`urllib.parse.parse_qs` directly
305+
on the desired query string (except for ``multipart/form-data`` input,
306+
which can be handled as described for :func:`parse_multipart`).
307+
296308

297309
.. function:: parse_multipart(fp, pdict, encoding="utf-8", errors="replace", separator="&")
298310

@@ -316,12 +328,31 @@ algorithms implemented in this module in other circumstances.
316328
.. versionchanged:: 3.10
317329
Added the *separator* parameter.
318330

331+
.. deprecated-removed:: 3.11 3.13
332+
This function, like the rest of the :mod:`cgi` module, is deprecated.
333+
It can be replaced with the functionality in the :mod:`email` package
334+
(e.g. :class:`email.message.EmailMessage`/:class:`email.message.Message`)
335+
which implements the same MIME RFCs, or with the
336+
`multipart <https://pypi.org/project/multipart/>`__ PyPI project.
337+
319338

320339
.. function:: parse_header(string)
321340

322341
Parse a MIME header (such as :mailheader:`Content-Type`) into a main value and a
323342
dictionary of parameters.
324343

344+
.. deprecated-removed:: 3.11 3.13
345+
This function, like the rest of the :mod:`cgi` module, is deprecated.
346+
It can be replaced with the functionality in the :mod:`email` package,
347+
which implements the same MIME RFCs.
348+
349+
For example, with :class:`email.message.EmailMessage`::
350+
351+
from email.message import EmailMessage
352+
msg = EmailMessage()
353+
msg['content-type'] = 'application/json; charset="utf8"'
354+
main, params = msg.get_content_type(), msg['content-type'].params
355+
325356

326357
.. function:: test()
327358

Doc/library/sqlite3.rst

Lines changed: 26 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -423,21 +423,20 @@ Connection Objects
423423

424424
.. method:: commit()
425425

426-
This method commits the current transaction. If you don't call this method,
427-
anything you did since the last call to ``commit()`` is not visible from
428-
other database connections. If you wonder why you don't see the data you've
429-
written to the database, please check you didn't forget to call this method.
426+
Commit any pending transaction to the database.
427+
If there is no open transaction, this method is a no-op.
430428

431429
.. method:: rollback()
432430

433-
This method rolls back any changes to the database since the last call to
434-
:meth:`commit`.
431+
Roll back to the start of any pending transaction.
432+
If there is no open transaction, this method is a no-op.
435433

436434
.. method:: close()
437435

438-
This closes the database connection. Note that this does not automatically
439-
call :meth:`commit`. If you just close your database connection without
440-
calling :meth:`commit` first, your changes will be lost!
436+
Close the database connection.
437+
Any pending transaction is not committed implicitly;
438+
make sure to :meth:`commit` before closing
439+
to avoid losing pending changes.
441440

442441
.. method:: execute(sql[, parameters])
443442

@@ -1431,13 +1430,27 @@ case-insensitively by name:
14311430
.. literalinclude:: ../includes/sqlite3/rowclass.py
14321431

14331432

1433+
.. _sqlite3-connection-context-manager:
1434+
14341435
Using the connection as a context manager
14351436
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
14361437

1437-
Connection objects can be used as context managers
1438-
that automatically commit or rollback transactions. In the event of an
1439-
exception, the transaction is rolled back; otherwise, the transaction is
1440-
committed:
1438+
A :class:`Connection` object can be used as a context manager that
1439+
automatically commits or rolls back open transactions when leaving the body of
1440+
the context manager.
1441+
If the body of the :keyword:`with` statement finishes without exceptions,
1442+
the transaction is committed.
1443+
If this commit fails,
1444+
or if the body of the ``with`` statement raises an uncaught exception,
1445+
the transaction is rolled back.
1446+
1447+
If there is no open transaction upon leaving the body of the ``with`` statement,
1448+
the context manager is a no-op.
1449+
1450+
.. note::
1451+
1452+
The context manager neither implicitly opens a new transaction
1453+
nor closes the connection.
14411454

14421455
.. literalinclude:: ../includes/sqlite3/ctx_manager.py
14431456

Doc/whatsnew/3.10.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1746,7 +1746,7 @@ Deprecated
17461746
17471747
* ``threading.Thread.setDaemon`` => :attr:`threading.Thread.daemon`
17481748
1749-
(Contributed by Jelle Zijlstra in :issue:`21574`.)
1749+
(Contributed by Jelle Zijlstra in :gh:`87889`.)
17501750
17511751
* :meth:`pathlib.Path.link_to` is deprecated and slated for removal in
17521752
Python 3.12. Use :meth:`pathlib.Path.hardlink_to` instead.

Doc/whatsnew/3.11.rst

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1752,6 +1752,21 @@ Porting to Python 3.11
17521752
which are not available in the limited C API.
17531753
(Contributed by Victor Stinner in :issue:`46007`.)
17541754

1755+
* The following frame functions and type are now directly available with
1756+
``#include <Python.h>``, it's no longer needed to add
1757+
``#include <frameobject.h>``:
1758+
1759+
* :c:func:`PyFrame_Check`
1760+
* :c:func:`PyFrame_GetBack`
1761+
* :c:func:`PyFrame_GetBuiltins`
1762+
* :c:func:`PyFrame_GetGenerator`
1763+
* :c:func:`PyFrame_GetGlobals`
1764+
* :c:func:`PyFrame_GetLasti`
1765+
* :c:func:`PyFrame_GetLocals`
1766+
* :c:type:`PyFrame_Type`
1767+
1768+
(Contributed by Victor Stinner in :gh:`93937`.)
1769+
17551770
.. _pyframeobject-3.11-hiding:
17561771

17571772
* The :c:type:`PyFrameObject` structure members have been removed from the
@@ -1888,7 +1903,6 @@ Porting to Python 3.11
18881903
paths and then modify them, finish initialization and use :c:func:`PySys_GetObject`
18891904
to retrieve :data:`sys.path` as a Python list object and modify it directly.
18901905

1891-
18921906
Deprecated
18931907
----------
18941908

Doc/whatsnew/3.12.rst

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -257,6 +257,35 @@ Porting to Python 3.12
257257
Deprecated
258258
----------
259259

260+
* Deprecate global configuration variable:
261+
262+
* :c:var:`Py_DebugFlag`: use :c:member:`PyConfig.parser_debug`
263+
* :c:var:`Py_VerboseFlag`: use :c:member:`PyConfig.verbose`
264+
* :c:var:`Py_QuietFlag`: use :c:member:`PyConfig.quiet`
265+
* :c:var:`Py_InteractiveFlag`: use :c:member:`PyConfig.interactive`
266+
* :c:var:`Py_InspectFlag`: use :c:member:`PyConfig.inspect`
267+
* :c:var:`Py_OptimizeFlag`: use :c:member:`PyConfig.optimization_level`
268+
* :c:var:`Py_NoSiteFlag`: use :c:member:`PyConfig.site_import`
269+
* :c:var:`Py_BytesWarningFlag`: use :c:member:`PyConfig.bytes_warning`
270+
* :c:var:`Py_FrozenFlag`: use :c:member:`PyConfig.pathconfig_warnings`
271+
* :c:var:`Py_IgnoreEnvironmentFlag`: use :c:member:`PyConfig.use_environment`
272+
* :c:var:`Py_DontWriteBytecodeFlag`: use :c:member:`PyConfig.write_bytecode`
273+
* :c:var:`Py_NoUserSiteDirectory`: use :c:member:`PyConfig.user_site_directory`
274+
* :c:var:`Py_UnbufferedStdioFlag`: use :c:member:`PyConfig.buffered_stdio`
275+
* :c:var:`Py_HashRandomizationFlag`: use :c:member:`PyConfig.use_hash_seed`
276+
and :c:member:`PyConfig.hash_seed`
277+
* :c:var:`Py_IsolatedFlag`: use :c:member:`PyConfig.isolated`
278+
* :c:var:`Py_LegacyWindowsFSEncodingFlag`: use :c:member:`PyConfig.legacy_windows_fs_encoding`
279+
* :c:var:`Py_LegacyWindowsStdioFlag`: use :c:member:`PyConfig.legacy_windows_stdio`
280+
* :c:var:`Py_FileSystemDefaultEncoding`: use :c:member:`PyConfig.filesystem_encoding`
281+
* :c:var:`Py_FileSystemDefaultEncodeErrors`: use :c:member:`PyConfig.filesystem_errors`
282+
* :c:var:`Py_UTF8Mode`: use :c:member:`PyPreConfig.utf8_mode` (see :c:func:`Py_PreInitialize`)
283+
284+
The :c:func:`Py_InitializeFromConfig` API should be used with
285+
:c:type:`PyConfig` instead.
286+
(Contributed by Victor Stinner in :gh:`77782`.)
287+
288+
260289
Removed
261290
-------
262291

Include/cpython/code.h

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,8 @@ typedef uint16_t _Py_CODEUNIT;
6262
PyObject *co_exceptiontable; /* Byte string encoding exception handling \
6363
table */ \
6464
int co_flags; /* CO_..., see below */ \
65-
int co_warmup; /* Warmup counter for quickening */ \
65+
short co_warmup; /* Warmup counter for quickening */ \
66+
short _co_linearray_entry_size; /* Size of each entry in _co_linearray */ \
6667
\
6768
/* The rest are not so impactful on performance. */ \
6869
int co_argcount; /* #arguments, except *args */ \
@@ -73,8 +74,8 @@ typedef uint16_t _Py_CODEUNIT;
7374
\
7475
/* redundant values (derived from co_localsplusnames and \
7576
co_localspluskinds) */ \
76-
int co_nlocalsplus; /* number of local + cell + free variables \
77-
*/ \
77+
int co_nlocalsplus; /* number of local + cell + free variables */ \
78+
int co_framesize; /* Size of frame in words */ \
7879
int co_nlocals; /* number of local variables */ \
7980
int co_nplaincellvars; /* number of non-arg cell variables */ \
8081
int co_ncellvars; /* total number of cell variables */ \
@@ -90,6 +91,7 @@ typedef uint16_t _Py_CODEUNIT;
9091
PyObject *co_weakreflist; /* to support weakrefs to code objects */ \
9192
void *_co_code; /* cached co_code object/attribute */ \
9293
int _co_firsttraceable; /* index of first traceable instruction */ \
94+
char *_co_linearray; /* array of line offsets */ \
9395
/* Scratch space for extra data relating to the code object. \
9496
Type is a void* to keep the format private in codeobject.c to force \
9597
people to go through the proper APIs. */ \

Include/cpython/frameobject.h

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,6 @@
66

77
/* Standard object interface */
88

9-
PyAPI_DATA(PyTypeObject) PyFrame_Type;
10-
11-
#define PyFrame_Check(op) Py_IS_TYPE((op), &PyFrame_Type)
12-
139
PyAPI_FUNC(PyFrameObject *) PyFrame_New(PyThreadState *, PyCodeObject *,
1410
PyObject *, PyObject *);
1511

@@ -31,12 +27,3 @@ PyAPI_FUNC(int) _PyFrame_IsEntryFrame(PyFrameObject *frame);
3127

3228
PyAPI_FUNC(int) PyFrame_FastToLocalsWithError(PyFrameObject *f);
3329
PyAPI_FUNC(void) PyFrame_FastToLocals(PyFrameObject *);
34-
35-
PyAPI_FUNC(PyFrameObject *) PyFrame_GetBack(PyFrameObject *frame);
36-
PyAPI_FUNC(PyObject *) PyFrame_GetLocals(PyFrameObject *frame);
37-
38-
PyAPI_FUNC(PyObject *) PyFrame_GetGlobals(PyFrameObject *frame);
39-
PyAPI_FUNC(PyObject *) PyFrame_GetBuiltins(PyFrameObject *frame);
40-
41-
PyAPI_FUNC(PyObject *) PyFrame_GetGenerator(PyFrameObject *frame);
42-
PyAPI_FUNC(int) PyFrame_GetLasti(PyFrameObject *frame);

Include/cpython/pydebug.h

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -5,31 +5,31 @@
55
extern "C" {
66
#endif
77

8-
PyAPI_DATA(int) Py_DebugFlag;
9-
PyAPI_DATA(int) Py_VerboseFlag;
10-
PyAPI_DATA(int) Py_QuietFlag;
11-
PyAPI_DATA(int) Py_InteractiveFlag;
12-
PyAPI_DATA(int) Py_InspectFlag;
13-
PyAPI_DATA(int) Py_OptimizeFlag;
14-
PyAPI_DATA(int) Py_NoSiteFlag;
15-
PyAPI_DATA(int) Py_BytesWarningFlag;
16-
PyAPI_DATA(int) Py_FrozenFlag;
17-
PyAPI_DATA(int) Py_IgnoreEnvironmentFlag;
18-
PyAPI_DATA(int) Py_DontWriteBytecodeFlag;
19-
PyAPI_DATA(int) Py_NoUserSiteDirectory;
20-
PyAPI_DATA(int) Py_UnbufferedStdioFlag;
21-
PyAPI_DATA(int) Py_HashRandomizationFlag;
22-
PyAPI_DATA(int) Py_IsolatedFlag;
8+
Py_DEPRECATED(3.12) PyAPI_DATA(int) Py_DebugFlag;
9+
Py_DEPRECATED(3.12) PyAPI_DATA(int) Py_VerboseFlag;
10+
Py_DEPRECATED(3.12) PyAPI_DATA(int) Py_QuietFlag;
11+
Py_DEPRECATED(3.12) PyAPI_DATA(int) Py_InteractiveFlag;
12+
Py_DEPRECATED(3.12) PyAPI_DATA(int) Py_InspectFlag;
13+
Py_DEPRECATED(3.12) PyAPI_DATA(int) Py_OptimizeFlag;
14+
Py_DEPRECATED(3.12) PyAPI_DATA(int) Py_NoSiteFlag;
15+
Py_DEPRECATED(3.12) PyAPI_DATA(int) Py_BytesWarningFlag;
16+
Py_DEPRECATED(3.12) PyAPI_DATA(int) Py_FrozenFlag;
17+
Py_DEPRECATED(3.12) PyAPI_DATA(int) Py_IgnoreEnvironmentFlag;
18+
Py_DEPRECATED(3.12) PyAPI_DATA(int) Py_DontWriteBytecodeFlag;
19+
Py_DEPRECATED(3.12) PyAPI_DATA(int) Py_NoUserSiteDirectory;
20+
Py_DEPRECATED(3.12) PyAPI_DATA(int) Py_UnbufferedStdioFlag;
21+
Py_DEPRECATED(3.12) PyAPI_DATA(int) Py_HashRandomizationFlag;
22+
Py_DEPRECATED(3.12) PyAPI_DATA(int) Py_IsolatedFlag;
2323

2424
#ifdef MS_WINDOWS
25-
PyAPI_DATA(int) Py_LegacyWindowsFSEncodingFlag;
26-
PyAPI_DATA(int) Py_LegacyWindowsStdioFlag;
25+
Py_DEPRECATED(3.12) PyAPI_DATA(int) Py_LegacyWindowsFSEncodingFlag;
26+
Py_DEPRECATED(3.12) PyAPI_DATA(int) Py_LegacyWindowsStdioFlag;
2727
#endif
2828

2929
/* this is a wrapper around getenv() that pays attention to
3030
Py_IgnoreEnvironmentFlag. It should be used for getting variables like
3131
PYTHONPATH and PYTHONHOME from the environment */
32-
PyAPI_DATA(char*) Py_GETENV(const char *name);
32+
PyAPI_FUNC(char*) Py_GETENV(const char *name);
3333

3434
#ifdef __cplusplus
3535
}

Include/cpython/pyframe.h

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#ifndef Py_CPYTHON_PYFRAME_H
2+
# error "this header file must not be included directly"
3+
#endif
4+
5+
PyAPI_DATA(PyTypeObject) PyFrame_Type;
6+
7+
#define PyFrame_Check(op) Py_IS_TYPE((op), &PyFrame_Type)
8+
9+
PyAPI_FUNC(PyFrameObject *) PyFrame_GetBack(PyFrameObject *frame);
10+
PyAPI_FUNC(PyObject *) PyFrame_GetLocals(PyFrameObject *frame);
11+
12+
PyAPI_FUNC(PyObject *) PyFrame_GetGlobals(PyFrameObject *frame);
13+
PyAPI_FUNC(PyObject *) PyFrame_GetBuiltins(PyFrameObject *frame);
14+
15+
PyAPI_FUNC(PyObject *) PyFrame_GetGenerator(PyFrameObject *frame);
16+
PyAPI_FUNC(int) PyFrame_GetLasti(PyFrameObject *frame);
17+

Include/cpython/pystate.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,10 @@ PyAPI_FUNC(const PyConfig*) _PyInterpreterState_GetConfig(PyInterpreterState *in
279279
for example.
280280
281281
Python must be preinitialized to call this method.
282-
The caller must hold the GIL. */
282+
The caller must hold the GIL.
283+
284+
Once done with the configuration, PyConfig_Clear() must be called to clear
285+
it. */
283286
PyAPI_FUNC(int) _PyInterpreterState_GetConfigCopy(
284287
struct PyConfig *config);
285288

Include/cpython/pytime.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,10 @@ PyAPI_FUNC(_PyTime_t) _PyTime_FromSeconds(int seconds);
130130
/* Create a timestamp from a number of nanoseconds. */
131131
PyAPI_FUNC(_PyTime_t) _PyTime_FromNanoseconds(_PyTime_t ns);
132132

133+
/* Create a timestamp from a number of microseconds.
134+
* Clamp to [_PyTime_MIN; _PyTime_MAX] on overflow. */
135+
PyAPI_FUNC(_PyTime_t) _PyTime_FromMicrosecondsClamp(_PyTime_t us);
136+
133137
/* Create a timestamp from nanoseconds (Python int). */
134138
PyAPI_FUNC(int) _PyTime_FromNanosecondsObject(_PyTime_t *t,
135139
PyObject *obj);

Include/fileobject.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,14 @@ PyAPI_FUNC(int) PyObject_AsFileDescriptor(PyObject *);
1919
/* The default encoding used by the platform file system APIs
2020
If non-NULL, this is different than the default encoding for strings
2121
*/
22-
PyAPI_DATA(const char *) Py_FileSystemDefaultEncoding;
22+
Py_DEPRECATED(3.12) PyAPI_DATA(const char *) Py_FileSystemDefaultEncoding;
2323
#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x03060000
24-
PyAPI_DATA(const char *) Py_FileSystemDefaultEncodeErrors;
24+
Py_DEPRECATED(3.12) PyAPI_DATA(const char *) Py_FileSystemDefaultEncodeErrors;
2525
#endif
2626
PyAPI_DATA(int) Py_HasFileSystemDefaultEncoding;
2727

2828
#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x03070000
29-
PyAPI_DATA(int) Py_UTF8Mode;
29+
Py_DEPRECATED(3.12) PyAPI_DATA(int) Py_UTF8Mode;
3030
#endif
3131

3232
/* A routine to check if a file descriptor can be select()-ed. */

0 commit comments

Comments
 (0)