Skip to content

Commit f69d2b7

Browse files
committed
Merge branch 'main' of https://github.com/python/cpython
2 parents dae60d0 + ddf66b5 commit f69d2b7

File tree

255 files changed

+4058
-3582
lines changed

Some content is hidden

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

255 files changed

+4058
-3582
lines changed

.github/workflows/mypy.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ on:
99
paths:
1010
- "Tools/clinic/**"
1111
- "Tools/cases_generator/**"
12+
- "Tools/requirements-dev.txt"
1213
- ".github/workflows/mypy.yml"
1314
workflow_dispatch:
1415

Doc/c-api/dict.rst

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,15 @@ Dictionary Objects
5555
This is equivalent to the Python expression ``key in p``.
5656
5757
58+
.. c:function:: int PyDict_ContainsString(PyObject *p, const char *key)
59+
60+
This is the same as :c:func:`PyDict_Contains`, but *key* is specified as a
61+
:c:expr:`const char*` UTF-8 encoded bytes string, rather than a
62+
:c:expr:`PyObject*`.
63+
64+
.. versionadded:: 3.13
65+
66+
5867
.. c:function:: PyObject* PyDict_Copy(PyObject *p)
5968
6069
Return a new dictionary that contains the same key-value pairs as *p*.
@@ -73,7 +82,7 @@ Dictionary Objects
7382
.. index:: single: PyUnicode_FromString()
7483
7584
Insert *val* into the dictionary *p* using *key* as a key. *key* should
76-
be a :c:expr:`const char*`. The key object is created using
85+
be a :c:expr:`const char*` UTF-8 encoded bytes string. The key object is created using
7786
``PyUnicode_FromString(key)``. Return ``0`` on success or ``-1`` on
7887
failure. This function *does not* steal a reference to *val*.
7988
@@ -88,7 +97,8 @@ Dictionary Objects
8897
8998
.. c:function:: int PyDict_DelItemString(PyObject *p, const char *key)
9099
91-
Remove the entry in dictionary *p* which has a key specified by the string *key*.
100+
Remove the entry in dictionary *p* which has a key specified by the UTF-8
101+
encoded bytes string *key*.
92102
If *key* is not in the dictionary, :exc:`KeyError` is raised.
93103
Return ``0`` on success or ``-1`` on failure.
94104
@@ -136,7 +146,8 @@ Dictionary Objects
136146
.. c:function:: PyObject* PyDict_GetItemString(PyObject *p, const char *key)
137147
138148
This is the same as :c:func:`PyDict_GetItem`, but *key* is specified as a
139-
:c:expr:`const char*`, rather than a :c:expr:`PyObject*`.
149+
:c:expr:`const char*` UTF-8 encoded bytes string, rather than a
150+
:c:expr:`PyObject*`.
140151
141152
.. note::
142153
@@ -150,7 +161,8 @@ Dictionary Objects
150161
.. c:function:: int PyDict_GetItemStringRef(PyObject *p, const char *key, PyObject **result)
151162
152163
Similar than :c:func:`PyDict_GetItemRef`, but *key* is specified as a
153-
:c:expr:`const char*`, rather than a :c:expr:`PyObject*`.
164+
:c:expr:`const char*` UTF-8 encoded bytes string, rather than a
165+
:c:expr:`PyObject*`.
154166
155167
.. versionadded:: 3.13
156168

Doc/c-api/long.rst

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,14 @@ distinguished from a number. Use :c:func:`PyErr_Occurred` to disambiguate.
136136
This function will no longer use :meth:`~object.__int__`.
137137
138138
139+
.. c:function:: int PyLong_AsInt(PyObject *obj)
140+
141+
Similar to :c:func:`PyLong_AsLong`, but store the result in a C
142+
:c:expr:`int` instead of a C :c:expr:`long`.
143+
144+
.. versionadded:: 3.13
145+
146+
139147
.. c:function:: long PyLong_AsLongAndOverflow(PyObject *obj, int *overflow)
140148
141149
Return a C :c:expr:`long` representation of *obj*. If *obj* is not an

Doc/data/stable_abi.dat

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

Doc/howto/pyporting.rst

Lines changed: 94 additions & 121 deletions
Large diffs are not rendered by default.

Doc/library/asyncio-task.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -592,7 +592,7 @@ Shielding From Cancellation
592592

593593
is equivalent to::
594594

595-
res = await something()
595+
res = await shield(something())
596596

597597
*except* that if the coroutine containing it is cancelled, the
598598
Task running in ``something()`` is not cancelled. From the point

Doc/whatsnew/3.13.rst

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -862,10 +862,21 @@ New Features
862862
not needed.
863863
(Contributed by Victor Stinner in :gh:`106004`.)
864864

865+
* Added :c:func:`PyDict_ContainsString` function: same as
866+
:c:func:`PyDict_Contains`, but *key* is specified as a :c:expr:`const char*`
867+
UTF-8 encoded bytes string, rather than a :c:expr:`PyObject*`.
868+
(Contributed by Victor Stinner in :gh:`108314`.)
869+
865870
* Add :c:func:`Py_IsFinalizing` function: check if the main Python interpreter is
866871
:term:`shutting down <interpreter shutdown>`.
867872
(Contributed by Victor Stinner in :gh:`108014`.)
868873

874+
* Add :c:func:`PyLong_AsInt` function: similar to :c:func:`PyLong_AsLong`, but
875+
store the result in a C :c:expr:`int` instead of a C :c:expr:`long`.
876+
Previously, it was known as the private function :c:func:`!_PyLong_AsInt`
877+
(with an underscore prefix).
878+
(Contributed by Victor Stinner in :gh:`108014`.)
879+
869880
Porting to Python 3.13
870881
----------------------
871882

Include/cpython/ceval.h

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,26 +4,16 @@
44

55
PyAPI_FUNC(void) PyEval_SetProfile(Py_tracefunc, PyObject *);
66
PyAPI_FUNC(void) PyEval_SetProfileAllThreads(Py_tracefunc, PyObject *);
7-
PyAPI_FUNC(int) _PyEval_SetProfile(PyThreadState *tstate, Py_tracefunc func, PyObject *arg);
87
PyAPI_FUNC(void) PyEval_SetTrace(Py_tracefunc, PyObject *);
98
PyAPI_FUNC(void) PyEval_SetTraceAllThreads(Py_tracefunc, PyObject *);
10-
PyAPI_FUNC(int) _PyEval_SetTrace(PyThreadState *tstate, Py_tracefunc func, PyObject *arg);
119

12-
/* Helper to look up a builtin object */
13-
PyAPI_FUNC(PyObject *) _PyEval_GetBuiltin(PyObject *);
14-
PyAPI_FUNC(PyObject *) _PyEval_GetBuiltinId(_Py_Identifier *);
1510
/* Look at the current frame's (if any) code's co_flags, and turn on
1611
the corresponding compiler flags in cf->cf_flags. Return 1 if any
1712
flag was set, else return 0. */
1813
PyAPI_FUNC(int) PyEval_MergeCompilerFlags(PyCompilerFlags *cf);
1914

2015
PyAPI_FUNC(PyObject *) _PyEval_EvalFrameDefault(PyThreadState *tstate, struct _PyInterpreterFrame *f, int exc);
2116

22-
PyAPI_FUNC(void) _PyEval_SetSwitchInterval(unsigned long microseconds);
23-
PyAPI_FUNC(unsigned long) _PyEval_GetSwitchInterval(void);
24-
25-
PyAPI_FUNC(int) _PyEval_MakePendingCalls(PyThreadState *);
26-
2717
PyAPI_FUNC(Py_ssize_t) PyUnstable_Eval_RequestCodeExtraIndex(freefunc);
2818
// Old name -- remove when this API changes:
2919
_Py_DEPRECATED_EXTERNALLY(3.12) static inline Py_ssize_t

Include/cpython/context.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -67,10 +67,6 @@ PyAPI_FUNC(PyObject *) PyContextVar_Set(PyObject *var, PyObject *value);
6767
PyAPI_FUNC(int) PyContextVar_Reset(PyObject *var, PyObject *token);
6868

6969

70-
/* This method is exposed only for CPython tests. Don not use it. */
71-
PyAPI_FUNC(PyObject *) _PyContext_NewHamtForTests(void);
72-
73-
7470
#ifdef __cplusplus
7571
}
7672
#endif

Include/cpython/dictobject.h

Lines changed: 1 addition & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -32,19 +32,8 @@ typedef struct {
3232
PyDictValues *ma_values;
3333
} PyDictObject;
3434

35-
PyAPI_FUNC(PyObject *) _PyDict_GetItem_KnownHash(PyObject *mp, PyObject *key,
36-
Py_hash_t hash);
37-
PyAPI_FUNC(PyObject *) _PyDict_GetItemIdWithError(PyObject *dp,
38-
_Py_Identifier *key);
3935
PyAPI_FUNC(PyObject *) PyDict_SetDefault(
4036
PyObject *mp, PyObject *key, PyObject *defaultobj);
41-
PyAPI_FUNC(int) _PyDict_SetItem_KnownHash(PyObject *mp, PyObject *key,
42-
PyObject *item, Py_hash_t hash);
43-
PyAPI_FUNC(int) _PyDict_DelItem_KnownHash(PyObject *mp, PyObject *key,
44-
Py_hash_t hash);
45-
46-
PyAPI_FUNC(int) _PyDict_Next(
47-
PyObject *mp, Py_ssize_t *pos, PyObject **key, PyObject **value, Py_hash_t *hash);
4837

4938
/* Get the number of items of a dictionary. */
5039
static inline Py_ssize_t PyDict_GET_SIZE(PyObject *op) {
@@ -55,26 +44,8 @@ static inline Py_ssize_t PyDict_GET_SIZE(PyObject *op) {
5544
}
5645
#define PyDict_GET_SIZE(op) PyDict_GET_SIZE(_PyObject_CAST(op))
5746

58-
PyAPI_FUNC(int) _PyDict_ContainsId(PyObject *, _Py_Identifier *);
59-
60-
PyAPI_FUNC(PyObject *) _PyDict_NewPresized(Py_ssize_t minused);
61-
PyAPI_FUNC(Py_ssize_t) _PyDict_SizeOf(PyDictObject *);
62-
PyAPI_FUNC(PyObject *) _PyDict_Pop(PyObject *, PyObject *, PyObject *);
63-
#define _PyDict_HasSplitTable(d) ((d)->ma_values != NULL)
64-
65-
PyAPI_FUNC(int) _PyDict_SetItemId(PyObject *dp, _Py_Identifier *key, PyObject *item);
66-
67-
PyAPI_FUNC(int) _PyDict_DelItemId(PyObject *mp, _Py_Identifier *key);
68-
69-
/* _PyDictView */
70-
71-
typedef struct {
72-
PyObject_HEAD
73-
PyDictObject *dv_dict;
74-
} _PyDictViewObject;
47+
PyAPI_FUNC(int) PyDict_ContainsString(PyObject *mp, const char *key);
7548

76-
PyAPI_FUNC(PyObject *) _PyDictView_New(PyObject *, PyTypeObject *);
77-
PyAPI_FUNC(PyObject *) _PyDictView_Intersect(PyObject* self, PyObject *other);
7849

7950
/* Dictionary watchers */
8051

0 commit comments

Comments
 (0)