Skip to content

Commit e10e451

Browse files
authored
Merge branch 'main' into gh-50720-urllib
2 parents fd2a709 + 1259f16 commit e10e451

115 files changed

Lines changed: 1167 additions & 457 deletions

File tree

Some content is hidden

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

‎Doc/builtins/exceptions.rst‎

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -396,10 +396,9 @@ The following exceptions are the exceptions that are usually raised.
396396

397397
.. attribute:: strerror
398398

399-
The corresponding error message, as provided by
400-
the operating system. It is formatted by the C
401-
functions :c:func:`!perror` under POSIX, and :c:func:`!FormatMessage`
402-
under Windows.
399+
The corresponding error message, as provided by the operating system.
400+
Under POSIX, it is obtained using the C functions :c:func:`!strerror`
401+
or :c:func:`!strerror_r`; under Windows, :c:func:`!FormatMessage` is used.
403402

404403
.. attribute:: filename
405404
filename2
@@ -567,11 +566,6 @@ The following exceptions are the exceptions that are usually raised.
567566
The column in the end line where the error occurred finishes. This is
568567
1-indexed: the first character in the line has an ``offset`` of 1.
569568

570-
For errors in f-string fields, the message is prefixed by "f-string: "
571-
and the offsets are offsets in a text constructed from the replacement
572-
expression. For example, compiling f'Bad {a b} field' results in this
573-
args attribute: ('f-string: ...', ('', 1, 2, '(a b)\n', 1, 5)).
574-
575569
.. versionchanged:: 3.10
576570
Added the :attr:`end_lineno` and :attr:`end_offset` attributes.
577571

‎Doc/builtins/functions.rst‎

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -772,7 +772,7 @@ are always available. They are listed here in alphabetical order.
772772
still access all builtins.
773773

774774
The *closure* argument specifies a closure--a tuple of cellvars.
775-
It's only valid when the *object* is a code object containing
775+
It's only valid when *source* is a code object containing
776776
:term:`free (closure) variables <closure variable>`.
777777
The length of the tuple must exactly match the length of the code object's
778778
:attr:`~codeobject.co_freevars` attribute.
@@ -1853,8 +1853,6 @@ are always available. They are listed here in alphabetical order.
18531853
including the name and address of the object. A class can control what this
18541854
function returns for its instances
18551855
by defining a :meth:`~object.__repr__` method.
1856-
If :func:`sys.displayhook` is not accessible, this function will raise
1857-
:exc:`RuntimeError`.
18581856

18591857
This class has a custom representation that can be evaluated::
18601858

@@ -2168,10 +2166,10 @@ are always available. They are listed here in alphabetical order.
21682166

21692167
When called directly within an ordinary method of a class, both arguments may
21702168
be omitted ("zero-argument :func:`!super`"). In this case, *type* will be the
2171-
enclosing class, and *obj* will be the first argument of the immediately
2172-
enclosing function (typically ``self``). (This means that zero-argument
2169+
enclosing class, and *object_or_type* will be the first argument of the
2170+
immediately enclosing function (typically ``self``). Zero-argument
21732171
:func:`!super` will not work as expected within nested functions, including
2174-
generator expressions, which implicitly create nested functions.)
2172+
generator expressions, which implicitly create nested functions.
21752173

21762174
There are two typical use cases for *super*. In a class hierarchy with
21772175
single inheritance, *super* can be used to refer to parent classes without
@@ -2430,10 +2428,9 @@ are always available. They are listed here in alphabetical order.
24302428
determine the package context of the :keyword:`import` statement.
24312429

24322430
*level* specifies whether to use absolute or relative imports. ``0`` (the
2433-
default) means only perform absolute imports. Positive values for
2434-
*level* indicate the number of parent directories to search relative to the
2435-
directory of the module calling :func:`__import__` (see :pep:`328` for the
2436-
details).
2431+
default) means only perform absolute imports. For relative imports,
2432+
``1`` refers to the current package, ``2`` to its parent package, and so on
2433+
(see :pep:`328` for details).
24372434

24382435
When the *name* variable is of the form ``package.module``, normally, the
24392436
top-level package (the name up till the first dot) is returned, *not* the

‎Doc/builtins/stdtypes.rst‎

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3780,8 +3780,8 @@ objects.
37803780

37813781
If the :class:`bytearray` needs to shrink, bytes beyond *size* are truncated.
37823782

3783-
If the :class:`bytearray` needs to grow, all new bytes, those beyond *size*,
3784-
will be set to null bytes.
3783+
If the :class:`bytearray` needs to grow, all new bytes will be set to null
3784+
bytes.
37853785

37863786

37873787
This is equivalent to:
@@ -5616,9 +5616,8 @@ Note, the non-operator versions of the :meth:`~set.update`,
56165616
argument.
56175617

56185618
Note, the *elem* argument to the :meth:`~object.__contains__`,
5619-
:meth:`~set.remove`, and
5620-
:meth:`~set.discard` methods may be a set. To support searching for an equivalent
5621-
frozenset, a temporary one is created from *elem*.
5619+
:meth:`~set.remove`, and :meth:`~set.discard` methods may be a set. In this case,
5620+
an equivalent frozenset is searched for.
56225621

56235622
Sets and frozensets are :ref:`generic <generics>` over the type of their elements.
56245623

@@ -5668,7 +5667,7 @@ can be used interchangeably to index the same dictionary entry.
56685667

56695668
* Use a comma-separated list of ``key: value`` pairs within braces:
56705669
``{'jack': 4098, 'sjoerd': 4127}`` or ``{4098: 'jack', 4127: 'sjoerd'}``
5671-
* Use a dict comprehension: ``{}``, ``{x: x ** 2 for x in range(10)}``
5670+
* Use a dict comprehension: ``{x: x ** 2 for x in range(10)}``
56725671
* Use the type constructor: ``dict()``,
56735672
``dict([('foo', 100), ('bar', 200)])``, ``dict(foo=100, bar=200)``
56745673

@@ -5879,9 +5878,8 @@ can be used interchangeably to index the same dictionary entry.
58795878
Return a new view of the dictionary's values. See the
58805879
:ref:`documentation of view objects <dict-views>`.
58815880

5882-
An equality comparison between one ``dict.values()`` view and another
5883-
will always return ``False``. This also applies when comparing
5884-
``dict.values()`` to itself::
5881+
An equality comparison between two distinct ``dict.values()`` views
5882+
will always return ``False``, even for views of the same dictionary::
58855883

58865884
>>> d = {'a': 1}
58875885
>>> d.values() == d.values()

‎Doc/c-api/code.rst‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -315,9 +315,9 @@ may change without deprecation warnings.
315315
316316
Return a new opaque index value used to adding data to code objects.
317317
318-
You generally call this function once (per interpreter) and use the result
319-
with ``PyCode_GetExtra`` and ``PyCode_SetExtra`` to manipulate
320-
data on individual code objects.
318+
You generally call this function once (per interpreter). Use the result with
319+
:c:func:`PyUnstable_Code_GetExtra` and :c:func:`PyUnstable_Code_SetExtra`
320+
to manipulate data on individual code objects.
321321
322322
If *free* is not ``NULL``: when a code object is deallocated,
323323
*free* will be called on non-``NULL`` data stored under the new index.

‎Doc/c-api/codec.rst‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ Codec lookup API
4747
4848
In the following functions, the *encoding* string is looked up converted to all
4949
lower-case characters, which makes encodings looked up through this mechanism
50-
effectively case-insensitive. If no codec is found, a :exc:`KeyError` is set
50+
effectively case-insensitive. If no codec is found, a :exc:`LookupError` is set
5151
and ``NULL`` returned.
5252
5353
.. c:function:: PyObject* PyCodec_Encoder(const char *encoding)

‎Doc/c-api/extension-modules.rst‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ For example, a module called ``spam`` would be defined like this::
8686
static PySlot spam_slots[] = {
8787
PySlot_STATIC_DATA(Py_mod_abi, &abi_info),
8888
PySlot_STATIC_DATA(Py_mod_name, "spam"),
89-
PySlot_FUNC(Py_mod_init, spam_init_function),
89+
PySlot_FUNC(Py_mod_exec, spam_init_function),
9090
...
9191
PySlot_END
9292
};

‎Doc/c-api/gcsupport.rst‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ rules:
127127
128128
.. c:macro:: PyObject_GC_Resize(TYPE, op, newsize)
129129
130-
Resize an object allocated by :c:macro:`PyObject_NewVar`.
130+
Resize an object allocated by :c:macro:`PyObject_GC_NewVar`.
131131
Returns the resized object of type ``TYPE*`` (refers to any C type)
132132
or ``NULL`` on failure.
133133

‎Doc/deprecations/pending-removal-in-3.20.rst‎

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,27 @@ Pending removal in Python 3.20
3939

4040
(Contributed by Hugo van Kemenade and Stan Ulbrych in :gh:`76007`.)
4141

42+
* The ``__author__``, ``__credits__``, ``__copyright__`` and ``__date__``
43+
attributes have been deprecated in these standard library modules and will
44+
be removed in Python 3.20. Attribution is preserved in the source code
45+
and the version control history.
46+
47+
- :mod:`bz2`
48+
- :mod:`concurrent.futures`
49+
- :mod:`inspect`
50+
- :mod:`io`
51+
- :mod:`json`
52+
- :mod:`logging`
53+
- :mod:`optparse`
54+
- :mod:`platform`
55+
- :mod:`pydoc`
56+
- :mod:`tarfile`
57+
- :mod:`tkinter.ttk`
58+
- :mod:`tokenize`
59+
- :mod:`uuid`
60+
61+
(Contributed by Stan Ulbrych in :gh:`159240`.)
62+
4263
* Deprecations defined by :pep:`829`:
4364

4465
* Warnings are produced for ``import`` lines found in :file:`{name}.pth`

‎Doc/extending/extending.rst‎

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -334,6 +334,8 @@ event code, you might use the following code::
334334
PyObject *arglist;
335335
...
336336
arglist = Py_BuildValue("(l)", eventcode);
337+
if (arglist == NULL)
338+
return NULL;
337339
result = PyObject_CallObject(my_callback, arglist);
338340
Py_DECREF(arglist);
339341
if (result == NULL)
@@ -342,17 +344,24 @@ event code, you might use the following code::
342344
Py_DECREF(result);
343345

344346
Note the placement of ``Py_DECREF(arglist)`` immediately after the call, before
345-
the error check! Also note that strictly speaking this code is not complete:
346-
:c:func:`Py_BuildValue` may run out of memory, and this should be checked.
347+
the error check!
347348

348349
You may also call a function with keyword arguments by using
349350
:c:func:`PyObject_Call`, which supports arguments and keyword arguments. As in
350351
the above example, we use :c:func:`Py_BuildValue` to construct the dictionary. ::
351352

352-
PyObject *dict;
353+
PyObject *arglist, *dict;
353354
...
355+
arglist = PyTuple_New(0);
356+
if (arglist == NULL)
357+
return NULL;
354358
dict = Py_BuildValue("{s:i}", "name", val);
355-
result = PyObject_Call(my_callback, NULL, dict);
359+
if (dict == NULL) {
360+
Py_DECREF(arglist);
361+
return NULL;
362+
}
363+
result = PyObject_Call(my_callback, arglist, dict);
364+
Py_DECREF(arglist);
356365
Py_DECREF(dict);
357366
if (result == NULL)
358367
return NULL; /* Pass error back */

‎Doc/extending/first-extension-module.rst‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -378,7 +378,7 @@ Add this array just below the ``spam_system`` function:
378378
As with module slots, a zero-filled sentinel marks the end of the array.
379379

380380
Next, we'll add the method to the module.
381-
Add a :c:data:`Py_mod_methods` slot to your :c:type:`PyMethodDef` array:
381+
Add a :c:data:`Py_mod_methods` slot to your :c:type:`PySlot` array:
382382

383383
.. literalinclude:: ../includes/capi-extension/spammodule-01.c
384384
:start-after: /// Module slot table
@@ -518,7 +518,7 @@ Add an ``if`` block for this:
518518
static PyObject *
519519
spam_system(PyObject *self, PyObject *arg)
520520
{
521-
const char *command = PyUnicode_AsUTF8AndSize(arg);
521+
const char *command = PyUnicode_AsUTF8AndSize(arg, NULL);
522522
if (command == NULL) {
523523
return NULL;
524524
}
@@ -548,7 +548,7 @@ the ``char *`` buffer, and using its result instead of the ``3``:
548548
static PyObject *
549549
spam_system(PyObject *self, PyObject *arg)
550550
{
551-
const char *command = PyUnicode_AsUTF8AndSize(arg);
551+
const char *command = PyUnicode_AsUTF8AndSize(arg, NULL);
552552
if (command == NULL) {
553553
return NULL;
554554
}

0 commit comments

Comments
 (0)