8000 Merge branch 'main' into dict_get · python/cpython@8a3a0cc · GitHub
[go: up one dir, main page]

Skip to content

Commit 8a3a0cc

Browse files
authored
Merge branch 'main' into dict_get
2 parents 772e7e0 + a4459c3 commit 8a3a0cc

File tree

88 files changed

+2101
-1417
lines changed
  • Tools
  • Some content is hidden

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

    88 files changed

    +2101
    -1417
    lines changed

    Android/android-env.sh

    Lines changed: 17 additions & 15 deletions
    Original file line numberDiff line numberDiff line change
    @@ -1,10 +1,10 @@
    11
    # This script must be sourced with the following variables already set:
    2-
    : ${ANDROID_HOME:?} # Path to Android SDK
    3-
    : ${HOST:?} # GNU target triplet
    2+
    : "${ANDROID_HOME:?}" # Path to Android SDK
    3+
    : "${HOST:?}" # GNU target triplet
    44

    55
    # You may also override the following:
    6-
    : ${api_level:=24} # Minimum Android API level the build will run on
    7-
    : ${PREFIX:-} # Path in which to find required libraries
    6+
    : "${api_level:=24}" # Minimum Android API level the build will run on
    7+
    : "${PREFIX:-}" # Path in which to find required libraries
    88

    99

    1010
    # Print all messages on stderr so they're visible when running within build-wheel.
    @@ -27,20 +27,20 @@ fail() {
    2727
    ndk_version=27.1.12297006
    2828

    2929
    ndk=$ANDROID_HOME/ndk/$ndk_version
    30-
    if ! [ -e $ndk ]; then
    30+
    if ! [ -e "$ndk" ]; then
    3131
    log "Installing NDK - this may take several minutes"
    32-
    yes | $ANDROID_HOME/cmdline-tools/latest/bin/sdkmanager "ndk;$ndk_version"
    32+
    yes | "$ANDROID_HOME/cmdline-tools/latest/bin/sdkmanager" "ndk;$ndk_version"
    3333
    fi
    3434

    35-
    if [ $HOST = "arm-linux-androideabi" ]; then
    35+
    if [ "$HOST" = "arm-linux-androideabi" ]; then
    3636
    clang_triplet=armv7a-linux-androideabi
    3737
    else
    38-
    clang_triplet=$HOST
    38+
    clang_triplet="$HOST"
    3939
    fi
    4040

    4141
    # These variables are based on BuildSystemMaintainers.md above, and
    4242
    # $ndk/build/cmake/android.toolchain.cmake.
    43-
    toolchain=$(echo $ndk/toolchains/llvm/prebuilt/*)
    43+
    toolchain=$(echo "$ndk"/toolchains/llvm/prebuilt/*)
    4444
    export AR="$toolchain/bin/llvm-ar"
    4545
    export AS="$toolchain/bin/llvm-as"
    4646
    export CC="$toolchain/bin/${clang_triplet}${api_level}-clang"
    @@ -72,12 +72,12 @@ LDFLAGS="$LDFLAGS -lm"
    7272

    7373
    # -mstackrealign is included where necessary in the clang launcher scripts which are
    7474
    # pointed to by $CC, so we don't need to include it here.
    75-
    if [ $HOST = "arm-linux-androideabi" ]; then
    75+
    if [ "$HOST" = "arm-linux-androideabi" ]; then
    7676
    CFLAGS="$CFLAGS -march=armv7-a -mthumb"
    7777
    fi
    7878

    7979
    if [ -n "${PREFIX:-}" ]; then
    80-
    abs_prefix=$(realpath $PREFIX)
    80+
    abs_prefix="$(realpath "$PREFIX")"
    8181
    CFLAGS="$CFLAGS -I$abs_prefix/include"
    8282
    LDFLAGS="$LDFLAGS -L$abs_prefix/lib"
    8383

    @@ -87,11 +87,13 @@ fi
    8787

    8888
    # When compiling C++, some build systems will combine CFLAGS and CXXFLAGS, and some will
    8989
    # use CXXFLAGS alone.
    90-
    export CXXFLAGS=$CFLAGS
    90+
    export CXXFLAGS="$CFLAGS"
    9191

    9292
    # Use the same variable name as conda-build
    93-
    if [ $(uname) = "Darwin" ]; then
    94-
    export CPU_COUNT=$(sysctl -n hw.ncpu)
    93+
    if [ "$(uname)" = "Darwin" ]; then
    94+
    CPU_COUNT="$(sysctl -n hw.ncpu)"
    95+
    export CPU_COUNT
    9596
    else
    96-
    export CPU_COUNT=$(nproc)
    97+
    CPU_COUNT="$(nproc)"
    98+
    export CPU_COUNT
    9799
    fi

    Doc/c-api/long.rst

    Lines changed: 1 addition & 1 deletion
    Original file line numberDiff line numberDiff line change
    @@ -824,6 +824,6 @@ The :c:type:`PyLongWriter` API can be used to import an integer.
    824824
    825825
    Discard a :c:type:`PyLongWriter` created by :c:func:`PyLongWriter_Create`.
    826826
    827-
    *writer* must not be ``NULL``.
    827+
    If *writer* is ``NULL``, no operation is performed.
    828828
    829829
    The writer instance and the *digits* array are invalid after the call.

    Doc/c-api/object.rst

    Lines changed: 92 additions & 0 deletions
    Original file line numberDiff line numberDiff line change
    @@ -613,3 +613,95 @@ Object Protocol
    613613
    614614
    .. versionadded:: 3.14
    615615
    616+
    .. c:function:: int PyUnstable_IsImmortal(PyObject *obj)
    617+
    618+
    This function returns non-zero if *obj* is :term:`immortal`, and zero
    619+
    otherwise. This function cannot fail.
    620+
    621+
    .. note::
    622+
    623+
    Objects that are immortal in one CPython version are not guaranteed to
    624+
    be immortal in another.
    625+
    626+
    .. versionadded:: next
    627+
    628+
    .. c:function:: int PyUnstable_TryIncRef(PyObject *obj)
    629+
    630+
    Increments the reference count of *obj* if it is not zero. Returns ``1``
    631+
    if the object's reference count was successfully incremented. Otherwise,
    632+
    this function returns ``0``.
    633+
    634+
    :c:func:`PyUnstable_EnableTryIncRef` must have been called
    635+
    earlier on *obj* or this function may spuriously return ``0`` in the
    636+
    :term:`free threading` build.
    637+
    638+
    This function is logically equivalent to the following C code, except that
    639+
    it behaves atomically in the :term:`free threading` build::
    640+
    641+
    if (Py_REFCNT(op) > 0) {
    642+
    Py_INCREF(op);
    643+
    return 1;
    644+< 10000 /span>
    }
    645+
    return 0;
    646+
    647+
    This is intended as a building block for managing weak references
    648+
    without the overhead of a Python :ref:`weak reference object <weakrefobjects>`.
    649+
    650+
    Typically, correct use of this function requires support from *obj*'s
    651+
    deallocator (:c:member:`~PyTypeObject.tp_dealloc`).
    652+
    For example, the following sketch could be adapted to implement a
    653+
    "weakmap" that works like a :py:class:`~weakref.WeakValueDictionary`
    654+
    for a specific type:
    655+
    656+
    .. code-block:: c
    657+
    658+
    PyMutex mutex;
    659+
    660+
    PyObject *
    661+
    add_entry(weakmap_key_type *key, PyObject *value)
    662+
    {
    663+
    PyUnstable_EnableTryIncRef(value);
    664+
    weakmap_type weakmap = ...;
    665+
    PyMutex_Lock(&mutex);
    666+
    weakmap_add_entry(weakmap, key, value);
    667+
    PyMutex_Unlock(&mutex);
    668+
    Py_RETURN_NONE;
    669+
    }
    670+
    671+
    PyObject *
    672+
    get_value(weakmap_key_type *key)
    673+
    {
    674+
    weakmap_type weakmap = ...;
    675+
    PyMutex_Lock(&mutex);
    676+
    PyObject *result = weakmap_find(weakmap, key);
    677+
    if (PyUnstable_TryIncRef(result)) {
    678+
    // `result` is safe to use
    679+
    PyMutex_Unlock(&mutex);
    680+
    return result;
    681+
    }
    682+
    // if we get here, `result` is starting to be garbage-collected,
    683+
    // but has not been removed from the weakmap yet
    684+
    PyMutex_Unlock(&mutex);
    685+
    return NULL;
    686+
    }
    687+
    688+
    // tp_dealloc function for weakmap values
    689+
    void
    690+
    value_dealloc(PyObject *value)
    691+
    {
    692+
    weakmap_type weakmap = ...;
    693+
    PyMutex_Lock(&mutex);
    694+
    weakmap_remove_value(weakmap, value);
    695+
    696+
    ...
    697+
    PyMutex_Unlock(&mutex);
    698+
    }
    699+
    700+
    .. versionadded:: 3.14
    701+
    702+
    .. c:function:: void PyUnstable_EnableTryIncRef(PyObject *obj)
    703+
    704+
    Enables subsequent uses of :c:func:`PyUnstable_TryIncRef` on *obj*. The
    705+
    caller must hold a :term:`strong reference` to *obj* when calling this.
    706+
    707+
    .. versionadded:: 3.14

    Doc/deprecations/c-api-pending-removal-in-future.rst

    Lines changed: 0 additions & 1 deletion
    Original file line numberDiff line numberDiff line change
    @@ -34,7 +34,6 @@ although there is currently no date scheduled for their removal.
    3434
    Use :c:func:`!_PyErr_ChainExceptions1` instead.
    3535
    * :c:member:`!PyBytesObject.ob_shash` member:
    3636
    call :c:func:`PyObject_Hash` instead.
    37-
    * :c:member:`!PyDictObject.ma_version_tag` member.
    3837
    * Thread Local Storage (TLS) API:
    3938

    4039
    * :c:func:`PyThread_create_key`:

    Doc/library/errno.rst

    Lines changed: 165 additions & 0 deletions
    Original file line numberDiff line numberDiff line change
    @@ -672,6 +672,171 @@ defined by the module 10000 . The specific list of defined symbols is available as
    672672

    673673
    .. versionadded:: 3.11
    674674

    675+
    676+
    .. data:: ENOMEDIUM
    677+
    678+
    No medium found
    679+
    680+
    681+
    .. data:: EMEDIUMTYPE
    682+
    683+
    Wrong medium type
    684+
    685+
    686+
    .. data:: ENOKEY
    687+
    688+
    Required key not available
    689+
    690+
    691+
    .. data:: EKEYEXPIRED
    692+
    693+
    Key has expired
    694+
    695+
    696+
    .. data:: EKEYREVOKED
    697+
    698+
    Key has been revoked
    699+
    700+
    701+
    .. data:: EKEYREJECTED
    702+
    703+
    Key was rejected by service
    704+
    705+
    706+
    .. data:: ERFKILL
    707+
    708+
    Operation not possible due to RF-kill
    709+
    710+
    711+
    .. data:: ELOCKUNMAPPED
    712+
    713+
    Locked lock was unmapped
    714+
    715+
    716+
    .. data:: ENOTACTIVE
    717+
    718+
    Facility is not active
    719+
    720+
    721+
    .. data:: EAUTH
    722+
    723+
    Authentication error
    724+
    725+
    .. versionadded:: 3.2
    726+
    727+
    728+
    .. data:: EBADARCH
    729+
    730+
    Bad CPU type in executable
    731+
    732+
    .. versionadded:: 3.2
    733+
    734+
    735+
    .. data:: EBADEXEC
    736+
    737+
    Bad executable (or shared library)
    738+
    739+
    .. versionadded:: 3.2
    740+
    741+
    742+
    .. data:: EBADMACHO
    743+
    744+
    Malformed Mach-o file
    745+
    746+
    .. versionadded:: 3.2
    747+
    748+
    749+
    .. data:: EDEVERR
    750+
    751+
    Device error
    752+
    753+
    .. versionadded:: 3.2
    754+
    755+
    756+
    .. data:: EFTYPE
    757+
    758+
    Inappropriate file type or format
    759+
    760+
    .. versionadded:: 3.2
    761+
    762+
    763+
    .. data:: ENEEDAUTH
    764+
    765+
    Need authenticator
    766+
    767+
    .. versionadded:: 3.2
    768+
    769+
    770+
    .. data:: ENOATTR
    771+
    772+
    Attribute not found
    773+
    774+
    .. versionadded:: 3.2
    775+
    776+
    777+
    .. data:: ENOPOLICY
    778+
    779+
    Policy not found
    780+
    781+
    .. versionadded:: 3.2
    782+
    783+
    784+
    .. data:: EPROCLIM
    785+
    786+
    Too many processes
    787+
    788+
    .. versionadded:: 3.2
    789+
    790+
    791+
    .. data:: EPROCUNAVAIL
    792+
    793+
    Bad procedure for program
    794+
    795+
    .. versionadded:: 3.2
    796+
    797+
    798+
    .. data:: EPROGMISMATCH
    799+
    800+
    Program version wrong
    801+
    802+
    .. versionadded:: 3.2
    803+
    804+
    805+
    .. data:: EPROGUNAVAIL
    806+
    807+
    RPC prog. not avail
    808+
    809+
    .. versionadded:: 3.2
    810+
    811+
    812+
    .. data:: EPWROFF
    813+
    814+
    Device power is off
    815+
    816+
    .. versionadded:: 3.2
    817+
    818+
    819+
    .. data:: EBADRPC
    820+
    821+
    RPC struct is bad
    822+
    823+
    .. versionadded:: 3.2
    824+
    825+
    826+
    .. data:: ERPCMISMATCH
    827+
    828+
    RPC version wrong
    829+
    830+
    .. versionadded:: 3.2
    831+
    832+
    833+
    .. data:: ESHLIBVERS
    834+
    835+
    Shared library version mismatch
    836+
    837+
    .. versionadded:: 3.2
    838+
    839+
    675840
    .. data:: ENOTCAPABLE
    676841

    677842
    Capabilities insufficient. This error is mapped to the exception

    Doc/library/uuid.rst

    Lines changed: 27 additions & 0 deletions
    Original file line numberDiff line numberDiff line change
    @@ -289,6 +289,25 @@ of the :attr:`~UUID.variant` attribute:
    289289
    Reserved for future definition.
    290290

    291291

    292+
    The :mod:`uuid` module defines the special Nil and Max UUID values:
    293+
    294+
    295+
    .. data:: NIL
    296+
    297+
    A special form of UUID that is specified to have all 128 bits set to zero
    298+
    according to :rfc:`RFC 9562, §5.9 <9562#section-5.9>`.
    299+
    300+
    .. versionadded:: next
    301+
    302+
    303+
    .. data:: MAX
    304+
    305+
    A special form of UUID that is specified to have all 128 bits set to one
    306+
    according to :rfc:`RFC 9562, §5.10 <9562#section-5.10>`.
    307+
    308+
    .. versionadded:: next
    309+
    310+
    292311
    .. seealso::
    293312

    294313
    :rfc:`9562` - A Universally Unique IDentifier (UUID) URN Namespace
    @@ -380,6 +399,14 @@ Here are some examples of typical usage of the :mod:`uuid` module::
    380399
    >>> uuid.UUID(bytes=x.bytes)
    381400
    UUID('00010203-0405-0607-0809-0a0b0c0d0e0f')
    382401

    402+
    >>> # get the Nil UUID
    403+
    >>> uuid.NIL
    404+
    UUID('00000000-0000-0000-0000-000000000000')
    405+
    406+
    >>> # get the Max UUID
    407+
    >>> uuid.MAX
    408+
    UUID('ffffffff-ffff-ffff-ffff-ffffffffffff')
    409+
    383410

    384411
    .. _uuid-cli-example:
    385412

    0 commit comments

    Comments
     (0)
    0