Skip to content

Commit ea3ba39

Browse files
authored
Merge branch 'main' into frozenset_immutable_tracking
2 parents 37af64f + f2b5c20 commit ea3ba39

18 files changed

Lines changed: 329 additions & 133 deletions

Doc/c-api/module.rst

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -426,10 +426,10 @@ To retrieve the state from a given module, use the following functions:
426426
module state.
427427
428428
429-
.. c:function:: int PyModule_GetStateSize(PyObject *, Py_ssize_t *result)
429+
.. c:function:: int PyModule_GetStateSize(PyObject *module, Py_ssize_t *result)
430430
431-
Set *\*result* to the size of the module's state, as specified using
432-
:c:macro:`Py_mod_state_size` (or :c:member:`PyModuleDef.m_size`),
431+
Set *\*result* to the size of *module*'s state, as specified
432+
using :c:macro:`Py_mod_state_size` (or :c:member:`PyModuleDef.m_size`),
433433
and return 0.
434434
435435
On error, set *\*result* to -1, and return -1 with an exception set.
@@ -597,7 +597,7 @@ A module's token -- and the *your_token* value to use in the above code -- is:
597597
598598
.. c:function:: int PyModule_GetToken(PyObject *module, void** result)
599599
600-
Set *\*result* to the module's token and return 0.
600+
Set *\*result* to the module token for *module* and return 0.
601601
602602
On error, set *\*result* to NULL, and return -1 with an exception set.
603603
@@ -645,7 +645,7 @@ rather than from an extension's :ref:`export hook <extension-export-hook>`.
645645
646646
.. c:function:: int PyModule_Exec(PyObject *module)
647647
648-
Execute the :c:data:`Py_mod_exec` slot(s) of the given *module*.
648+
Execute the :c:data:`Py_mod_exec` slot(s) of *module*.
649649
650650
On success, return 0.
651651
On error, return -1 with an exception set.
@@ -1021,6 +1021,9 @@ or code that creates modules dynamically.
10211021
``PyModuleDef`` (such as when using :ref:`multi-phase-initialization`,
10221022
``PyModule_Create``, or ``PyModule_FromDefAndSpec``).
10231023
1024+
Return ``0`` on success.
1025+
Return ``-1`` with an exception set on error.
1026+
10241027
.. versionadded:: 3.5
10251028
10261029
.. c:function:: int PyUnstable_Module_SetGIL(PyObject *module, void *gil)

Doc/library/base64.rst

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ POST request.
7373

7474

7575
.. function:: b64decode(s, altchars=None, validate=False)
76+
b64decode(s, altchars=None, validate=True, *, ignorechars)
7677
7778
Decode the Base64 encoded :term:`bytes-like object` or ASCII string
7879
*s* and return the decoded :class:`bytes`.
@@ -84,11 +85,17 @@ POST request.
8485
A :exc:`binascii.Error` exception is raised
8586
if *s* is incorrectly padded.
8687

87-
If *validate* is false (the default), characters that are neither
88+
If *ignorechars* is specified, it should be a :term:`bytes-like object`
89+
containing characters to ignore from the input when *validate* is true.
90+
The default value of *validate* is ``True`` if *ignorechars* is specified,
91+
``False`` otherwise.
92+
93+
If *validate* is false, characters that are neither
8894
in the normal base-64 alphabet nor the alternative alphabet are
8995
discarded prior to the padding check, but the ``+`` and ``/`` characters
9096
keep their meaning if they are not in *altchars* (they will be discarded
9197
in future Python versions).
98+
9299
If *validate* is true, these non-alphabet characters in the input
93100
result in a :exc:`binascii.Error`.
94101

@@ -99,6 +106,10 @@ POST request.
99106
is now deprecated.
100107

101108

109+
.. versionchanged:: next
110+
Added the *ignorechars* parameter.
111+
112+
102113
.. function:: standard_b64encode(s)
103114

104115
Encode :term:`bytes-like object` *s* using the standard Base64 alphabet

Doc/library/binascii.rst

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,16 @@ The :mod:`binascii` module defines the following functions:
4949

5050

5151
.. function:: a2b_base64(string, /, *, strict_mode=False)
52+
a2b_base64(string, /, *, strict_mode=True, ignorechars)
5253
5354
Convert a block of base64 data back to binary and return the binary data. More
5455
than one line may be passed at a time.
5556

57+
If *ignorechars* is specified, it should be a :term:`bytes-like object`
58+
containing characters to ignore from the input when *strict_mode* is true.
59+
The default value of *strict_mode* is ``True`` if *ignorechars* is specified,
60+
``False`` otherwise.
61+
5662
If *strict_mode* is true, only valid base64 data will be converted. Invalid base64
5763
data will raise :exc:`binascii.Error`.
5864

@@ -66,6 +72,9 @@ The :mod:`binascii` module defines the following functions:
6672
.. versionchanged:: 3.11
6773
Added the *strict_mode* parameter.
6874

75+
.. versionchanged:: next
76+
Added the *ignorechars* parameter.
77+
6978

7079
.. function:: b2a_base64(data, *, wrapcol=0, newline=True)
7180

Doc/library/contextvars.rst

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,13 +119,15 @@ Context Variables
119119
# After the reset call the var has no value again, so
120120
# var.get() would raise a LookupError.
121121

122+
The same *token* cannot be used twice.
123+
122124

123125
.. class:: Token
124126

125127
*Token* objects are returned by the :meth:`ContextVar.set` method.
126128
They can be passed to the :meth:`ContextVar.reset` method to revert
127129
the value of the variable to what it was before the corresponding
128-
*set*.
130+
*set*. A single token cannot reset a context variable more than once.
129131

130132
Tokens support the :ref:`context manager protocol <context-managers>`
131133
to automatically reset context variables. See :meth:`ContextVar.set`.

Doc/whatsnew/3.15.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -444,13 +444,18 @@ base64
444444
* Added the *wrapcol* parameter in :func:`~base64.b64encode`.
445445
(Contributed by Serhiy Storchaka in :gh:`143214`.)
446446

447+
* Added the *ignorechars* parameter in :func:`~base64.b64decode`.
448+
(Contributed by Serhiy Storchaka in :gh:`144001`.)
447449

448450
binascii
449451
--------
450452

451453
* Added the *wrapcol* parameter in :func:`~binascii.b2a_base64`.
452454
(Contributed by Serhiy Storchaka in :gh:`143214`.)
453455

456+
* Added the *ignorechars* parameter in :func:`~binascii.a2b_base64`.
457+
(Contributed by Serhiy Storchaka in :gh:`144001`.)
458+
454459

455460
calendar
456461
--------

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
@@ -520,6 +520,7 @@ struct _Py_global_strings {
520520
STRUCT_FOR_ID(ident)
521521
STRUCT_FOR_ID(identity_hint)
522522
STRUCT_FOR_ID(ignore)
523+
STRUCT_FOR_ID(ignorechars)
523524
STRUCT_FOR_ID(imag)
524525
STRUCT_FOR_ID(implieslink)
525526
STRUCT_FOR_ID(importlib)

Include/internal/pycore_runtime_init_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_unicodeobject_generated.h

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

Include/moduleobject.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -118,11 +118,11 @@ PyAPI_FUNC(int) PyUnstable_Module_SetGIL(PyObject *module, void *gil);
118118
#endif
119119

120120
#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= _Py_PACK_VERSION(3, 15)
121-
PyAPI_FUNC(PyObject *) PyModule_FromSlotsAndSpec(const PyModuleDef_Slot *,
121+
PyAPI_FUNC(PyObject *) PyModule_FromSlotsAndSpec(const PyModuleDef_Slot *slots,
122122
PyObject *spec);
123-
PyAPI_FUNC(int) PyModule_Exec(PyObject *mod);
124-
PyAPI_FUNC(int) PyModule_GetStateSize(PyObject *mod, Py_ssize_t *result);
125-
PyAPI_FUNC(int) PyModule_GetToken(PyObject *, void **result);
123+
PyAPI_FUNC(int) PyModule_Exec(PyObject *module);
124+
PyAPI_FUNC(int) PyModule_GetStateSize(PyObject *module, Py_ssize_t *result);
125+
PyAPI_FUNC(int) PyModule_GetToken(PyObject *module, void **result);
126126
#endif
127127

128128
#ifndef _Py_OPAQUE_PYOBJECT

0 commit comments

Comments
 (0)