Skip to content

Commit c0ee947

Browse files
committed
Merge branch 'master' into fix-legacy-repr-tests
2 parents 2ccc403 + a1da208 commit c0ee947

38 files changed

Lines changed: 248 additions & 177 deletions

Doc/c-api/function.rst

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,13 @@ There are a few functions specific to Python functions.
9595
9696
.. versionadded:: 3.12
9797
98+
99+
.. c:function:: PyObject* PyFunction_GetKwDefaults(PyObject *op)
100+
101+
Return the keyword-only argument default values of the function object *op*. This can be a
102+
dictionary of arguments or ``NULL``.
103+
104+
98105
.. c:function:: PyObject* PyFunction_GetClosure(PyObject *op)
99106
100107
Return the closure associated with the function object *op*. This can be ``NULL``
@@ -123,6 +130,19 @@ There are a few functions specific to Python functions.
123130
Raises :exc:`SystemError` and returns ``-1`` on failure.
124131
125132
133+
.. c:function:: PyObject *PyFunction_GET_CODE(PyObject *op)
134+
PyObject *PyFunction_GET_GLOBALS(PyObject *op)
135+
PyObject *PyFunction_GET_MODULE(PyObject *op)
136+
PyObject *PyFunction_GET_DEFAULTS(PyObject *op)
137+
PyObject *PyFunction_GET_KW_DEFAULTS(PyObject *op)
138+
PyObject *PyFunction_GET_CLOSURE(PyObject *op)
139+
PyObject *PyFunction_GET_ANNOTATIONS(PyObject *op)
140+
141+
These functions are similar to their ``PyFunction_Get*`` counterparts, but
142+
do not do type checking. Passing anything other than an instance of
143+
:c:data:`PyFunction_Type` is undefined behavior.
144+
145+
126146
.. c:function:: int PyFunction_AddWatcher(PyFunction_WatchCallback callback)
127147
128148
Register *callback* as a function watcher for the current interpreter.

Doc/data/refcounts.dat

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -963,21 +963,45 @@ PyFunction_Check:PyObject*:o:0:
963963
PyFunction_GetAnnotations:PyObject*::0:
964964
PyFunction_GetAnnotations:PyObject*:op:0:
965965

966+
PyFunction_GET_ANNOTATIONS:PyObject*::0:
967+
PyFunction_GET_ANNOTATIONS:PyObject*:op:0:
968+
966969
PyFunction_GetClosure:PyObject*::0:
967970
PyFunction_GetClosure:PyObject*:op:0:
968971

972+
PyFunction_GET_CLOSURE:PyObject*::0:
973+
PyFunction_GET_CLOSURE:PyObject*:op:0:
974+
969975
PyFunction_GetCode:PyObject*::0:
970976
PyFunction_GetCode:PyObject*:op:0:
971977

978+
PyFunction_GET_CODE:PyObject*::0:
979+
PyFunction_GET_CODE:PyObject*:op:0:
980+
972981
PyFunction_GetDefaults:PyObject*::0:
973982
PyFunction_GetDefaults:PyObject*:op:0:
974983

984+
PyFunction_GET_DEFAULTS:PyObject*::0:
985+
PyFunction_GET_DEFAULTS:PyObject*:op:0:
986+
987+
PyFunction_GetKwDefaults:PyObject*::0:
988+
PyFunction_GetKwDefaults:PyObject*:op:0:
989+
990+
PyFunction_GET_KW_DEFAULTS:PyObject*::0:
991+
PyFunction_GET_KW_DEFAULTS:PyObject*:op:0:
992+
975993
PyFunction_GetGlobals:PyObject*::0:
976994
PyFunction_GetGlobals:PyObject*:op:0:
977995

996+
PyFunction_GET_GLOBALS:PyObject*::0:
997+
PyFunction_GET_GLOBALS:PyObject*:op:0:
998+
978999
PyFunction_GetModule:PyObject*::0:
9791000
PyFunction_GetModule:PyObject*:op:0:
9801001

1002+
PyFunction_GET_MODULE:PyObject*::0:
1003+
PyFunction_GET_MODULE:PyObject*:op:0:
1004+
9811005
PyFunction_New:PyObject*::+1:
9821006
PyFunction_New:PyObject*:code:+1:
9831007
PyFunction_New:PyObject*:globals:+1:

Doc/library/functions.rst

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1839,15 +1839,15 @@ are always available. They are listed here in alphabetical order.
18391839
``range(start, stop, step)``. The *start* and *step* arguments default to
18401840
``None``.
18411841

1842+
Slice objects have read-only data attributes :attr:`!start`,
1843+
:attr:`!stop`, and :attr:`!step` which merely return the argument
1844+
values (or their default). They have no other explicit functionality;
1845+
however, they are used by NumPy and other third-party packages.
1846+
18421847
.. attribute:: slice.start
18431848
.. attribute:: slice.stop
18441849
.. attribute:: slice.step
18451850

1846-
Slice objects have read-only data attributes :attr:`!start`,
1847-
:attr:`!stop`, and :attr:`!step` which merely return the argument
1848-
values (or their default). They have no other explicit functionality;
1849-
however, they are used by NumPy and other third-party packages.
1850-
18511851
Slice objects are also generated when extended indexing syntax is used. For
18521852
example: ``a[start:stop:step]`` or ``a[start:stop, i]``. See
18531853
:func:`itertools.islice` for an alternate version that returns an

Doc/reference/expressions.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1023,7 +1023,7 @@ series of :term:`arguments <argument>`:
10231023
: ["," `keywords_arguments`]
10241024
: | `starred_and_keywords` ["," `keywords_arguments`]
10251025
: | `keywords_arguments`
1026-
positional_arguments: positional_item ("," positional_item)*
1026+
positional_arguments: `positional_item` ("," `positional_item`)*
10271027
positional_item: `assignment_expression` | "*" `expression`
10281028
starred_and_keywords: ("*" `expression` | `keyword_item`)
10291029
: ("," "*" `expression` | "," `keyword_item`)*

Doc/whatsnew/3.14.rst

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -978,6 +978,23 @@ be specified by the build backend, as it will no longer be determined
978978
automatically by the C compiler. For a running interpreter, the setting that
979979
was used at compile time can be found using :func:`sysconfig.get_config_var`.
980980

981+
A new flag has been added, :data:`~sys.flags.context_aware_warnings`. This
982+
flag defaults to true for the free-threaded build and false for the GIL-enabled
983+
build. If the flag is true then the :class:`warnings.catch_warnings` context
984+
manager uses a context variable for warning filters. This makes the context
985+
manager behave predicably when used with multiple threads or asynchronous
986+
tasks.
987+
988+
A new flag has been added, :data:`~sys.flags.thread_inherit_context`. This flag
989+
defaults to true for the free-threaded build and false for the GIL-enabled
990+
build. If the flag is true then threads created with :class:`threading.Thread`
991+
start with a copy of the :class:`~contextvars.Context()` of the caller of
992+
:meth:`~threading.Thread.start`. Most significantly, this makes the warning
993+
filtering context established by :class:`~warnings.catch_warnings` be
994+
"inherited" by threads (or asyncio tasks) started within that context. It also
995+
affects other modules that use context variables, such as the :mod:`decimal`
996+
context manager.
997+
981998

982999
.. _whatsnew314-pyrepl-highlighting:
9831000

@@ -1028,6 +1045,18 @@ Please report any bugs or major performance regressions that you encounter!
10281045

10291046
.. seealso:: :pep:`744`
10301047

1048+
Concurrent safe warnings control
1049+
--------------------------------
1050+
1051+
The :class:`warnings.catch_warnings` context manager will now optionally
1052+
use a context variable for warning filters. This is enabled by setting
1053+
the :data:`~sys.flags.context_aware_warnings` flag, either with the ``-X``
1054+
command-line option or an environment variable. This gives predicable
1055+
warnings control when using :class:`~warnings.catch_warnings` combined with
1056+
multiple threads or asynchronous tasks. The flag defaults to true for the
1057+
free-threaded build and false for the GIL-enabled build.
1058+
1059+
(Contributed by Neil Schemenauer and Kumar Aditya in :gh:`130010`.)
10311060

10321061
Other language changes
10331062
======================

Include/ceval.h

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -133,13 +133,6 @@ PyAPI_FUNC(void) PyEval_ReleaseThread(PyThreadState *tstate);
133133
#define FVS_MASK 0x4
134134
#define FVS_HAVE_SPEC 0x4
135135

136-
/* Special methods used by LOAD_SPECIAL */
137-
#define SPECIAL___ENTER__ 0
138-
#define SPECIAL___EXIT__ 1
139-
#define SPECIAL___AENTER__ 2
140-
#define SPECIAL___AEXIT__ 3
141-
#define SPECIAL_MAX 3
142-
143136
#ifndef Py_LIMITED_API
144137
# define Py_CPYTHON_CEVAL_H
145138
# include "cpython/ceval.h"

Include/cpython/pystate.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,10 @@ typedef int (*Py_tracefunc)(PyObject *, PyFrameObject *, int, PyObject *);
2828
#define PyTrace_OPCODE 7
2929

3030
/* Remote debugger support */
31-
#define MAX_SCRIPT_PATH_SIZE 512
32-
typedef struct _remote_debugger_support {
31+
#define Py_MAX_SCRIPT_PATH_SIZE 512
32+
typedef struct {
3333
int32_t debugger_pending_call;
34-
char debugger_script_path[MAX_SCRIPT_PATH_SIZE];
34+
char debugger_script_path[Py_MAX_SCRIPT_PATH_SIZE];
3535
} _PyRemoteDebuggerSupport;
3636

3737
typedef struct _err_stackitem {

Include/internal/pycore_ceval.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -366,6 +366,13 @@ extern int _PyRunRemoteDebugger(PyThreadState *tstate);
366366
PyAPI_FUNC(_PyStackRef)
367367
_PyForIter_VirtualIteratorNext(PyThreadState* tstate, struct _PyInterpreterFrame* frame, _PyStackRef iter, _PyStackRef *index_ptr);
368368

369+
/* Special methods used by LOAD_SPECIAL */
370+
#define SPECIAL___ENTER__ 0
371+
#define SPECIAL___EXIT__ 1
372+
#define SPECIAL___AENTER__ 2
373+
#define SPECIAL___AEXIT__ 3
374+
#define SPECIAL_MAX 3
375+
369376
#ifdef __cplusplus
370377
}
371378
#endif

Include/internal/pycore_debug_offsets.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -368,7 +368,7 @@ typedef struct _Py_DebugOffsets {
368368
.remote_debugging_enabled = offsetof(PyInterpreterState, config.remote_debug), \
369369
.debugger_pending_call = offsetof(_PyRemoteDebuggerSupport, debugger_pending_call), \
370370
.debugger_script_path = offsetof(_PyRemoteDebuggerSupport, debugger_script_path), \
371-
.debugger_script_path_size = MAX_SCRIPT_PATH_SIZE, \
371+
.debugger_script_path_size = Py_MAX_SCRIPT_PATH_SIZE, \
372372
}, \
373373
}
374374

Include/internal/pycore_pymem.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ extern wchar_t *_PyMem_DefaultRawWcsdup(const wchar_t *str);
8888
extern int _PyMem_DebugEnabled(void);
8989

9090
// Enqueue a pointer to be freed possibly after some delay.
91-
extern void _PyMem_FreeDelayed(void *ptr);
91+
extern void _PyMem_FreeDelayed(void *ptr, size_t size);
9292

9393
// Periodically process delayed free requests.
9494
extern void _PyMem_ProcessDelayed(PyThreadState *tstate);

0 commit comments

Comments
 (0)