Skip to content

Commit 2c91bb4

Browse files
authored
Merge branch 'main' into type_hasattr
2 parents 9157e1b + 1cf3d78 commit 2c91bb4

Some content is hidden

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

46 files changed

+767
-413
lines changed

Doc/c-api/apiabiversion.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,8 @@ See :ref:`stable` for a discussion of API and ABI stability across versions.
5858
Thus ``3.4.1a2`` is hexversion ``0x030401a2`` and ``3.10.0`` is
5959
hexversion ``0x030a00f0``.
6060

61+
Use this for numeric comparisons, e.g. ``#if PY_VERSION_HEX >= ...``.
62+
6163
This version is also available via the symbol :data:`Py_Version`.
6264

6365
.. c:var:: const unsigned long Py_Version

Doc/c-api/structures.rst

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -228,29 +228,30 @@ Implementing functions and methods
228228
Structure used to describe a method of an extension type. This structure has
229229
four fields:
230230
231-
+------------------+---------------+-------------------------------+
232-
| Field | C Type | Meaning |
233-
+==================+===============+===============================+
234-
| :attr:`ml_name` | const char \* | name of the method |
235-
+------------------+---------------+-------------------------------+
236-
| :attr:`ml_meth` | PyCFunction | pointer to the C |
237-
| | | implementation |
238-
+------------------+---------------+-------------------------------+
239-
| :attr:`ml_flags` | int | flag bits indicating how the |
240-
| | | call should be constructed |
241-
+------------------+---------------+-------------------------------+
242-
| :attr:`ml_doc` | const char \* | points to the contents of the |
243-
| | | docstring |
244-
+------------------+---------------+-------------------------------+
245-
246-
The :attr:`ml_meth` is a C function pointer. The functions may be of different
231+
.. c:member:: const char* ml_name
232+
233+
name of the method
234+
235+
.. c:member:: PyCFunction ml_meth
236+
237+
pointer to the C implementation
238+
239+
.. c:member:: int ml_flags
240+
241+
flags bits indicating how the call should be constructed
242+
243+
.. c:member:: const char* ml_doc
244+
245+
points to the contents of the docstring
246+
247+
The :c:member:`ml_meth` is a C function pointer. The functions may be of different
247248
types, but they always return :c:expr:`PyObject*`. If the function is not of
248249
the :c:type:`PyCFunction`, the compiler will require a cast in the method table.
249250
Even though :c:type:`PyCFunction` defines the first parameter as
250251
:c:expr:`PyObject*`, it is common that the method implementation uses the
251252
specific C type of the *self* object.
252253
253-
The :attr:`ml_flags` field is a bitfield which can include the following flags.
254+
The :c:member:`ml_flags` field is a bitfield which can include the following flags.
254255
The individual flags indicate either a calling convention or a binding
255256
convention.
256257

Doc/c-api/typeobj.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ Quick Reference
147147
+------------------------------------------------+-----------------------------------+-------------------+---+---+---+---+
148148
| :c:member:`~PyTypeObject.tp_vectorcall` | :c:type:`vectorcallfunc` | | | | | |
149149
+------------------------------------------------+-----------------------------------+-------------------+---+---+---+---+
150-
| :c:member:`~PyTypeObject.tp_watched` | char | | | | | |
150+
| [:c:member:`~PyTypeObject.tp_watched`] | char | | | | | |
151151
+------------------------------------------------+-----------------------------------+-------------------+---+---+---+---+
152152

153153
.. [#slots]

Doc/library/asyncio-eventloop.rst

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -932,7 +932,8 @@ Watching file descriptors
932932

933933
.. method:: loop.remove_reader(fd)
934934

935-
Stop monitoring the *fd* file descriptor for read availability.
935+
Stop monitoring the *fd* file descriptor for read availability. Returns
936+
``True`` if *fd* was previously being monitored for reads.
936937

937938
.. method:: loop.add_writer(fd, callback, *args)
938939

@@ -945,7 +946,8 @@ Watching file descriptors
945946

946947
.. method:: loop.remove_writer(fd)
947948

948-
Stop monitoring the *fd* file descriptor for write availability.
949+
Stop monitoring the *fd* file descriptor for write availability. Returns
950+
``True`` if *fd* was previously being monitored for writes.
949951

950952
See also :ref:`Platform Support <asyncio-platform-support>` section
951953
for some limitations of these methods.

Doc/library/pathlib.rst

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -490,7 +490,7 @@ Pure paths provide the following methods and properties:
490490
True
491491

492492

493-
.. method:: PurePath.is_relative_to(*other)
493+
.. method:: PurePath.is_relative_to(other)
494494

495495
Return whether or not this path is relative to the *other* path.
496496

@@ -502,6 +502,10 @@ Pure paths provide the following methods and properties:
502502

503503
.. versionadded:: 3.9
504504

505+
.. deprecated-removed:: 3.12 3.14
506+
507+
Passing additional arguments is deprecated; if supplied, they are joined
508+
with *other*.
505509

506510
.. method:: PurePath.is_reserved()
507511

@@ -564,7 +568,7 @@ Pure paths provide the following methods and properties:
564568
True
565569

566570

567-
.. method:: PurePath.relative_to(*other, walk_up=False)
571+
.. method:: PurePath.relative_to(other, walk_up=False)
568572

569573
Compute a version of this path relative to the path represented by
570574
*other*. If it's impossible, :exc:`ValueError` is raised::
@@ -581,7 +585,7 @@ Pure paths provide the following methods and properties:
581585
raise ValueError(error_message.format(str(self), str(formatted)))
582586
ValueError: '/etc/passwd' is not in the subpath of '/usr' OR one path is relative and the other is absolute.
583587

584-
When *walk_up* is False (the default), the path must start with *other*.
588+
When *walk_up* is False (the default), the path must start with *other*.
585589
When the argument is True, ``..`` entries may be added to form the
586590
relative path. In all other cases, such as the paths referencing
587591
different drives, :exc:`ValueError` is raised.::
@@ -605,6 +609,10 @@ When *walk_up* is False (the default), the path must start with *other*.
605609
.. versionadded:: 3.12
606610
The *walk_up* argument (old behavior is the same as ``walk_up=False``).
607611

612+
.. deprecated-removed:: 3.12 3.14
613+
614+
Passing additional positional arguments is deprecated; if supplied,
615+
they are joined with *other*.
608616

609617
.. method:: PurePath.with_name(name)
610618

Doc/library/stdtypes.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5480,7 +5480,7 @@ to mitigate denial of service attacks. This limit *only* applies to decimal or
54805480
other non-power-of-two number bases. Hexadecimal, octal, and binary conversions
54815481
are unlimited. The limit can be configured.
54825482

5483-
The :class:`int` type in CPython is an abitrary length number stored in binary
5483+
The :class:`int` type in CPython is an arbitrary length number stored in binary
54845484
form (commonly known as a "bignum"). There exists no algorithm that can convert
54855485
a string to a binary integer or a binary integer to a string in linear time,
54865486
*unless* the base is a power of 2. Even the best known algorithms for base 10
@@ -5544,7 +5544,7 @@ and :class:`str` or :class:`bytes`:
55445544
* ``int(string)`` with default base 10.
55455545
* ``int(string, base)`` for all bases that are not a power of 2.
55465546
* ``str(integer)``.
5547-
* ``repr(integer)``
5547+
* ``repr(integer)``.
55485548
* any other string conversion to base 10, for example ``f"{integer}"``,
55495549
``"{}".format(integer)``, or ``b"%d" % integer``.
55505550

@@ -5572,7 +5572,7 @@ command line flag to configure the limit:
55725572
:envvar:`PYTHONINTMAXSTRDIGITS` or :option:`-X int_max_str_digits <-X>`.
55735573
If both the env var and the ``-X`` option are set, the ``-X`` option takes
55745574
precedence. A value of *-1* indicates that both were unset, thus a value of
5575-
:data:`sys.int_info.default_max_str_digits` was used during initilization.
5575+
:data:`sys.int_info.default_max_str_digits` was used during initialization.
55765576

55775577
From code, you can inspect the current limit and set a new one using these
55785578
:mod:`sys` APIs:

Doc/library/zipfile.rst

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,8 @@ ZipFile Objects
273273
Access a member of the archive as a binary file-like object. *name*
274274
can be either the name of a file within the archive or a :class:`ZipInfo`
275275
object. The *mode* parameter, if included, must be ``'r'`` (the default)
276-
or ``'w'``. *pwd* is the password used to decrypt encrypted ZIP files.
276+
or ``'w'``. *pwd* is the password used to decrypt encrypted ZIP files as a
277+
:class:`bytes` object.
277278

278279
:meth:`~ZipFile.open` is also a context manager and therefore supports the
279280
:keyword:`with` statement::
@@ -325,7 +326,7 @@ ZipFile Objects
325326
must be its full name or a :class:`ZipInfo` object. Its file information is
326327
extracted as accurately as possible. *path* specifies a different directory
327328
to extract to. *member* can be a filename or a :class:`ZipInfo` object.
328-
*pwd* is the password used for encrypted files.
329+
*pwd* is the password used for encrypted files as a :class:`bytes` object.
329330

330331
Returns the normalized path created (a directory or new file).
331332

@@ -352,7 +353,7 @@ ZipFile Objects
352353
Extract all members from the archive to the current working directory. *path*
353354
specifies a different directory to extract to. *members* is optional and must
354355
be a subset of the list returned by :meth:`namelist`. *pwd* is the password
355-
used for encrypted files.
356+
used for encrypted files as a :class:`bytes` object.
356357

357358
.. warning::
358359

@@ -377,16 +378,16 @@ ZipFile Objects
377378

378379
.. method:: ZipFile.setpassword(pwd)
379380

380-
Set *pwd* as default password to extract encrypted files.
381+
Set *pwd* (a :class:`bytes` object) as default password to extract encrypted files.
381382

382383

383384
.. method:: ZipFile.read(name, pwd=None)
384385

385386
Return the bytes of the file *name* in the archive. *name* is the name of the
386387
file in the archive, or a :class:`ZipInfo` object. The archive must be open for
387-
read or append. *pwd* is the password used for encrypted files and, if specified,
388-
it will override the default password set with :meth:`setpassword`. Calling
389-
:meth:`read` on a ZipFile that uses a compression method other than
388+
read or append. *pwd* is the password used for encrypted files as a :class:`bytes`
389+
object and, if specified, overrides the default password set with :meth:`setpassword`.
390+
Calling :meth:`read` on a ZipFile that uses a compression method other than
390391
:const:`ZIP_STORED`, :const:`ZIP_DEFLATED`, :const:`ZIP_BZIP2` or
391392
:const:`ZIP_LZMA` will raise a :exc:`NotImplementedError`. An error will also
392393
be raised if the corresponding compression module is not available.

Doc/reference/compound_stmts.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -506,7 +506,7 @@ The execution of the :keyword:`with` statement with one "item" proceeds as follo
506506
method returns without an error, then :meth:`__exit__` will always be
507507
called. Thus, if an error occurs during the assignment to the target list,
508508
it will be treated the same as an error occurring within the suite would
509-
be. See step 6 below.
509+
be. See step 7 below.
510510

511511
#. The suite is executed.
512512

Doc/tutorial/introduction.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,7 @@ Indices may also be negative numbers, to start counting from the right::
269269
Note that since -0 is the same as 0, negative indices start from -1.
270270

271271
In addition to indexing, *slicing* is also supported. While indexing is used
272-
to obtain individual characters, *slicing* allows you to obtain substring::
272+
to obtain individual characters, *slicing* allows you to obtain a substring::
273273

274274
>>> word[0:2] # characters from position 0 (included) to 2 (excluded)
275275
'Py'

Doc/whatsnew/3.11.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2319,7 +2319,7 @@ Porting to Python 3.11
23192319
can define the following macros and use them throughout
23202320
the code (credit: these were copied from the ``mypy`` codebase)::
23212321

2322-
#if PY_MAJOR_VERSION >= 3 && PY_MINOR_VERSION >= 8
2322+
#if PY_VERSION_HEX >= 0x03080000
23232323
# define CPy_TRASHCAN_BEGIN(op, dealloc) Py_TRASHCAN_BEGIN(op, dealloc)
23242324
# define CPy_TRASHCAN_END(op) Py_TRASHCAN_END
23252325
#else

Include/internal/pycore_parser.h

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ extern "C" {
99
#endif
1010

1111

12+
#include "pycore_ast.h" // struct _expr
13+
#include "pycore_global_strings.h" // _Py_DECLARE_STR()
1214
#include "pycore_pyarena.h" // PyArena
1315

1416

@@ -22,9 +24,22 @@ struct _parser_runtime_state {
2224
#else
2325
int _not_used;
2426
#endif
27+
struct _expr dummy_name;
2528
};
2629

27-
30+
_Py_DECLARE_STR(empty, "")
31+
#define _parser_runtime_state_INIT \
32+
{ \
33+
.dummy_name = { \
34+
.kind = Name_kind, \
35+
.v.Name.id = &_Py_STR(empty), \
36+
.v.Name.ctx = Load, \
37+
.lineno = 1, \
38+
.col_offset = 0, \
39+
.end_lineno = 1, \
40+
.end_col_offset = 0, \
41+
}, \
42+
}
2843

2944
extern struct _mod* _PyParser_ASTFromString(
3045
const char *str,

Include/internal/pycore_runtime_init.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ extern "C" {
99
#endif
1010

1111
#include "pycore_object.h"
12+
#include "pycore_parser.h"
1213
#include "pycore_pymem_init.h"
1314
#include "pycore_obmalloc_init.h"
1415

@@ -32,6 +33,7 @@ extern "C" {
3233
until _PyInterpreterState_Enable() is called. */ \
3334
.next_id = -1, \
3435
}, \
36+
.parser = _parser_runtime_state_INIT, \
3537
.imports = { \
3638
.lock = { \
3739
.mutex = NULL, \

Include/pystats.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ extern "C" {
88

99
#ifdef Py_STATS
1010

11-
#define SPECIALIZATION_FAILURE_KINDS 32
11+
#define SPECIALIZATION_FAILURE_KINDS 36
1212

1313
/* Stats for determining who is calling PyEval_EvalFrame */
1414
#define EVAL_CALL_TOTAL 0

Lib/ctypes/__init__.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -444,7 +444,10 @@ def __init__(self, dlltype):
444444
def __getattr__(self, name):
445445
if name[0] == '_':
446446
raise AttributeError(name)
447-
dll = self._dlltype(name)
447+
try:
448+
dll = self._dlltype(name)
449+
except OSError:
450+
raise AttributeError(name)
448451
setattr(self, name, dll)
449452
return dll
450453

0 commit comments

Comments
 (0)