Skip to content

Commit

Permalink
Merge branch 'main' into pythongh-115999-tlbc-call
Browse files Browse the repository at this point in the history
  • Loading branch information
mpage committed Dec 3, 2024
2 parents 6b591c3 + 0cb5222 commit a5fdc59
Show file tree
Hide file tree
Showing 31 changed files with 856 additions and 83 deletions.
14 changes: 11 additions & 3 deletions Doc/c-api/stable.rst
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ Limited C API

Python 3.2 introduced the *Limited API*, a subset of Python's C API.
Extensions that only use the Limited API can be
compiled once and work with multiple versions of Python.
compiled once and be loaded on multiple versions of Python.
Contents of the Limited API are :ref:`listed below <limited-api-list>`.

.. c:macro:: Py_LIMITED_API
Expand All @@ -76,7 +76,7 @@ Contents of the Limited API are :ref:`listed below <limited-api-list>`.

Define ``Py_LIMITED_API`` to the value of :c:macro:`PY_VERSION_HEX`
corresponding to the lowest Python version your extension supports.
The extension will work without recompilation with all Python 3 releases
The extension will be ABI-compatible with all Python 3 releases
from the specified one onward, and can use Limited API introduced up to that
version.

Expand All @@ -94,7 +94,15 @@ Stable ABI
----------

To enable this, Python provides a *Stable ABI*: a set of symbols that will
remain compatible across Python 3.x versions.
remain ABI-compatible across Python 3.x versions.

.. note::

The Stable ABI prevents ABI issues, like linker errors due to missing
symbols or data corruption due to changes in structure layouts or function
signatures.
However, other changes in Python can change the *behavior* of extensions.
See Python's Backwards Compatibility Policy (:pep:`387`) for details.

The Stable ABI contains symbols exposed in the :ref:`Limited API
<limited-c-api>`, but also other ones – for example, functions necessary to
Expand Down
2 changes: 1 addition & 1 deletion Doc/howto/logging.rst
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ that; formatting options will also be explained later.

Notice that in this example, we use functions directly on the ``logging``
module, like ``logging.debug``, rather than creating a logger and calling
functions on it. These functions operation on the root logger, but can be useful
functions on it. These functions operate on the root logger, but can be useful
as they will call :func:`~logging.basicConfig` for you if it has not been called yet, like in
this example. In larger programs you'll usually want to control the logging
configuration explicitly however - so for that reason as well as others, it's
Expand Down
18 changes: 18 additions & 0 deletions Doc/library/ctypes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1949,6 +1949,24 @@ Utility functions
It behaves similar to ``pointer(obj)``, but the construction is a lot faster.


.. function:: CopyComPointer(src, dst)

Copies a COM pointer from *src* to *dst* and returns the Windows specific
:c:type:`!HRESULT` value.

If *src* is not ``NULL``, its ``AddRef`` method is called, incrementing the
reference count.

In contrast, the reference count of *dst* will not be decremented before
assigning the new value. Unless *dst* is ``NULL``, the caller is responsible
for decrementing the reference count by calling its ``Release`` method when
necessary.

.. availability:: Windows

.. versionadded:: next


.. function:: cast(obj, type)

This function is similar to the cast operator in C. It returns a new instance
Expand Down
7 changes: 7 additions & 0 deletions Doc/library/errno.rst
Original file line number Diff line number Diff line change
Expand Up @@ -613,6 +613,13 @@ defined by the module. The specific list of defined symbols is available as
No route to host


.. data:: EHWPOISON

Memory page has hardware error.

.. versionadded:: next


.. data:: EALREADY

Operation already in progress. This error is mapped to the
Expand Down
7 changes: 7 additions & 0 deletions Doc/library/traceback.rst
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,13 @@ Module-Level Functions
arguments have the same meaning as for :func:`print_stack`.


.. function:: print_list(extracted_list, file=None)

Print the list of tuples as returned by :func:`extract_tb` or
:func:`extract_stack` as a formatted stack trace to the given file.
If *file* is ``None``, the output is written to :data:`sys.stderr`.


.. function:: format_list(extracted_list)

Given a list of tuples or :class:`FrameSummary` objects as returned by
Expand Down
10 changes: 9 additions & 1 deletion Doc/whatsnew/3.14.rst
Original file line number Diff line number Diff line change
Expand Up @@ -313,9 +313,12 @@ ctypes
to help match a non-default ABI.
(Contributed by Petr Viktorin in :gh:`97702`.)

* The :exc:`~ctypes.COMError` exception is now public.
* On Windows, the :exc:`~ctypes.COMError` exception is now public.
(Contributed by Jun Komoda in :gh:`126686`.)

* On Windows, the :func:`~ctypes.CopyComPointer` function is now public.
(Contributed by Jun Komoda in :gh:`127275`.)

datetime
--------

Expand Down Expand Up @@ -345,6 +348,11 @@ dis
This feature is also exposed via :option:`dis --show-positions`.
(Contributed by Bénédikt Tran in :gh:`123165`.)

errno
-----

* Add :data:`errno.EHWPOISON` error code.
(Contributed by James Roy in :gh:`126585`.)

fractions
---------
Expand Down
45 changes: 45 additions & 0 deletions Include/cpython/pyatomic.h
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,27 @@ _Py_atomic_load_ptr(const void *obj);
static inline int
_Py_atomic_load_int_relaxed(const int *obj);

static inline char
_Py_atomic_load_char_relaxed(const char *obj);

static inline unsigned char
_Py_atomic_load_uchar_relaxed(const unsigned char *obj);

static inline short
_Py_atomic_load_short_relaxed(const short *obj);

static inline unsigned short
_Py_atomic_load_ushort_relaxed(const unsigned short *obj);

static inline long
_Py_atomic_load_long_relaxed(const long *obj);

static inline double
_Py_atomic_load_double_relaxed(const double *obj);

static inline long long
_Py_atomic_load_llong_relaxed(const long long *obj);

static inline int8_t
_Py_atomic_load_int8_relaxed(const int8_t *obj);

Expand Down Expand Up @@ -458,6 +479,30 @@ static inline void
_Py_atomic_store_ullong_relaxed(unsigned long long *obj,
unsigned long long value);

static inline void
_Py_atomic_store_char_relaxed(char *obj, char value);

static inline void
_Py_atomic_store_uchar_relaxed(unsigned char *obj, unsigned char value);

static inline void
_Py_atomic_store_short_relaxed(short *obj, short value);

static inline void
_Py_atomic_store_ushort_relaxed(unsigned short *obj, unsigned short value);

static inline void
_Py_atomic_store_long_relaxed(long *obj, long value);

static inline void
_Py_atomic_store_float_relaxed(float *obj, float value);

static inline void
_Py_atomic_store_double_relaxed(double *obj, double value);

static inline void
_Py_atomic_store_llong_relaxed(long long *obj, long long value);


// --- _Py_atomic_load_ptr_acquire / _Py_atomic_store_ptr_release ------------

Expand Down
64 changes: 64 additions & 0 deletions Include/cpython/pyatomic_gcc.h
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,34 @@ static inline int
_Py_atomic_load_int_relaxed(const int *obj)
{ return __atomic_load_n(obj, __ATOMIC_RELAXED); }

static inline char
_Py_atomic_load_char_relaxed(const char *obj)
{ return __atomic_load_n(obj, __ATOMIC_RELAXED); }

static inline unsigned char
_Py_atomic_load_uchar_relaxed(const unsigned char *obj)
{ return __atomic_load_n(obj, __ATOMIC_RELAXED); }

static inline short
_Py_atomic_load_short_relaxed(const short *obj)
{ return __atomic_load_n(obj, __ATOMIC_RELAXED); }

static inline unsigned short
_Py_atomic_load_ushort_relaxed(const unsigned short *obj)
{ return __atomic_load_n(obj, __ATOMIC_RELAXED); }

static inline long
_Py_atomic_load_long_relaxed(const long *obj)
{ return __atomic_load_n(obj, __ATOMIC_RELAXED); }

static inline float
_Py_atomic_load_float_relaxed(const float *obj)
{ float ret; __atomic_load(obj, &ret, __ATOMIC_RELAXED); return ret; }

static inline double
_Py_atomic_load_double_relaxed(const double *obj)
{ double ret; __atomic_load(obj, &ret, __ATOMIC_RELAXED); return ret; }

static inline int8_t
_Py_atomic_load_int8_relaxed(const int8_t *obj)
{ return __atomic_load_n(obj, __ATOMIC_RELAXED); }
Expand Down Expand Up @@ -362,6 +390,10 @@ static inline unsigned long long
_Py_atomic_load_ullong_relaxed(const unsigned long long *obj)
{ return __atomic_load_n(obj, __ATOMIC_RELAXED); }

static inline long long
_Py_atomic_load_llong_relaxed(const long long *obj)
{ return __atomic_load_n(obj, __ATOMIC_RELAXED); }


// --- _Py_atomic_store ------------------------------------------------------

Expand Down Expand Up @@ -485,6 +517,38 @@ _Py_atomic_store_ullong_relaxed(unsigned long long *obj,
unsigned long long value)
{ __atomic_store_n(obj, value, __ATOMIC_RELAXED); }

static inline void
_Py_atomic_store_char_relaxed(char *obj, char value)
{ __atomic_store_n(obj, value, __ATOMIC_RELEASE); }

static inline void
_Py_atomic_store_uchar_relaxed(unsigned char *obj, unsigned char value)
{ __atomic_store_n(obj, value, __ATOMIC_RELAXED); }

static inline void
_Py_atomic_store_short_relaxed(short *obj, short value)
{ __atomic_store_n(obj, value, __ATOMIC_RELAXED); }

static inline void
_Py_atomic_store_ushort_relaxed(unsigned short *obj, unsigned short value)
{ __atomic_store_n(obj, value, __ATOMIC_RELAXED); }

static inline void
_Py_atomic_store_long_relaxed(long *obj, long value)
{ __atomic_store_n(obj, value, __ATOMIC_RELAXED); }

static inline void
_Py_atomic_store_float_relaxed(float *obj, float value)
{ __atomic_store(obj, &value, __ATOMIC_RELAXED); }

static inline void
_Py_atomic_store_double_relaxed(double *obj, double value)
{ __atomic_store(obj, &value, __ATOMIC_RELAXED); }

static inline void
_Py_atomic_store_llong_relaxed(long long *obj, long long value)
{ __atomic_store_n(obj, value, __ATOMIC_RELAXED); }


// --- _Py_atomic_load_ptr_acquire / _Py_atomic_store_ptr_release ------------

Expand Down
102 changes: 102 additions & 0 deletions Include/cpython/pyatomic_msc.h
Original file line number Diff line number Diff line change
Expand Up @@ -634,6 +634,48 @@ _Py_atomic_load_int_relaxed(const int *obj)
return *(volatile int *)obj;
}

static inline char
_Py_atomic_load_char_relaxed(const char *obj)
{
return *(volatile char *)obj;
}

static inline unsigned char
_Py_atomic_load_uchar_relaxed(const unsigned char *obj)
{
return *(volatile unsigned char *)obj;
}

static inline short
_Py_atomic_load_short_relaxed(const short *obj)
{
return *(volatile short *)obj;
}

static inline unsigned short
_Py_atomic_load_ushort_relaxed(const unsigned short *obj)
{
return *(volatile unsigned short *)obj;
}

static inline long
_Py_atomic_load_long_relaxed(const long *obj)
{
return *(volatile long *)obj;
}

static inline float
_Py_atomic_load_float_relaxed(const float *obj)
{
return *(volatile float *)obj;
}

static inline double
_Py_atomic_load_double_relaxed(const double *obj)
{
return *(volatile double *)obj;
}

static inline int8_t
_Py_atomic_load_int8_relaxed(const int8_t *obj)
{
Expand Down Expand Up @@ -718,6 +760,12 @@ _Py_atomic_load_ullong_relaxed(const unsigned long long *obj)
return *(volatile unsigned long long *)obj;
}

static inline long long
_Py_atomic_load_llong_relaxed(const long long *obj)
{
return *(volatile long long *)obj;
}


// --- _Py_atomic_store ------------------------------------------------------

Expand Down Expand Up @@ -899,6 +947,60 @@ _Py_atomic_store_ullong_relaxed(unsigned long long *obj,
*(volatile unsigned long long *)obj = value;
}

static inline void
_Py_atomic_store_char_relaxed(char *obj, char value)
{
*(volatile char *)obj = value;
}

static inline void
_Py_atomic_store_uchar_relaxed(unsigned char *obj, unsigned char value)
{
*(volatile unsigned char *)obj = value;
}

static inline void
_Py_atomic_store_short_relaxed(short *obj, short value)
{
*(volatile short *)obj = value;
}

static inline void
_Py_atomic_store_ushort_relaxed(unsigned short *obj, unsigned short value)
{
*(volatile unsigned short *)obj = value;
}

static inline void
_Py_atomic_store_uint_release(unsigned int *obj, unsigned int value)
{
*(volatile unsigned int *)obj = value;
}

static inline void
_Py_atomic_store_long_relaxed(long *obj, long value)
{
*(volatile long *)obj = value;
}

static inline void
_Py_atomic_store_float_relaxed(float *obj, float value)
{
*(volatile float *)obj = value;
}

static inline void
_Py_atomic_store_double_relaxed(double *obj, double value)
{
*(volatile double *)obj = value;
}

static inline void
_Py_atomic_store_llong_relaxed(long long *obj, long long value)
{
*(volatile long long *)obj = value;
}


// --- _Py_atomic_load_ptr_acquire / _Py_atomic_store_ptr_release ------------

Expand Down
Loading

0 comments on commit a5fdc59

Please sign in to comment.