Skip to content

Commit 61f6e5e

Browse files
authored
Merge branch 'main' into meta/crypto/c/hashlib/34/openssl-peek-error-159815
2 parents 0a4837e + 6fa2d64 commit 61f6e5e

142 files changed

Lines changed: 2292 additions & 1348 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/c-api/interp-lifecycle.rst‎

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -265,6 +265,48 @@ Initializing and finalizing the interpreter
265265
first initialized).
266266
267267
268+
.. c:function:: int Py_FrozenMain(int argc, char **argv)
269+
270+
.. index:: single: freeze utility
271+
272+
The main program for a "frozen" Python program (an executable that embeds
273+
the interpreter together with the bytecode of the program's modules, as
274+
produced by the :program:`freeze` utility; see :source:`Tools/freeze`).
275+
276+
This function initializes the interpreter, imports the frozen module named
277+
``__main__``, and finalizes the interpreter.
278+
The frozen modules must have been registered in
279+
:c:var:`PyImport_FrozenModules` before calling this function;
280+
it is a fatal error if ``__main__`` is not among them.
281+
282+
*argc* and *argv* are byte strings like the arguments of a C program's
283+
``main`` function, and are passed to the interpreter with
284+
:c:func:`PyConfig_SetBytesArgv`.
285+
Unlike :c:func:`Py_Main`, the arguments are not parsed as Python command
286+
line options (:c:member:`PyConfig.parse_argv` is ``0``), so all of them
287+
are made available to the program in :data:`sys.argv`.
288+
Apart from that, the interpreter uses the
289+
:ref:`Python Configuration <init-python-config>`, so environment variables
290+
such as :envvar:`PYTHONPATH` are honored.
291+
Warnings about the path configuration
292+
(:c:member:`PyConfig.pathconfig_warnings`) are suppressed.
293+
If :envvar:`PYTHONINSPECT` is set and standard input is a terminal, an
294+
interactive prompt is run after ``__main__`` has finished, as with the
295+
:option:`-i` option.
296+
297+
Return ``0`` if ``__main__`` ran without an unhandled exception, ``1``
298+
otherwise, and ``120`` if finalizing the interpreter failed (see
299+
:c:func:`Py_FinalizeEx`).
300+
An unhandled :exc:`SystemExit` terminates the process.
301+
If the interpreter cannot be initialized, the process exits via
302+
:c:func:`Py_ExitStatusException`.
303+
304+
On Windows, this function is not exported by the Python DLL.
305+
The :program:`freeze` utility compiles :file:`Python/frozenmain.c` into the
306+
frozen program instead, together with the Windows-specific hooks that the
307+
function requires.
308+
309+
268310
.. c:function:: int Py_RunMain(void)
269311
270312
Executes the main module in a fully configured CPython runtime.

‎Doc/c-api/structures.rst‎

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -760,11 +760,20 @@ The following flags can be used with :c:member:`PyMemberDef.flags`:
760760
.. versionchanged:: 3.12
761761
762762
The :c:macro:`!READONLY` macro was renamed to :c:macro:`Py_READONLY`.
763-
The :c:macro:`!PY_AUDIT_READ` macro was renamed with the ``Py_`` prefix.
763+
The :c:macro:`PY_AUDIT_READ` macro was renamed with the ``Py_`` prefix.
764764
The new names are now always available.
765765
Previously, these required ``#include "structmember.h"``.
766766
The header is still available and it provides the old names.
767767
768+
.. c:macro:: PY_AUDIT_READ
769+
770+
Soft-deprecated alias of :c:macro:`Py_AUDIT_READ` (note capitalization of
771+
the ``y``).
772+
Only available with ``#include "structmember.h"``.
773+
774+
.. soft-deprecated:: 3.12
775+
Use :c:macro:`Py_AUDIT_READ` instead.
776+
768777
.. _PyMemberDef-types:
769778
770779
Member types

‎Doc/library/ctypes.rst‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1107,6 +1107,17 @@ In addition, if a function argument is explicitly declared to be a pointer type
11071107
type (``c_int`` in this case) can be passed to the function. ctypes will apply
11081108
the required :func:`byref` conversion in this case automatically.
11091109

1110+
These conversions are also applied to the :attr:`!_as_parameter_` attribute of
1111+
an object passed for a pointer argument (see
1112+
:ref:`ctypes-calling-functions-with-own-custom-data-types`). So, for a
1113+
``POINTER(c_int)`` argument, an object whose :attr:`!_as_parameter_` is a
1114+
``c_int`` instance is passed by reference, and one whose :attr:`!_as_parameter_`
1115+
is a ``c_int`` array is accepted as well.
1116+
1117+
.. versionchanged:: next
1118+
Objects with an :attr:`!_as_parameter_` attribute now receive the same
1119+
implicit conversions for pointer arguments as the object they wrap.
1120+
11101121
To set a POINTER type field to ``NULL``, you can assign ``None``::
11111122

11121123
>>> bar.values = None

‎Doc/library/pathlib-parts.svg‎

Lines changed: 67 additions & 0 deletions
Loading

‎Doc/library/pathlib.rst‎

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -307,6 +307,21 @@ Methods and properties
307307

308308
from pathlib import PurePath, PurePosixPath, PureWindowsPath
309309

310+
The :attr:`~PurePath.parent`, :attr:`~PurePath.name`,
311+
:attr:`~PurePath.stem`, and :attr:`~PurePath.suffix` properties describe
312+
different parts of a path. For example, given::
313+
314+
>>> p = PurePosixPath('/srv/holy/grail.tar.gz')
315+
316+
.. image:: pathlib-parts.svg
317+
:align: center
318+
:class: invert-in-dark-mode
319+
:alt: For p = PurePosixPath('/srv/holy/grail.tar.gz'), p.parent is
320+
PurePosixPath('/srv/holy'), p.name is 'grail.tar.gz',
321+
p.stem is 'grail.tar', and p.suffix is '.gz'.
322+
323+
The stem excludes only the final suffix: in this example, it includes ``.tar``.
324+
310325
Pure paths provide the following methods and properties:
311326

312327
.. attribute:: PurePath.parser

‎Doc/library/sys.rst‎

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2432,6 +2432,26 @@ always available. Unless explicitly noted otherwise, all variables are read-only
24322432
.. versionadded:: 3.2
24332433

24342434

2435+
.. data:: EXIT_SUCCESS
2436+
2437+
An int you can use to indicate your program ended gracefully.
2438+
2439+
.. code-block:: python
2440+
2441+
sys.exit(sys.EXIT_SUCCESS)
2442+
2443+
.. versionadded:: 3.16
2444+
2445+
.. data:: EXIT_FAILURE
2446+
2447+
An int you can use to indicate your program encountered an error.
2448+
2449+
.. code-block:: python
2450+
2451+
sys.exit(sys.EXIT_FAILURE)
2452+
2453+
.. versionadded:: 3.16
2454+
24352455
.. rubric:: Citations
24362456

24372457
.. [C99] ISO/IEC 9899:1999. "Programming languages -- C." A public draft of this standard is available at https://www.open-std.org/jtc1/sc22/wg14/www/docs/n1256.pdf\ .

‎Doc/library/weakref.rst‎

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -227,8 +227,13 @@ than needed.
227227
.. versionchanged:: 3.9
228228
Added support for ``|`` and ``|=`` operators, as specified in :pep:`584`.
229229

230-
:class:`WeakValueDictionary` objects have an additional method that has the
231-
same issues as the :meth:`WeakKeyDictionary.keyrefs` method.
230+
:class:`WeakValueDictionary` objects have the following additional methods.
231+
These have the same issues as the :meth:`WeakKeyDictionary.keyrefs` method.
232+
233+
234+
.. method:: WeakValueDictionary.itervaluerefs()
235+
236+
Return an :term:`iterator` that yields the weak references to the values.
232237

233238

234239
.. method:: WeakValueDictionary.valuerefs()

0 commit comments

Comments
 (0)