Skip to content

Commit 6b73046

Browse files
authored
Merge branch 'main' into int_freelist
2 parents 9df776b + 2313f84 commit 6b73046

Some content is hidden

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

53 files changed

+647
-318
lines changed

Doc/c-api/marshal.rst

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,12 @@ binary mode.
1313

1414
Numeric values are stored with the least significant byte first.
1515

16-
The module supports two versions of the data format: version 0 is the
17-
historical version, version 1 shares interned strings in the file, and upon
18-
unmarshalling. Version 2 uses a binary format for floating-point numbers.
19-
``Py_MARSHAL_VERSION`` indicates the current file format (currently 2).
16+
The module supports several versions of the data format; see
17+
the :py:mod:`Python module documentation <marshal>` for details.
2018

19+
.. c:macro:: Py_MARSHAL_VERSION
20+
21+
The current format version. See :py:data:`marshal.version`.
2122

2223
.. c:function:: void PyMarshal_WriteLongToFile(long value, FILE *file, int version)
2324

Doc/library/marshal.rst

Lines changed: 46 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -38,23 +38,39 @@ supports a substantially wider range of objects than marshal.
3838
maliciously constructed data. Never unmarshal data received from an
3939
untrusted or unauthenticated source.
4040

41+
There are functions that read/write files as well as functions operating on
42+
bytes-like objects.
43+
4144
.. index:: object; code, code object
4245

4346
Not all Python object types are supported; in general, only objects whose value
4447
is independent from a particular invocation of Python can be written and read by
45-
this module. The following types are supported: booleans, integers, floating-point
46-
numbers, complex numbers, strings, bytes, bytearrays, tuples, lists, sets,
47-
frozensets, dictionaries, and code objects (if *allow_code* is true),
48-
where it should be understood that
49-
tuples, lists, sets, frozensets and dictionaries are only supported as long as
50-
the values contained therein are themselves supported. The
51-
singletons :const:`None`, :const:`Ellipsis` and :exc:`StopIteration` can also be
52-
marshalled and unmarshalled.
53-
For format *version* lower than 3, recursive lists, sets and dictionaries cannot
54-
be written (see below).
48+
this module. The following types are supported:
49+
50+
* Numeric types: :class:`int`, :class:`bool`, :class:`float`, :class:`complex`.
51+
* Strings (:class:`str`) and :class:`bytes`.
52+
:term:`Bytes-like objects <bytes-like object>` like :class:`bytearray` are
53+
marshalled as :class:`!bytes`.
54+
* Containers: :class:`tuple`, :class:`list`, :class:`set`, :class:`frozenset`,
55+
and (since :data:`version` 5), :class:`slice`.
56+
It should be understood that these are supported only if the values contained
57+
therein are themselves supported.
58+
Recursive containers are supported since :data:`version` 3.
59+
* The singletons :const:`None`, :const:`Ellipsis` and :exc:`StopIteration`.
60+
* :class:`code` objects, if *allow_code* is true. See note above about
61+
version dependence.
62+
63+
.. versionchanged:: 3.4
64+
65+
* Added format version 3, which supports marshalling recursive lists, sets
66+
and dictionaries.
67+
* Added format version 4, which supports efficient representations
68+
of short strings.
69+
70+
.. versionchanged:: next
71+
72+
Added format version 5, which allows marshalling slices.
5573

56-
There are functions that read/write files as well as functions operating on
57-
bytes-like objects.
5874

5975
The module defines these functions:
6076

@@ -140,11 +156,24 @@ In addition, the following constants are defined:
140156

141157
.. data:: version
142158

143-
Indicates the format that the module uses. Version 0 is the historical
144-
format, version 1 shares interned strings and version 2 uses a binary format
145-
for floating-point numbers.
146-
Version 3 adds support for object instancing and recursion.
147-
The current version is 4.
159+
Indicates the format that the module uses.
160+
Version 0 is the historical first version; subsequent versions
161+
add new features.
162+
Generally, a new version becomes the default when it is introduced.
163+
164+
======= =============== ====================================================
165+
Version Available since New features
166+
======= =============== ====================================================
167+
1 Python 2.4 Sharing interned strings
168+
------- --------------- ----------------------------------------------------
169+
2 Python 2.5 Binary representation of floats
170+
------- --------------- ----------------------------------------------------
171+
3 Python 3.4 Support for object instancing and recursion
172+
------- --------------- ----------------------------------------------------
173+
4 Python 3.4 Efficient representation of short strings
174+
------- --------------- ----------------------------------------------------
175+
5 Python 3.14 Support for :class:`slice` objects
176+
======= =============== ====================================================
148177

149178

150179
.. rubric:: Footnotes
@@ -154,4 +183,3 @@ In addition, the following constants are defined:
154183
around in a self-contained form. Strictly speaking, "to marshal" means to
155184
convert some data from internal to external form (in an RPC buffer for instance)
156185
and "unmarshalling" for the reverse process.
157-

Doc/library/platform.rst

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -359,3 +359,15 @@ Android Platform
359359
<https://storage.googleapis.com/play_public/supported_devices.html>`__.
360360

361361
.. versionadded:: 3.13
362+
363+
364+
Miscellaneous
365+
-------------
366+
367+
.. function:: invalidate_caches()
368+
369+
Clear out the internal cache of information, such as the :func:`uname`.
370+
This is typically useful when the platform's :func:`node` is changed
371+
by an external process and one needs to retrieve the updated value.
372+
373+
.. versionadded:: 3.14

Doc/library/urllib.parse.rst

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -407,6 +407,15 @@ or on combining URL components into a URL string.
407407
If you do not want that behavior, preprocess the *url* with :func:`urlsplit` and
408408
:func:`urlunsplit`, removing possible *scheme* and *netloc* parts.
409409

410+
.. warning::
411+
412+
Because an absolute URL may be passed as the ``url`` parameter, it is
413+
generally **not secure** to use ``urljoin`` with an attacker-controlled
414+
``url``. For example in,
415+
``urljoin("https://website.com/users/", username)``, if ``username`` can
416+
contain an absolute URL, the result of ``urljoin`` will be the absolute
417+
URL.
418+
410419

411420
.. versionchanged:: 3.5
412421

Doc/library/uuid.rst

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@
1111
--------------
1212

1313
This module provides immutable :class:`UUID` objects (the :class:`UUID` class)
14-
and the functions :func:`uuid1`, :func:`uuid3`, :func:`uuid4`, :func:`uuid5` for
15-
generating version 1, 3, 4, 5, and 8 UUIDs as specified in :rfc:`9562` (which
16-
supersedes :rfc:`4122`).
14+
and the functions :func:`uuid1`, :func:`uuid3`, :func:`uuid4`, :func:`uuid5`,
15+
and :func:`uuid.uuid8` for generating version 1, 3, 4, 5, and 8 UUIDs as
16+
specified in :rfc:`9562` (which supersedes :rfc:`4122`).
1717

1818
If all you want is a unique ID, you should probably call :func:`uuid1` or
1919
:func:`uuid4`. Note that :func:`uuid1` may compromise privacy since it creates
@@ -323,6 +323,9 @@ The following options are accepted:
323323
Specify the function name to use to generate the uuid. By default :func:`uuid4`
324324
is used.
325325

326+
.. versionadded:: next
327+
Allow generating UUID version 8.
328+
326329
.. option:: -n <namespace>
327330
--namespace <namespace>
328331

Doc/reference/simple_stmts.rst

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -408,9 +408,9 @@ The extended form, ``assert expression1, expression2``, is equivalent to ::
408408

409409
These equivalences assume that :const:`__debug__` and :exc:`AssertionError` refer to
410410
the built-in variables with those names. In the current implementation, the
411-
built-in variable :const:`__debug__` is ``True`` under normal circumstances,
411+
built-in variable ``__debug__`` is ``True`` under normal circumstances,
412412
``False`` when optimization is requested (command line option :option:`-O`). The current
413-
code generator emits no code for an assert statement when optimization is
413+
code generator emits no code for an :keyword:`assert` statement when optimization is
414414
requested at compile time. Note that it is unnecessary to include the source
415415
code for the expression that failed in the error message; it will be displayed
416416
as part of the stack trace.
@@ -533,8 +533,8 @@ The :keyword:`!yield` statement
533533
yield_stmt: `yield_expression`
534534

535535
A :keyword:`yield` statement is semantically equivalent to a :ref:`yield
536-
expression <yieldexpr>`. The yield statement can be used to omit the parentheses
537-
that would otherwise be required in the equivalent yield expression
536+
expression <yieldexpr>`. The ``yield`` statement can be used to omit the
537+
parentheses that would otherwise be required in the equivalent yield expression
538538
statement. For example, the yield statements ::
539539

540540
yield <expr>
@@ -546,7 +546,7 @@ are equivalent to the yield expression statements ::
546546
(yield from <expr>)
547547

548548
Yield expressions and statements are only used when defining a :term:`generator`
549-
function, and are only used in the body of the generator function. Using yield
549+
function, and are only used in the body of the generator function. Using :keyword:`yield`
550550
in a function definition is sufficient to cause that definition to create a
551551
generator function instead of a normal function.
552552

@@ -966,12 +966,12 @@ The :keyword:`!global` statement
966966
.. productionlist:: python-grammar
967967
global_stmt: "global" `identifier` ("," `identifier`)*
968968

969-
The :keyword:`global` causes the listed identifiers to be interpreted
969+
The :keyword:`global` statement causes the listed identifiers to be interpreted
970970
as globals. It would be impossible to assign to a global variable without
971971
:keyword:`!global`, although free variables may refer to globals without being
972972
declared global.
973973

974-
The global statement applies to the entire scope of a function or
974+
The :keyword:`global` statement applies to the entire scope of a function or
975975
class body. A :exc:`SyntaxError` is raised if a variable is used or
976976
assigned to prior to its global declaration in the scope.
977977

@@ -1009,7 +1009,7 @@ identifiers. If a name is bound in more than one nonlocal scope, the
10091009
nearest binding is used. If a name is not bound in any nonlocal scope,
10101010
or if there is no nonlocal scope, a :exc:`SyntaxError` is raised.
10111011

1012-
The nonlocal statement applies to the entire scope of a function or
1012+
The :keyword:`nonlocal` statement applies to the entire scope of a function or
10131013
class body. A :exc:`SyntaxError` is raised if a variable is used or
10141014
assigned to prior to its nonlocal declaration in the scope.
10151015

Doc/using/configure.rst

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -454,15 +454,6 @@ Options for third-party dependencies
454454
WebAssembly Options
455455
-------------------
456456

457-
.. option:: --with-emscripten-target=[browser|node]
458-
459-
Set build flavor for ``wasm32-emscripten``.
460-
461-
* ``browser`` (default): preload minimal stdlib, default MEMFS.
462-
* ``node``: NODERAWFS and pthread support.
463-
464-
.. versionadded:: 3.11
465-
466457
.. option:: --enable-wasm-dynamic-linking
467458

468459
Turn on dynamic linking support for WASM.
@@ -1097,7 +1088,8 @@ CPython project) this is usually the ``all`` target. The
10971088
all`` will build. The three choices are:
10981089

10991090
* ``profile-opt`` (configured with ``--enable-optimizations``)
1100-
* ``build_wasm`` (configured with ``--with-emscripten-target``)
1091+
* ``build_wasm`` (chosen if the host platform matches ``wasm32-wasi*`` or
1092+
``wasm32-emscripten``)
11011093
* ``build_all`` (configured without explicitly using either of the others)
11021094

11031095
Depending on the most recent source file changes, Make will rebuild

Doc/whatsnew/3.14.rst

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -454,6 +454,14 @@ pathlib
454454
(Contributed by Barney Gale in :gh:`125413`.)
455455

456456

457+
platform
458+
--------
459+
460+
* Add :func:`platform.invalidate_caches` to invalidate the cached results.
461+
462+
(Contributed by Bénédikt Tran in :gh:`122549`.)
463+
464+
457465
pdb
458466
---
459467

@@ -783,6 +791,16 @@ Changes in the Python API
783791
Build changes
784792
=============
785793

794+
PEP 761: Discontinuation of PGP signatures
795+
------------------------------------------
796+
797+
PGP signatures will not be available for CPython 3.14 and onwards.
798+
Users verifying artifacts must use `Sigstore verification materials`_ for
799+
verifying CPython artifacts. This change in release process is specified
800+
in :pep:`761`.
801+
802+
.. _Sigstore verification materials: https://www.python.org/downloads/metadata/sigstore/
803+
786804

787805
C API changes
788806
=============

Include/marshal.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ PyAPI_FUNC(PyObject *) PyMarshal_ReadObjectFromString(const char *,
1313
Py_ssize_t);
1414
PyAPI_FUNC(PyObject *) PyMarshal_WriteObjectToString(PyObject *, int);
1515

16-
#define Py_MARSHAL_VERSION 4
16+
#define Py_MARSHAL_VERSION 5
1717

1818
PyAPI_FUNC(long) PyMarshal_ReadLongFromFile(FILE *);
1919
PyAPI_FUNC(int) PyMarshal_ReadShortFromFile(FILE *);

Lib/calendar.py

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,9 @@
2727
error = ValueError
2828

2929
# Exceptions raised for bad input
30-
class IllegalMonthError(ValueError):
30+
# This is trick for backward compatibility. Since 3.13, we will raise IllegalMonthError instead of
31+
# IndexError for bad month number(out of 1-12). But we can't remove IndexError for backward compatibility.
32+
class IllegalMonthError(ValueError, IndexError):
3133
def __init__(self, month):
3234
self.month = month
3335
def __str__(self):
@@ -158,11 +160,14 @@ def weekday(year, month, day):
158160
return Day(datetime.date(year, month, day).weekday())
159161

160162

163+
def _validate_month(month):
164+
if not 1 <= month <= 12:
165+
raise IllegalMonthError(month)
166+
161167
def monthrange(year, month):
162168
"""Return weekday of first day of month (0-6 ~ Mon-Sun)
163169
and number of days (28-31) for year, month."""
164-
if not 1 <= month <= 12:
165-
raise IllegalMonthError(month)
170+
_validate_month(month)
166171
day1 = weekday(year, month, 1)
167172
ndays = mdays[month] + (month == FEBRUARY and isleap(year))
168173
return day1, ndays
@@ -370,6 +375,8 @@ def formatmonthname(self, theyear, themonth, width, withyear=True):
370375
"""
371376
Return a formatted month name.
372377
"""
378+
_validate_month(themonth)
379+
373380
s = month_name[themonth]
374381
if withyear:
375382
s = "%s %r" % (s, theyear)
@@ -500,6 +507,7 @@ def formatmonthname(self, theyear, themonth, withyear=True):
500507
"""
501508
Return a month name as a table row.
502509
"""
510+
_validate_month(themonth)
503511
if withyear:
504512
s = '%s %s' % (month_name[themonth], theyear)
505513
else:
@@ -786,6 +794,8 @@ def main(args=None):
786794
if options.month is None:
787795
optdict["c"] = options.spacing
788796
optdict["m"] = options.months
797+
if options.month is not None:
798+
_validate_month(options.month)
789799
if options.year is None:
790800
result = cal.formatyear(datetime.date.today().year, **optdict)
791801
elif options.month is None:

0 commit comments

Comments
 (0)