Skip to content

Commit ea5965a

Browse files
committed
Merge branch 'main' into gsallam/main
* main: (30 commits) pythongh-103987: fix several crashes in mmap module (python#103990) docs: fix wrong indentation causing rendering error in dis page (python#104661) pythongh-94906: Support multiple steps in math.nextafter (python#103881) pythongh-104472: Skip `test_subprocess.ProcessTestCase.test_empty_env` if ASAN is enabled (python#104667) pythongh-103839: Allow building Tkinter against Tcl 8.7 without external libtommath (pythonGH-103842) pythongh-85984: New additions and improvements to the tty library. (python#101832) pythongh-104659: Consolidate python examples in enum documentation (python#104665) pythongh-92248: Deprecate `type`, `choices`, `metavar` parameters of `argparse.BooleanOptionalAction` (python#103678) pythongh-104645: fix error handling in marshal tests (python#104646) pythongh-104600: Make type.__type_params__ writable (python#104634) pythongh-104602: Add additional test for listcomp with lambda (python#104639) pythongh-104640: Disallow walrus in comprehension within type scopes (python#104641) pythongh-103921: Rename "type" header in argparse docs (python#104654) Improve readability of `typing._ProtocolMeta.__instancecheck__` (python#104649) pythongh-96522: Fix deadlock in pty.spawn (python#96639) pythonGH-102818: Do not call `PyTraceBack_Here` in sys.settrace trampoline. (pythonGH-104579) pythonGH-103545: Add macOS specific constants for ``os.setpriority`` to ``os`` (python#104606) pythongh-104623: Update macOS installer to SQLite 3.42.0 (pythonGH-104624) pythongh-104619: never leak comprehension locals to outer locals() (python#104637) pythongh-104602: ensure all cellvars are known up front (python#104603) ...
2 parents 6585f32 + ceaa4c3 commit ea5965a

File tree

80 files changed

+1254
-299
lines changed

Some content is hidden

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

80 files changed

+1254
-299
lines changed

Doc/library/argparse.rst

+15-15
Original file line numberDiff line numberDiff line change
@@ -57,20 +57,20 @@ the extracted data in a :class:`argparse.Namespace` object::
5757
Quick Links for add_argument()
5858
------------------------------
5959

60-
====================== =========================================================== ==========================================================================================================================
61-
Name Description Values
62-
====================== =========================================================== ==========================================================================================================================
63-
action_ Specify how an argument should be handled ``'store'``, ``'store_const'``, ``'store_true'``, ``'append'``, ``'append_const'``, ``'count'``, ``'help'``, ``'version'``
64-
choices_ Limit values to a specific set of choices ``['foo', 'bar']``, ``range(1, 10)``, or :class:`~collections.abc.Container` instance
65-
const_ Store a constant value
66-
default_ Default value used when an argument is not provided Defaults to ``None``
67-
dest_ Specify the attribute name used in the result namespace
68-
help_ Help message for an argument
69-
metavar_ Alternate display name for the argument as shown in help
70-
nargs_ Number of times the argument can be used :class:`int`, ``'?'``, ``'*'``, or ``'+'``
71-
required_ Indicate whether an argument is required or optional ``True`` or ``False``
72-
type_ Automatically convert an argument to the given type :class:`int`, :class:`float`, ``argparse.FileType('w')``, or callable function
73-
====================== =========================================================== ==========================================================================================================================
60+
============================ =========================================================== ==========================================================================================================================
61+
Name Description Values
62+
============================ =========================================================== ==========================================================================================================================
63+
action_ Specify how an argument should be handled ``'store'``, ``'store_const'``, ``'store_true'``, ``'append'``, ``'append_const'``, ``'count'``, ``'help'``, ``'version'``
64+
choices_ Limit values to a specific set of choices ``['foo', 'bar']``, ``range(1, 10)``, or :class:`~collections.abc.Container` instance
65+
const_ Store a constant value
66+
default_ Default value used when an argument is not provided Defaults to ``None``
67+
dest_ Specify the attribute name used in the result namespace
68+
help_ Help message for an argument
69+
metavar_ Alternate display name for the argument as shown in help
70+
nargs_ Number of times the argument can be used :class:`int`, ``'?'``, ``'*'``, or ``'+'``
71+
required_ Indicate whether an argument is required or optional ``True`` or ``False``
72+
:ref:`type <argparse-type>` Automatically convert an argument to the given type :class:`int`, :class:`float`, ``argparse.FileType('w')``, or callable function
73+
============================ =========================================================== ==========================================================================================================================
7474

7575

7676
Example
@@ -1132,7 +1132,7 @@ command-line argument was not present::
11321132
Namespace(foo='1')
11331133

11341134

1135-
.. _type:
1135+
.. _argparse-type:
11361136

11371137
type
11381138
^^^^

Doc/library/dis.rst

+2-2
Original file line numberDiff line numberDiff line change
@@ -622,8 +622,8 @@ not have to be) the original ``STACK[-2]``.
622622

623623
.. versionadded:: 3.8
624624

625-
.. versionchanged:: 3.11
626-
Exception representation on the stack now consist of one, not three, items.
625+
.. versionchanged:: 3.11
626+
Exception representation on the stack now consist of one, not three, items.
627627

628628

629629
.. opcode:: CLEANUP_THROW

Doc/library/enum.rst

+6-6
Original file line numberDiff line numberDiff line change
@@ -406,18 +406,18 @@ Data Types
406406
with an *IntEnum* member, the resulting value loses its enumeration status.
407407

408408
>>> from enum import IntEnum
409-
>>> class Numbers(IntEnum):
409+
>>> class Number(IntEnum):
410410
... ONE = 1
411411
... TWO = 2
412412
... THREE = 3
413413
...
414-
>>> Numbers.THREE
415-
<Numbers.THREE: 3>
416-
>>> Numbers.ONE + Numbers.TWO
414+
>>> Number.THREE
415+
<Number.THREE: 3>
416+
>>> Number.ONE + Number.TWO
417417
3
418-
>>> Numbers.THREE + 5
418+
>>> Number.THREE + 5
419419
8
420-
>>> Numbers.THREE == 3
420+
>>> Number.THREE == 3
421421
True
422422

423423
.. note::

Doc/library/math.rst

+6-3
Original file line numberDiff line numberDiff line change
@@ -224,11 +224,11 @@ Number-theoretic and representation functions
224224
of *x* and are floats.
225225

226226

227-
.. function:: nextafter(x, y)
227+
.. function:: nextafter(x, y, steps=1)
228228

229-
Return the next floating-point value after *x* towards *y*.
229+
Return the floating-point value *steps* steps after *x* towards *y*.
230230

231-
If *x* is equal to *y*, return *y*.
231+
If *x* is equal to *y*, return *y*, unless *steps* is zero.
232232

233233
Examples:
234234

@@ -239,6 +239,9 @@ Number-theoretic and representation functions
239239

240240
See also :func:`math.ulp`.
241241

242+
.. versionchanged:: 3.12
243+
Added the *steps* argument.
244+
242245
.. versionadded:: 3.9
243246

244247
.. function:: perm(n, k=None)

Doc/library/os.rst

+11
Original file line numberDiff line numberDiff line change
@@ -493,6 +493,17 @@ process and user.
493493
.. versionadded:: 3.3
494494

495495

496+
.. data:: PRIO_DARWIN_THREAD
497+
PRIO_DARWIN_PROCESS
498+
PRIO_DARWIN_BG
499+
PRIO_DARWIN_NONUI
500+
501+
Parameters for the :func:`getpriority` and :func:`setpriority` functions.
502+
503+
.. availability:: macOS
504+
505+
.. versionadded:: 3.12
506+
496507
.. function:: getresuid()
497508

498509
Return a tuple (ruid, euid, suid) denoting the current process's

Doc/library/pathlib.rst

+6-1
Original file line numberDiff line numberDiff line change
@@ -546,7 +546,7 @@ Pure paths provide the following methods and properties:
546546
PureWindowsPath('c:/Program Files')
547547

548548

549-
.. method:: PurePath.match(pattern)
549+
.. method:: PurePath.match(pattern, *, case_sensitive=None)
550550

551551
Match this path against the provided glob-style pattern. Return ``True``
552552
if matching is successful, ``False`` otherwise.
@@ -576,6 +576,11 @@ Pure paths provide the following methods and properties:
576576
>>> PureWindowsPath('b.py').match('*.PY')
577577
True
578578

579+
Set *case_sensitive* to ``True`` or ``False`` to override this behaviour.
580+
581+
.. versionadded:: 3.12
582+
The *case_sensitive* argument.
583+
579584

580585
.. method:: PurePath.relative_to(other, walk_up=False)
581586

Doc/library/tty.rst

+20-2
Original file line numberDiff line numberDiff line change
@@ -20,18 +20,36 @@ Because it requires the :mod:`termios` module, it will work only on Unix.
2020
The :mod:`tty` module defines the following functions:
2121

2222

23+
.. function:: cfmakeraw(mode)
24+
25+
Convert the tty attribute list *mode*, which is a list like the one returned
26+
by :func:`termios.tcgetattr`, to that of a tty in raw mode.
27+
28+
.. versionadded:: 3.12
29+
30+
31+
.. function:: cfmakecbreak(mode)
32+
33+
Convert the tty attribute list *mode*, which is a list like the one returned
34+
by :func:`termios.tcgetattr`, to that of a tty in cbreak mode.
35+
36+
.. versionadded:: 3.12
37+
38+
2339
.. function:: setraw(fd, when=termios.TCSAFLUSH)
2440

2541
Change the mode of the file descriptor *fd* to raw. If *when* is omitted, it
2642
defaults to :const:`termios.TCSAFLUSH`, and is passed to
27-
:func:`termios.tcsetattr`.
43+
:func:`termios.tcsetattr`. The return value of :func:`termios.tcgetattr`
44+
is saved before setting *fd* to raw mode; this value is returned.
2845

2946

3047
.. function:: setcbreak(fd, when=termios.TCSAFLUSH)
3148

3249
Change the mode of file descriptor *fd* to cbreak. If *when* is omitted, it
3350
defaults to :const:`termios.TCSAFLUSH`, and is passed to
34-
:func:`termios.tcsetattr`.
51+
:func:`termios.tcsetattr`. The return value of :func:`termios.tcgetattr`
52+
is saved before setting *fd* to cbreak mode; this value is returned.
3553

3654

3755
.. seealso::

Doc/whatsnew/3.12.rst

+8
Original file line numberDiff line numberDiff line change
@@ -395,6 +395,9 @@ pathlib
395395
* Add :meth:`pathlib.Path.is_junction` as a proxy to :func:`os.path.isjunction`.
396396
(Contributed by Charles Machalow in :gh:`99547`.)
397397

398+
* Add *case_sensitive* optional parameter to :meth:`pathlib.Path.glob`,
399+
:meth:`pathlib.Path.rglob` and :meth:`pathlib.PurePath.match` for matching
400+
the path's case sensitivity, allowing for more precise control over the matching process.
398401

399402
dis
400403
---
@@ -867,6 +870,11 @@ Pending Removal in Python 3.14
867870
* The *onerror* argument of :func:`shutil.rmtree` is deprecated in 3.12,
868871
and will be removed in 3.14.
869872

873+
* The *type*, *choices*, and *metavar* parameters
874+
of :class:`!argparse.BooleanOptionalAction` are deprecated
875+
and will be removed in 3.14.
876+
(Contributed by Nikita Sobolev in :gh:`92248`.)
877+
870878
* :func:`pkgutil.find_loader` and :func:`pkgutil.get_loader`
871879
now raise :exc:`DeprecationWarning`;
872880
use :func:`importlib.util.find_spec` instead.

Include/internal/pycore_compile.h

+2-1
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,8 @@ PyAPI_FUNC(PyObject*) _PyCompile_CodeGen(
105105

106106
PyAPI_FUNC(PyObject*) _PyCompile_OptimizeCfg(
107107
PyObject *instructions,
108-
PyObject *consts);
108+
PyObject *consts,
109+
int nlocals);
109110

110111
PyAPI_FUNC(PyCodeObject*)
111112
_PyCompile_Assemble(_PyCompile_CodeUnitMetadata *umd, PyObject *filename,

Include/internal/pycore_global_objects.h

-1
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,6 @@ struct _Py_interp_cached_objects {
7575
PyTypeObject *paramspec_type;
7676
PyTypeObject *paramspecargs_type;
7777
PyTypeObject *paramspeckwargs_type;
78-
PyTypeObject *typealias_type;
7978
};
8079

8180
#define _Py_INTERP_STATIC_OBJECT(interp, NAME) \

Include/internal/pycore_global_objects_fini_generated.h

+2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Include/internal/pycore_global_strings.h

+2
Original file line numberDiff line numberDiff line change
@@ -559,6 +559,7 @@ struct _Py_global_strings {
559559
STRUCT_FOR_ID(newline)
560560
STRUCT_FOR_ID(newlines)
561561
STRUCT_FOR_ID(next)
562+
STRUCT_FOR_ID(nlocals)
562563
STRUCT_FOR_ID(node_depth)
563564
STRUCT_FOR_ID(node_offset)
564565
STRUCT_FOR_ID(ns)
@@ -680,6 +681,7 @@ struct _Py_global_strings {
680681
STRUCT_FOR_ID(stdin)
681682
STRUCT_FOR_ID(stdout)
682683
STRUCT_FOR_ID(step)
684+
STRUCT_FOR_ID(steps)
683685
STRUCT_FOR_ID(store_name)
684686
STRUCT_FOR_ID(strategy)
685687
STRUCT_FOR_ID(strftime)

Include/internal/pycore_runtime_init_generated.h

+2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Include/internal/pycore_symtable.h

+3-2
Original file line numberDiff line numberDiff line change
@@ -120,14 +120,15 @@ extern PyObject* _Py_Mangle(PyObject *p, PyObject *name);
120120
#define DEF_ANNOT 2<<7 /* this name is annotated */
121121
#define DEF_COMP_ITER 2<<8 /* this name is a comprehension iteration variable */
122122
#define DEF_TYPE_PARAM 2<<9 /* this name is a type parameter */
123+
#define DEF_COMP_CELL 2<<10 /* this name is a cell in an inlined comprehension */
123124

124125
#define DEF_BOUND (DEF_LOCAL | DEF_PARAM | DEF_IMPORT)
125126

126127
/* GLOBAL_EXPLICIT and GLOBAL_IMPLICIT are used internally by the symbol
127128
table. GLOBAL is returned from PyST_GetScope() for either of them.
128-
It is stored in ste_symbols at bits 12-15.
129+
It is stored in ste_symbols at bits 13-16.
129130
*/
130-
#define SCOPE_OFFSET 11
131+
#define SCOPE_OFFSET 12
131132
#define SCOPE_MASK (DEF_GLOBAL | DEF_LOCAL | DEF_PARAM | DEF_NONLOCAL)
132133

133134
#define LOCAL 1

Include/internal/pycore_typevarobject.h

+2
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ extern PyObject *_Py_subscript_generic(PyThreadState *, PyObject *);
1616
extern int _Py_initialize_generic(PyInterpreterState *);
1717
extern void _Py_clear_generic_types(PyInterpreterState *);
1818

19+
extern PyTypeObject _PyTypeAlias_Type;
20+
1921
#ifdef __cplusplus
2022
}
2123
#endif

Include/internal/pycore_unicodeobject_generated.h

+6
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Lib/argparse.py

+24-3
Original file line numberDiff line numberDiff line change
@@ -883,16 +883,19 @@ def __call__(self, parser, namespace, values, option_string=None):
883883
raise NotImplementedError(_('.__call__() not defined'))
884884

885885

886+
# FIXME: remove together with `BooleanOptionalAction` deprecated arguments.
887+
_deprecated_default = object()
888+
886889
class BooleanOptionalAction(Action):
887890
def __init__(self,
888891
option_strings,
889892
dest,
890893
default=None,
891-
type=None,
892-
choices=None,
894+
type=_deprecated_default,
895+
choices=_deprecated_default,
893896
required=False,
894897
help=None,
895-
metavar=None):
898+
metavar=_deprecated_default):
896899

897900
_option_strings = []
898901
for option_string in option_strings:
@@ -902,6 +905,24 @@ def __init__(self,
902905
option_string = '--no-' + option_string[2:]
903906
_option_strings.append(option_string)
904907

908+
# We need `_deprecated` special value to ban explicit arguments that
909+
# match default value. Like:
910+
# parser.add_argument('-f', action=BooleanOptionalAction, type=int)
911+
for field_name in ('type', 'choices', 'metavar'):
912+
if locals()[field_name] is not _deprecated_default:
913+
warnings._deprecated(
914+
field_name,
915+
"{name!r} is deprecated as of Python 3.12 and will be "
916+
"removed in Python {remove}.",
917+
remove=(3, 14))
918+
919+
if type is _deprecated_default:
920+
type = None
921+
if choices is _deprecated_default:
922+
choices = None
923+
if metavar is _deprecated_default:
924+
metavar = None
925+
905926
super().__init__(
906927
option_strings=_option_strings,
907928
dest=dest,

Lib/functools.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
# wrapper functions that can handle naive introspection
3131

3232
WRAPPER_ASSIGNMENTS = ('__module__', '__name__', '__qualname__', '__doc__',
33-
'__annotations__')
33+
'__annotations__', '__type_params__')
3434
WRAPPER_UPDATES = ('__dict__',)
3535
def update_wrapper(wrapper,
3636
wrapped,

0 commit comments

Comments
 (0)