Skip to content

Commit 0b1aef9

Browse files
committed
Merge branch 'main' into tstrings
2 parents 48f771b + 208d06f commit 0b1aef9

File tree

68 files changed

+2621
-904
lines changed

Some content is hidden

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

68 files changed

+2621
-904
lines changed

.github/workflows/mypy.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,10 @@ on:
88
pull_request:
99
paths:
1010
- ".github/workflows/mypy.yml"
11+
- "Lib/_colorize.py"
1112
- "Lib/_pyrepl/**"
1213
- "Lib/test/libregrtest/**"
14+
- "Misc/mypy/**"
1315
- "Tools/build/generate_sbom.py"
1416
- "Tools/cases_generator/**"
1517
- "Tools/clinic/**"

Doc/c-api/init.rst

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1517,16 +1517,6 @@ All of the following functions must be called after :c:func:`Py_Initialize`.
15171517
.. versionadded:: 3.8
15181518
15191519
1520-
.. c:function:: PyObject* PyUnstable_InterpreterState_GetMainModule(PyInterpreterState *interp)
1521-
1522-
Return a :term:`strong reference` to the ``__main__`` :ref:`module object <moduleobjects>`
1523-
for the given interpreter.
1524-
1525-
The caller must have an :term:`attached thread state`.
1526-
1527-
.. versionadded:: 3.13
1528-
1529-
15301520
.. c:type:: PyObject* (*_PyFrameEvalFunction)(PyThreadState *tstate, _PyInterpreterFrame *frame, int throwflag)
15311521
15321522
Type of a frame evaluation function.

Doc/whatsnew/3.14.rst

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1072,9 +1072,22 @@ mimetypes
10721072

10731073
* :rfc:`2361`: Change type for ``.avi`` to ``video/vnd.avi``
10741074
and for ``.wav`` to ``audio/vnd.wave``
1075-
* :rfc:`4337`: Add MPEG-4 ``audio/mp4`` (``.m4a``))
1075+
* :rfc:`4337`: Add MPEG-4 ``audio/mp4`` (``.m4a``)
10761076
* :rfc:`5334`: Add Ogg media (``.oga``, ``.ogg`` and ``.ogx``)
1077+
* :rfc:`6713`: Add gzip ``application/gzip`` (``.gz``)
10771078
* :rfc:`9639`: Add FLAC ``audio/flac`` (``.flac``)
1079+
* Add 7z ``application/x-7z-compressed`` (``.7z``)
1080+
* Add Android Package ``application/vnd.android.package-archive`` (``.apk``)
1081+
when not strict
1082+
* Add deb ``application/x-debian-package`` (``.deb``)
1083+
* Add glTF binary ``model/gltf-binary`` (``.glb``)
1084+
* Add glTF JSON/ASCII ``model/gltf+json`` (``.gltf``)
1085+
* Add M4V ``video/x-m4v`` (``.m4v``)
1086+
* Add PHP ``application/x-httpd-php`` (``.php``)
1087+
* Add RAR ``application/vnd.rar`` (``.rar``)
1088+
* Add RPM ``application/x-rpm`` (``.rpm``)
1089+
* Add STL ``model/stl`` (``.stl``)
1090+
* Add Windows Media Video ``video/x-ms-wmv`` (``.wmv``)
10781091
* De facto: Add WebM ``audio/webm`` (``.weba``)
10791092
* `ECMA-376
10801093
<https://ecma-international.org/publications-and-standards/standards/ecma-376/>`__:

Include/cpython/pystate.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@
88
PyAPI_FUNC(int) _PyInterpreterState_RequiresIDRef(PyInterpreterState *);
99
PyAPI_FUNC(void) _PyInterpreterState_RequireIDRef(PyInterpreterState *, int);
1010

11-
PyAPI_FUNC(PyObject *) PyUnstable_InterpreterState_GetMainModule(PyInterpreterState *);
12-
1311
/* State unique per thread */
1412

1513
/* Py_tracefunc return -1 when raising an exception, or 0 for success. */

Include/internal/pycore_code.h

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -177,12 +177,14 @@ typedef struct {
177177
*/
178178

179179
// Note that these all fit within a byte, as do combinations.
180-
// Later, we will use the smaller numbers to differentiate the different
181-
// kinds of locals (e.g. pos-only arg, varkwargs, local-only).
182-
#define CO_FAST_HIDDEN 0x10
183-
#define CO_FAST_LOCAL 0x20
184-
#define CO_FAST_CELL 0x40
185-
#define CO_FAST_FREE 0x80
180+
#define CO_FAST_ARG_POS (0x02) // pos-only, pos-or-kw, varargs
181+
#define CO_FAST_ARG_KW (0x04) // kw-only, pos-or-kw, varkwargs
182+
#define CO_FAST_ARG_VAR (0x08) // varargs, varkwargs
183+
#define CO_FAST_ARG (CO_FAST_ARG_POS | CO_FAST_ARG_KW | CO_FAST_ARG_VAR)
184+
#define CO_FAST_HIDDEN (0x10)
185+
#define CO_FAST_LOCAL (0x20)
186+
#define CO_FAST_CELL (0x40)
187+
#define CO_FAST_FREE (0x80)
186188

187189
typedef unsigned char _PyLocals_Kind;
188190

@@ -315,6 +317,7 @@ extern void _Py_Specialize_ForIter(_PyStackRef iter, _Py_CODEUNIT *instr, int op
315317
extern void _Py_Specialize_Send(_PyStackRef receiver, _Py_CODEUNIT *instr);
316318
extern void _Py_Specialize_ToBool(_PyStackRef value, _Py_CODEUNIT *instr);
317319
extern void _Py_Specialize_ContainsOp(_PyStackRef value, _Py_CODEUNIT *instr);
320+
extern void _Py_GatherStats_GetIter(_PyStackRef iterable);
318321

319322
// Utility functions for reading/writing 32/64-bit values in the inline caches.
320323
// Great care should be taken to ensure that these functions remain correct and
@@ -561,6 +564,10 @@ extern void _Py_ClearTLBCIndex(_PyThreadStateImpl *tstate);
561564
extern int _Py_ClearUnusedTLBC(PyInterpreterState *interp);
562565
#endif
563566

567+
568+
PyAPI_FUNC(int) _PyCode_ReturnsOnlyNone(PyCodeObject *);
569+
570+
564571
#ifdef __cplusplus
565572
}
566573
#endif

Include/internal/pycore_crossinterp.h

Lines changed: 63 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ struct _xidata {
5757
// likely a registered "xidatafunc", is responsible for
5858
// ensuring it owns the reference (i.e. incref).
5959
PyObject *obj;
60-
// interp is the ID of the owning interpreter of the original
60+
// interpid is the ID of the owning interpreter of the original
6161
// object. It corresponds to the active interpreter when
6262
// _PyObject_GetXIData() was called. This should only
6363
// be set by the cross-interpreter machinery.
@@ -93,37 +93,6 @@ PyAPI_FUNC(void) _PyXIData_Free(_PyXIData_t *data);
9393
// Users should not need getters for "new_object" or "free".
9494

9595

96-
/* getting cross-interpreter data */
97-
98-
typedef int (*xidatafunc)(PyThreadState *tstate, PyObject *, _PyXIData_t *);
99-
100-
PyAPI_FUNC(PyObject *) _PyXIData_GetNotShareableErrorType(PyThreadState *);
101-
PyAPI_FUNC(void) _PyXIData_SetNotShareableError(PyThreadState *, const char *);
102-
PyAPI_FUNC(void) _PyXIData_FormatNotShareableError(
103-
PyThreadState *,
104-
const char *,
105-
...);
106-
107-
PyAPI_FUNC(xidatafunc) _PyXIData_Lookup(
108-
PyThreadState *,
109-
PyObject *);
110-
PyAPI_FUNC(int) _PyObject_CheckXIData(
111-
PyThreadState *,
112-
PyObject *);
113-
114-
PyAPI_FUNC(int) _PyObject_GetXIData(
115-
PyThreadState *,
116-
PyObject *,
117-
_PyXIData_t *);
118-
119-
120-
/* using cross-interpreter data */
121-
122-
PyAPI_FUNC(PyObject *) _PyXIData_NewObject(_PyXIData_t *);
123-
PyAPI_FUNC(int) _PyXIData_Release(_PyXIData_t *);
124-
PyAPI_FUNC(int) _PyXIData_ReleaseAndRawFree(_PyXIData_t *);
125-
126-
12796
/* defining cross-interpreter data */
12897

12998
PyAPI_FUNC(void) _PyXIData_Init(
@@ -134,7 +103,7 @@ PyAPI_FUNC(int) _PyXIData_InitWithSize(
134103
_PyXIData_t *,
135104
PyInterpreterState *interp, const size_t, PyObject *,
136105
xid_newobjfunc);
137-
PyAPI_FUNC(void) _PyXIData_Clear( PyInterpreterState *, _PyXIData_t *);
106+
PyAPI_FUNC(void) _PyXIData_Clear(PyInterpreterState *, _PyXIData_t *);
138107

139108
// Normally the Init* functions are sufficient. The only time
140109
// additional initialization might be needed is to set the "free" func,
@@ -143,6 +112,8 @@ PyAPI_FUNC(void) _PyXIData_Clear( PyInterpreterState *, _PyXIData_t *);
143112
do { \
144113
(DATA)->free = (FUNC); \
145114
} while (0)
115+
#define _PyXIData_CHECK_FREE(DATA, FUNC) \
116+
((DATA)->free == (FUNC))
146117
// Additionally, some shareable types are essentially light wrappers
147118
// around other shareable types. The xidatafunc of the wrapper
148119
// can often be implemented by calling the wrapped object's
@@ -154,6 +125,65 @@ PyAPI_FUNC(void) _PyXIData_Clear( PyInterpreterState *, _PyXIData_t *);
154125
do { \
155126
(DATA)->new_object = (FUNC); \
156127
} while (0)
128+
#define _PyXIData_CHECK_NEW_OBJECT(DATA, FUNC) \
129+
((DATA)->new_object == (FUNC))
130+
131+
132+
/* getting cross-interpreter data */
133+
134+
typedef int (*xidatafunc)(PyThreadState *tstate, PyObject *, _PyXIData_t *);
135+
136+
PyAPI_FUNC(PyObject *) _PyXIData_GetNotShareableErrorType(PyThreadState *);
137+
PyAPI_FUNC(void) _PyXIData_SetNotShareableError(PyThreadState *, const char *);
138+
PyAPI_FUNC(void) _PyXIData_FormatNotShareableError(
139+
PyThreadState *,
140+
const char *,
141+
...);
142+
143+
PyAPI_FUNC(xidatafunc) _PyXIData_Lookup(
144+
PyThreadState *,
145+
PyObject *);
146+
PyAPI_FUNC(int) _PyObject_CheckXIData(
147+
PyThreadState *,
148+
PyObject *);
149+
150+
PyAPI_FUNC(int) _PyObject_GetXIData(
151+
PyThreadState *,
152+
PyObject *,
153+
_PyXIData_t *);
154+
155+
// _PyObject_GetXIData() for bytes
156+
typedef struct {
157+
const char *bytes;
158+
Py_ssize_t len;
159+
} _PyBytes_data_t;
160+
PyAPI_FUNC(int) _PyBytes_GetData(PyObject *, _PyBytes_data_t *);
161+
PyAPI_FUNC(PyObject *) _PyBytes_FromData(_PyBytes_data_t *);
162+
PyAPI_FUNC(PyObject *) _PyBytes_FromXIData(_PyXIData_t *);
163+
PyAPI_FUNC(int) _PyBytes_GetXIData(
164+
PyThreadState *,
165+
PyObject *,
166+
_PyXIData_t *);
167+
PyAPI_FUNC(_PyBytes_data_t *) _PyBytes_GetXIDataWrapped(
168+
PyThreadState *,
169+
PyObject *,
170+
size_t,
171+
xid_newobjfunc,
172+
_PyXIData_t *);
173+
174+
// _PyObject_GetXIData() for marshal
175+
PyAPI_FUNC(PyObject *) _PyMarshal_ReadObjectFromXIData(_PyXIData_t *);
176+
PyAPI_FUNC(int) _PyMarshal_GetXIData(
177+
PyThreadState *,
178+
PyObject *,
179+
_PyXIData_t *);
180+
181+
182+
/* using cross-interpreter data */
183+
184+
PyAPI_FUNC(PyObject *) _PyXIData_NewObject(_PyXIData_t *);
185+
PyAPI_FUNC(int) _PyXIData_Release(_PyXIData_t *);
186+
PyAPI_FUNC(int) _PyXIData_ReleaseAndRawFree(_PyXIData_t *);
157187

158188

159189
/* cross-interpreter data registry */

Include/internal/pycore_global_objects_fini_generated.h

Lines changed: 1 addition & 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: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -516,6 +516,7 @@ struct _Py_global_strings {
516516
STRUCT_FOR_ID(intern)
517517
STRUCT_FOR_ID(intersection)
518518
STRUCT_FOR_ID(interval)
519+
STRUCT_FOR_ID(io)
519520
STRUCT_FOR_ID(is_running)
520521
STRUCT_FOR_ID(is_struct)
521522
STRUCT_FOR_ID(isatty)

Include/internal/pycore_import.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ extern void _PyImport_SetDLOpenFlags(PyInterpreterState *interp, int new_val);
6363

6464
extern PyObject * _PyImport_InitModules(PyInterpreterState *interp);
6565
extern PyObject * _PyImport_GetModules(PyInterpreterState *interp);
66+
extern PyObject * _PyImport_GetModulesRef(PyInterpreterState *interp);
6667
extern void _PyImport_ClearModules(PyInterpreterState *interp);
6768

6869
extern void _PyImport_ClearModulesByIndex(PyInterpreterState *interp);

Include/internal/pycore_moduleobject.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,12 @@ static inline PyObject* _PyModule_GetDict(PyObject *mod) {
4747
return dict; // borrowed reference
4848
}
4949

50+
extern PyObject * _PyModule_GetFilenameObject(PyObject *);
51+
extern Py_ssize_t _PyModule_GetFilenameUTF8(
52+
PyObject *module,
53+
char *buffer,
54+
Py_ssize_t maxlen);
55+
5056
PyObject* _Py_module_getattro_impl(PyModuleObject *m, PyObject *name, int suppress);
5157
PyObject* _Py_module_getattro(PyObject *m, PyObject *name);
5258

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy