8000 Merge branch 'main' into speedup-posixpath.abspath · python/cpython@9fcedb5 · GitHub
[go: up one dir, main page]

Skip to content

Commit 9fcedb5

Browse files
authored
Merge branch 'main' into speedup-posixpath.abspath
2 parents 3d2836e + 456c29c commit 9fcedb5
  • Lib
  • Mac/BuildScript/scripts
  • Misc
  • Modules
  • Objects
  • Programs
  • Python
  • Tools
  • Some content is hidden

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

    148 files changed

    +3085
    -873
    lines changed

    .github/workflows/build.yml

    Lines changed: 1 addition & 0 deletions
    Original file line numberDiff line numberDiff line change
    @@ -137,6 +137,7 @@ jobs:
    137137
    uses: actions/cache@v4
    138138
    with:
    139139
    path: config.cache
    140+
    # Include env.pythonLocation in key to avoid changes in environment when setup-python updates Python
    140141
    key: ${{ github.job }}-${{ runner.os }}-${{ env.IMAGE_VERSION }}-${{ needs.check_source.outputs.config_hash }}-${{ env.pythonLocation }}
    141142
    - name: Install Dependencies
    142143
    run: sudo ./.github/workflows/posix-deps-apt.sh

    .github/workflows/jit.yml

    Lines changed: 3 additions & 0 deletions
    Original file line numberDiff line numberDiff line change
    @@ -12,6 +12,9 @@ on:
    1212
    - 'Python/optimizer*.c'
    1313
    workflow_dispatch:
    1414

    15+
    permissions:
    16+
    contents: read
    17+
    1518
    concurrency:
    1619
    group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
    1720
    cancel-in-progress: true

    .github/workflows/reusable-wasi.yml

    Lines changed: 3 additions & 1 deletion
    Original file line numberDiff line numberDiff line change
    @@ -50,6 +50,7 @@ jobs:
    5050
    uses: actions/cache@v4
    5151
    with:
    5252
    path: ${{ env.CROSS_BUILD_PYTHON }}/config.cache
    53+
    # Include env.pythonLocation in key to avoid changes in environment when setup-python updates Python
    5354
    key: ${{ github.job }}-${{ runner.os }}-${{ env.IMAGE_VERSION }}-${{ inputs.config_hash }}-${{ env.pythonLocation }}
    5455
    - name: "Configure build Python"
    5556
    run: python3 Tools/wasm/wasi.py configure-build-python -- --config-cache --with-pydebug
    @@ -59,7 +60,8 @@ jobs:
    5960
    uses: actions/cache@v4
    6061
    with:
    6162
    path: ${{ env.CROSS_BUILD_WASI }}/config.cache
    62-
    key: ${{ github.job }}-${{ runner.os }}-${{ env.IMAGE_VERSION }}-wasi-sdk-${{ env.WASI_SDK_VERSION }}-${{ inputs.config_hash }}
    63+
    # Include env.pythonLocation in key to avoid changes in environment when setup-python updates Python
    64+
    key: ${{ github.job }}-${{ runner.os }}-${{ env.IMAGE_VERSION }}-wasi-sdk-${{ env.WASI_SDK_VERSION }}-${{ inputs.config_hash }}-${{ env.pythonLocation }}
    6365
    - name: "Configure host"
    6466
    # `--with-pydebug` inferred from configure-build-python
    6567
    run: python3 Tools/wasm/wasi.py configure-host -- --config-cache

    Doc/bugs.rst

    Lines changed: 4 additions & 0 deletions
    Original file line numberDiff line numberDiff line change
    @@ -22,6 +22,10 @@ have a suggestion on how to fix it, include that as well.
    2222
    You can also open a discussion item on our
    2323
    `Documentation Discourse forum <https://discuss.python.org/c/documentation/26>`_.
    2424

    25+
    If you find a bug in the theme (HTML / CSS / JavaScript) of the
    26+
    documentation, please submit a bug report on the `python-doc-theme bug
    27+
    tracker <https://github.com/python/python-docs-theme>`_.
    28+
    2529
    If you're short on time, you can also email documentation bug reports to
    2630
    docs@python.org (behavioral bugs can be sent to python-list@python.org).
    2731
    'docs@' is a mailing list run by volunteers; your request will be noticed,

    Doc/c-api/init.rst

    Lines changed: 130 additions & 0 deletions
    Original file line numberDiff line numberDiff line change
    @@ -29,6 +29,8 @@ The following functions can be safely called before Python is initialized:
    2929
    * :c:func:`PyMem_SetAllocator`
    3030
    * :c:func:`PyMem_SetupDebugHooks`
    3131
    * :c:func:`PyObject_SetArenaAllocator`
    32+
    * :c:func:`Py_SetProgramName`
    33+
    * :c:func:`Py_SetPythonHome`
    3234
    * :c:func:`PySys_ResetWarnOptions`
    3335

    3436
    * Informative functions:
    @@ -426,6 +428,34 @@ Process-wide parameters
    426428
    =======================
    427429
    428430
    431+
    .. c:function:: void Py_SetProgramName(const wchar_t *name)
    432+
    433+
    .. index::
    434+
    single: Py_Initialize()
    435+
    single: main()
    436+
    single: Py_GetPath()
    437+
    438+
    This API is kept for backward compatibility: setting
    439+
    :c:member:`PyConfig.program_name` should be used instead, see :ref:`Python
    440+
    Initialization Configuration <init-config>`.
    441+
    442+
    This function should be called before :c:func:`Py_Initialize` is called for
    443+
    the first time, if it is called at all. It tells the interpreter the value
    444+
    of the ``argv[0]`` argument to the :c:func:`main` function of the program
    445+
    (converted to wide characters).
    446+
    This is used by :c:func:`Py_GetPath` and some other functions below to find
    447+
    the Python run-time libraries relative to the interpreter executable. The
    448+
    default value is ``'python'``. The argument should point to a
    449+
    zero-terminated wide character string in static storage whose contents will not
    450+
    change for the duration of the program's execution. No code in the Python
    451+
    interpreter will change the contents of this storage.
    452+
    453+
    Use :c:func:`Py_DecodeLocale` to decode a bytes string to get a
    454+
    :c:expr:`wchar_*` string.
    455+
    456+
    .. deprecated:: 3.11
    457+
    458+
    429459
    .. c:function:: wchar_t* Py_GetProgramName()
    430460
    431461
    Return the program name set with :c:member:`PyConfig.program_name`, or the default.
    @@ -627,6 +657,106 @@ Process-wide parameters
    627657
    ``sys.version``.
    628658
    629659
    660+
    .. c:function:: void PySys_SetArgvEx(int argc, wchar_t **argv, int updatepath)
    661+
    662+
    .. index::
    663+
    single: main()
    664+
    single: Py_FatalError()
    665+
    single: argv (in module sys)
    666+
    667+
    This API is kept for backward compatibility: setting
    668+
    :c:member:`PyConfig.argv`, :c:member:`PyConfig.parse_argv` and
    669+
    :c:member:`PyConfig.safe_path` should be used instead, see :ref:`Python
    670+
    Initialization Configuration <init-config>`.
    671+
    672+
    Set :data:`sys.argv` based on *argc* and *argv*. These parameters are
    673+
    similar to those passed to the program's :c:func:`main` function with the
    674+
    difference that the first entry should refer to the script file to be
    675+
    executed rather than the executable hosting the Python interpreter. If there
    676+
    isn't a script that will be run, the first entry in *argv* can be an empty
    677+
    string. If this function fails to initialize :data:`sys.argv`, a fatal
    678+
    condition is signalled using :c:func:`Py_FatalError`.
    679+
    680+
    If *updatepath* is zero, this is all the function does. If *updatepath*
    681+
    is non-zero, the function also modifies :data:`sys.path` according to the
    682+
    following algorithm:
    683+
    684+
    - If the name of an existing script is passed in ``argv[0]``, the absolute
    685+
    path of the directory where the script is located is prepended to
    686+
    :data:`sys.path`.
    687+
    - Otherwise (that is, if *argc* is ``0`` or ``argv[0]`` doesn't point
    688+
    to an existing file name), an empty string is prepended to
    689+
    :data:`sys.path`, which is the same as prepending the current working
    690+
    directory (``"."``).
    691+
    692+
    Use :c:func:`Py_DecodeLocale` to decode a bytes string to get a
    693+
    :c:expr:`wchar_*` string.
    694+
    695+
    See also :c:member:`PyConfig.orig_argv` and :c:member:`PyConfig.argv`
    696+
    members of the :ref:`Python Initialization Configuration <init-config>`.
    697+
    698+
    .. note::
    699+
    It is recommended that applications embedding the Python interpreter
    700+
    for purposes other than executing a single script pass ``0`` as *updatepath*,
    701+
    and update :data:`sys.path` themselves if desired.
    702+
    See :cve:`2008-5983`.
    703+
    704+
    On versions before 3.1.3, you can achieve the same effect by manually
    705+
    popping the first :data:`sys.path` element after having called
    706+
    :c:func:`PySys_SetArgv`, for example using::
    707+
    708+
    PyRun_SimpleString("import sys; sys.path.pop(0)\n");
    709+
    710+
    .. versionadded:: 3.1.3
    711+
    712+
    .. XXX impl. doesn't seem consistent in allowing ``0``/``NULL`` for the params;
    713+
    check w/ Guido.
    714+
    715+
    .. deprecated:: 3.11
    716+
    717+
    718+
    .. c:function:: void PySys_SetArgv(int argc, wchar_t **argv)
    719+
    720+
    This API is kept for backward compatibility: setting
    721+
    :c:member:`PyConfig.argv` and :c:member:`PyConfig.parse_argv` should be used
    722+
    instead, see :ref:`Python Initialization Configuration <init-config>`.
    723+
    724+
    This function works like :c:func:`PySys_SetArgvEx` with *updatepath* set
    725+
    to ``1`` unless the :program:`python` interpreter was started with the
    726+
    :option:`-I`.
    727+
    728+
    Use :c:func:`Py_DecodeLocale` to decode a bytes string to get a
    729+
    :c:expr:`wchar_*` string.
    730+
    731+
    See also :c:member:`PyConfig.orig_argv` and :c:member:`PyConfig.argv`
    732+
    members of the :ref:`Python Initialization Configuration <init-config>`.
    733+
    734+
    .. versionchanged:: 3.4 The *updatepath* value depends on :option:`-I`.
    735+
    736+
    .. deprecated:: 3.11
    737+
    738+
    739+
    .. c:function:: void Py_SetPythonHome(const wchar_t *home)
    740+
    741+
    This API is kept for backward compatibility: setting
    742+
    :c:member:`PyConfig.home` should be used instead, see :ref:`Python
    743+
    Initialization Configuration <init-config>`.
    744+
    745+
    Set the default "home" directory, that is, the location of the standard
    746+
    Python libraries. See :envvar:`PYTHONHOME` for the meaning of the
    747+
    argument string.
    748+
    749+
    The argument should point to a zero-terminated character string in static
    750+
    storage whose contents will not change for the duration of the program's
    751+
    execution. No code in the Python interpreter will change the contents of
    752+
    this storage.
    753+
    754+
    Use :c:func:`Py_DecodeLocale` to decode a bytes string to get a
    755+
    :c:expr:`wchar_*` string.
    756+
    757+
    .. deprecated:: 3.11
    758+
    759+
    630760
    .. c:function:: wchar_t* Py_GetPythonHome()
    631761
    632762
    Return the default "home", that is, the value set by

    Doc/c-api/tuple.rst

    Lines changed: 6 additions & 0 deletions
    Original file line numberDiff line numberDiff line change
    @@ -59,6 +59,12 @@ Tuple Objects
    5959
    Return the object at position *pos* in the tuple pointed to by *p*. If *pos* is
    6060
    negative or out of bounds, return ``NULL`` and set an :exc:`IndexError` exception.
    6161
    62+
    The returned reference is borrowed from the tuple *p*
    63+
    (that is: it is only valid as long as you hold a reference to *p*).
    64+
    To get a :term:`strong reference`, use
    65+
    :c:func:`Py_NewRef(PyTuple_GetItem(...)) <Py_NewRef>`
    66+
    or :c:func:`PySequence_GetItem`.
    67+
    6268
    6369
    .. c:function:: PyObject* PyTuple_GET_ITEM(PyObject *p, Py_ssize_t pos)
    6470

    Doc/c-api/typeobj.rst

    Lines changed: 2 additions & 1 deletion
    Original file line numberDiff line numberDiff line change
    @@ -1034,7 +1034,8 @@ and :c:data:`PyType_Type` effectively act as defaults.)
    10341034
    the type, and the type object is INCREF'ed when a new instance is created, and
    10351035
    DECREF'ed when an instance is destroyed (this does not apply to instances of
    10361036
    subtypes; only the type referenced by the instance's ob_type gets INCREF'ed or
    1037-
    DECREF'ed).
    1037+
    DECREF'ed). Heap types should also :ref:`support garbage collection <supporting-cycle-detection>`
    1038+
    as they can form a reference cycle with their own module object.
    10381039

    10391040
    **Inheritance:**
    10401041

    Doc/data/stable_abi.dat

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

    Doc/library/ast.rst

    Lines changed: 3 additions & 2 deletions
    Original file line numberDiff line numberDiff line change
    @@ -2536,7 +2536,8 @@ to stdout. Otherwise, the content is read from stdin.
    25362536
    code that generated them. This is helpful for tools that make source code
    25372537
    transformations.
    25382538

    2539-
    `leoAst.py <https://leoeditor.com/appendices.html#leoast-py>`_ unifies the
    2539+
    `leoAst.py <https://leo-editor.github.io/leo-editor/appendices.html#leoast-py>`_
    2540+
    unifies the
    25402541
    token-based and parse-tree-based views of python programs by inserting
    25412542
    two-way links between tokens and ast nodes.
    25422543

    @@ -2548,4 +2549,4 @@ to stdout. Otherwise, the content is read from stdin.
    25482549
    `Parso <https://parso.readthedocs.io>`_ is a Python parser that supports
    25492550
    error recovery and round-trip parsing for different Python versions (in
    25502551
    multiple Python versions). Parso is also able to list multiple syntax errors
    2551-
    in your python file.
    2552+
    in your Python file.

    Doc/library/bz2.rst

    Lines changed: 14 additions & 1 deletion
    Original file line numberDiff line numberDiff line change
    @@ -91,7 +91,7 @@ The :mod:`bz2` module contains:
    9191
    and :meth:`~io.IOBase.truncate`.
    9292
    Iteration and the :keyword:`with` statement are supported.
    9393

    94-
    :class:`BZ2File` also provides the following methods:
    94+
    :class:`BZ2File` also provides the following methods and attributes:
    9595

    9696
    .. method:: peek([n])
    9797

    @@ -148,6 +148,19 @@ The :mod:`bz2` module contains:
    148148

    149149
    .. versionadded:: 3.3
    150150

    151+
    .. attribute:: mode
    152+
    153+
    ``'rb'`` for reading and ``'wb'`` for writing.
    154+
    155+
    .. versionadded:: 3.13
    156+
    157+
    .. attribute:: name
    158+
    159+
    The bzip2 file name. Equivalent to the :attr:`~io.FileIO.name`
    160+
    attribute of the underlying :term:`file object`.
    161+
    162+
    .. versionadded:: 3.13
    163+
    151164

    152165
    .. versionchanged:: 3.1
    153166
    Support for the :keyword:`with` statement was added.

    Doc/library/ctypes.rst

    Lines changed: 8 additions & 8 deletions
    Original file line numberDiff line numberDiff line change
    @@ -2077,13 +2077,13 @@ Utility functions
    20772077
    Does the same as the C ``sizeof`` operator.
    20782078

    20792079

    2080-
    .. function:: string_at(address, size=-1)
    2080+
    .. function:: string_at(ptr, size=-1)
    20812081

    2082-
    This function returns the C string starting at memory address *address* as a bytes
    2083-
    object. If size is specified, it is used as size, otherwise the string is assumed
    2082+
    Return the byte string at *void \*ptr*.
    2083+
    If *size* is specified, it is used as size, otherwise the string is assumed
    20842084
    to be zero-terminated.
    20852085

    2086-
    .. audit-event:: ctypes.string_at address,size ctypes.string_at
    2086+
    .. audit-event:: ctypes.string_at ptr,size ctypes.string_at
    20872087

    20882088

    20892089
    .. function:: WinError(code=None, descr=None)
    @@ -2099,14 +2099,14 @@ Utility functions
    20992099
    alias of :exc:`OSError`.
    21002100

    21012101

    2102-
    .. function:: wstring_at(address, size=-1)
    2102+
    .. function:: wstring_at(ptr, size=-1)
    21032103

    2104-
    This function returns the wide character string starting at memory address
    2105-
    *address* as a string. If *size* is specified, it is used as the number of
    2104+
    Return the wide-character string at *void \*ptr*.
    2105+
    If *size* is specified, it is used as the number of
    21062106
    characters of the string, otherwise the string is assumed to be
    21072107
    zero-terminated.
    21082108

    2109-
    .. audit-event:: ctypes.wstring_at address,size ctypes.wstring_at
    2109+
    .. audit-event:: ctypes.wstring_at ptr,size ctypes.wstring_at
    21102110

    21112111

    21122112
    .. _ctypes-data-types:

    Doc/library/doctest.rst

    Lines changed: 3 additions & 3 deletions
    Original file line numberDiff line numberDiff line change
    @@ -800,18 +800,18 @@ guarantee about output. For example, when printing a set, Python doesn't
    800800
    guarantee that the element is printed in any particular order, so a test like ::
    801801

    802802
    >>> foo()
    803-
    {"Hermione", "Harry"}
    803+
    {"spam", "eggs"}
    804804

    805805
    is vulnerable! One workaround is to do ::
    806806

    807-
    >>> foo() == {"Hermione", "Harry"}
    807+
    >>> foo() == {"spam", "eggs"}
    808808
    True
    809809

    810810
    instead. Another is to do ::
    811811

    812812
    >>> d = sorted(foo())
    813813
    >>> d
    814-
    ['Harry', 'Hermione']
    814+
    ['eggs', 'spam']
    815815

    816816
    There are others, but you get the idea.
    817817

    Doc/library/gzip.rst

    Lines changed: 11 additions & 4 deletions
    Original file line numberDiff line numberDiff line change
    @@ -133,6 +133,13 @@ The module defines the following items:
    133133

    134134
    .. versionadded:: 3.2
    135135

    136+
    .. attribute:: mode
    137+
    138+
    ``'rb'`` for reading and ``'wb'`` for writing.
    139+
    140+
    .. versionchanged:: 3.13
    141+
    In previous versions it was an integer ``1`` or ``2``.
    142+
    136143
    .. attribute:: mtime
    137144

    138145
    When decompressing, this attribute is set to the last timestamp in the most
    @@ -168,14 +175,14 @@ The module defines the following items:
    168175
    .. versionchanged:: 3.6
    169176
    Accepts a :term:`path-like object`.
    170177

    171-
    .. versionchanged:: 3.12
    172-
    Remove the ``filename`` attribute, use the :attr:`~GzipFile.name`
    173-
    attribute instead.
    174-
    175178
    .. deprecated:: 3.9
    176179
    Opening :class:`GzipFile` for writing without specifying the *mode*
    177180
    argument is deprecated.
    178181

    182+
    .. versionchanged:: 3.12
    183+
    Remove the ``filename`` attribute, use the :attr:`~GzipFile.name`
    184+
    attribute instead.
    185+
    179186

    180187
    .. function:: compress(data, compresslevel=9, *, mtime=None)
    181188

    0 commit comments

    Comments
     (0)
    0