Skip to content

Commit

Permalink
Merge branch 'main' into split-classes-again
Browse files Browse the repository at this point in the history
  • Loading branch information
barneygale authored Jan 5, 2025
2 parents 87b6ad9 + 2228e92 commit 620818c
Show file tree
Hide file tree
Showing 11 changed files with 74 additions and 25 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/reusable-docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ jobs:
# Run "doctest" on HEAD as new syntax doesn't exist in the latest stable release
doctest:
name: 'Doctest'
runs-on: ubuntu-22.04
runs-on: ubuntu-24.04
timeout-minutes: 60
steps:
- uses: actions/checkout@v4
Expand Down
7 changes: 7 additions & 0 deletions Doc/c-api/object.rst
Original file line number Diff line number Diff line change
Expand Up @@ -493,6 +493,13 @@ Object Protocol
on failure. This is equivalent to the Python statement ``del o[key]``.
.. c:function:: int PyObject_DelItemString(PyObject *o, const char *key)
This is the same as :c:func:`PyObject_DelItem`, but *key* is
specified as a :c:expr:`const char*` UTF-8 encoded bytes string,
rather than a :c:expr:`PyObject*`.
.. c:function:: PyObject* PyObject_Dir(PyObject *o)
This is equivalent to the Python expression ``dir(o)``, returning a (possibly
Expand Down
13 changes: 8 additions & 5 deletions Doc/library/json.rst
Original file line number Diff line number Diff line change
Expand Up @@ -154,10 +154,6 @@ Basic Usage
:term:`file-like object`) using this :ref:`Python-to-JSON conversion table
<py-to-json-table>`.

To use a custom :class:`JSONEncoder` subclass (for example, one that overrides the
:meth:`~JSONEncoder.default` method to serialize additional types), specify it with the
*cls* keyword argument; otherwise :class:`JSONEncoder` is used.

.. note::

Unlike :mod:`pickle` and :mod:`marshal`, JSON is not a framed protocol,
Expand Down Expand Up @@ -197,6 +193,13 @@ Basic Usage
If ``True`` (the default), their JavaScript equivalents
(``NaN``, ``Infinity``, ``-Infinity``) are used.

:param cls:
If set, a custom JSON encoder with the
:meth:`~JSONEncoder.default` method overridden,
for serializing into custom datatypes.
If ``None`` (the default), :class:`!JSONEncoder` is used.
:type cls: a :class:`JSONEncoder` subclass

:param indent:
If a positive integer or string, JSON array elements and
object members will be pretty-printed with that indent level.
Expand All @@ -223,7 +226,7 @@ Basic Usage
If ``None`` (the default), :exc:`!TypeError` is raised.
:type default: :term:`callable` | None

:param sort_keys:
:param bool sort_keys:
If ``True``, dictionaries will be outputted sorted by key.
Default ``False``.

Expand Down
3 changes: 2 additions & 1 deletion Doc/library/math.rst
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,8 @@ Floating point arithmetic

.. function:: fmod(x, y)

Return ``fmod(x, y)``, as defined by the platform C library. Note that the
Return the floating-point remainder of ``x / y``,
as defined by the platform C library function ``fmod(x, y)``. Note that the
Python expression ``x % y`` may not return the same result. The intent of the C
standard is that ``fmod(x, y)`` be exactly (mathematically; to infinite
precision) equal to ``x - n*y`` for some integer *n* such that the result has
Expand Down
5 changes: 4 additions & 1 deletion Doc/using/configure.rst
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ Features and minimum versions required to build CPython:

* Tcl/Tk 8.5.12 for the :mod:`tkinter` module.

* Autoconf 2.71 and aclocal 1.16.5 are required to regenerate the
* Autoconf 2.72 and aclocal 1.16.5 are required to regenerate the
:file:`configure` script.

.. versionchanged:: 3.1
Expand Down Expand Up @@ -58,6 +58,9 @@ Features and minimum versions required to build CPython:
.. versionchanged:: 3.13
Autoconf 2.71, aclocal 1.16.5 and SQLite 3.15.2 are now required.

.. versionchanged:: next
Autoconf 2.72 is now required.

See also :pep:`7` "Style Guide for C Code" and :pep:`11` "CPython platform
support".

Expand Down
20 changes: 13 additions & 7 deletions Include/cpython/unicodeobject.h
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ typedef struct {
3: Interned, Immortal, and Static
This categorization allows the runtime to determine the right
cleanup mechanism at runtime shutdown. */
unsigned int interned:2;
uint16_t interned;
/* Character size:
- PyUnicode_1BYTE_KIND (1):
Expand All @@ -132,21 +132,23 @@ typedef struct {
* all characters are in the range U+0000-U+10FFFF
* at least one character is in the range U+10000-U+10FFFF
*/
unsigned int kind:3;
unsigned short kind:3;
/* Compact is with respect to the allocation scheme. Compact unicode
objects only require one memory block while non-compact objects use
one block for the PyUnicodeObject struct and another for its data
buffer. */
unsigned int compact:1;
unsigned short compact:1;
/* The string only contains characters in the range U+0000-U+007F (ASCII)
and the kind is PyUnicode_1BYTE_KIND. If ascii is set and compact is
set, use the PyASCIIObject structure. */
unsigned int ascii:1;
unsigned short ascii:1;
/* The object is statically allocated. */
unsigned int statically_allocated:1;
unsigned short statically_allocated:1;
/* Padding to ensure that PyUnicode_DATA() is always aligned to
4 bytes (see issue #19537 on m68k). */
unsigned int :24;
4 bytes (see issue #19537 on m68k) and we use unsigned short to avoid
the extra four bytes on 32-bit Windows. This is restricted features
for specific compilers including GCC, MSVC, Clang and IBM's XL compiler. */
unsigned short :10;
} state;
} PyASCIIObject;

Expand Down Expand Up @@ -195,7 +197,11 @@ typedef struct {

/* Use only if you know it's a string */
static inline unsigned int PyUnicode_CHECK_INTERNED(PyObject *op) {
#ifdef Py_GIL_DISABLED
return _Py_atomic_load_uint16_relaxed(&_PyASCIIObject_CAST(op)->state.interned);
#else
return _PyASCIIObject_CAST(op)->state.interned;
#endif
}
#define PyUnicode_CHECK_INTERNED(op) PyUnicode_CHECK_INTERNED(_PyObject_CAST(op))

Expand Down
1 change: 0 additions & 1 deletion Lib/_pydatetime.py
Original file line number Diff line number Diff line change
Expand Up @@ -2392,7 +2392,6 @@ def __reduce__(self):

def _isoweek1monday(year):
# Helper to calculate the day number of the Monday starting week 1
# XXX This could be done more efficiently
THURSDAY = 3
firstday = _ymd2ord(year, 1, 1)
firstweekday = (firstday + 6) % 7 # See weekday() above
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Update :c:type:`PyASCIIObject` layout to handle interned field with the
atomic operation. Patch by Donghee Na.
6 changes: 3 additions & 3 deletions Objects/unicodeobject.c
Original file line number Diff line number Diff line change
Expand Up @@ -15729,7 +15729,7 @@ immortalize_interned(PyObject *s)
_Py_DecRefTotal(_PyThreadState_GET());
}
#endif
_PyUnicode_STATE(s).interned = SSTATE_INTERNED_IMMORTAL;
FT_ATOMIC_STORE_UINT16_RELAXED(_PyUnicode_STATE(s).interned, SSTATE_INTERNED_IMMORTAL);
_Py_SetImmortal(s);
}

Expand Down Expand Up @@ -15848,7 +15848,7 @@ intern_common(PyInterpreterState *interp, PyObject *s /* stolen */,
_Py_DecRefTotal(_PyThreadState_GET());
#endif
}
_PyUnicode_STATE(s).interned = SSTATE_INTERNED_MORTAL;
FT_ATOMIC_STORE_UINT16_RELAXED(_PyUnicode_STATE(s).interned, SSTATE_INTERNED_MORTAL);

/* INTERNED_MORTAL -> INTERNED_IMMORTAL (if needed) */

Expand Down Expand Up @@ -15984,7 +15984,7 @@ _PyUnicode_ClearInterned(PyInterpreterState *interp)
Py_UNREACHABLE();
}
if (!shared) {
_PyUnicode_STATE(s).interned = SSTATE_NOT_INTERNED;
FT_ATOMIC_STORE_UINT16_RELAXED(_PyUnicode_STATE(s).interned, SSTATE_NOT_INTERNED);
}
}
#ifdef INTERNED_STATS
Expand Down
18 changes: 16 additions & 2 deletions configure

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

22 changes: 18 additions & 4 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ dnl ************************************************************
dnl * Please run autoreconf -ivf -Werror to test your changes! *
dnl ************************************************************
dnl
dnl Python's configure script requires autoconf 2.71, autoconf-archive,
dnl Python's configure script requires autoconf 2.72, autoconf-archive,
dnl aclocal 1.16, and pkg-config.
dnl
dnl It is recommended to use the Tools/build/regen-configure.sh shell script
Expand All @@ -12,7 +12,7 @@ dnl
# Set VERSION so we only need to edit in one place (i.e., here)
m4_define([PYTHON_VERSION], [3.14])

AC_PREREQ([2.71])
AC_PREREQ([2.72])

AC_INIT([python],[PYTHON_VERSION],[https://github.com/python/cpython/issues/])

Expand Down Expand Up @@ -2160,14 +2160,28 @@ AS_VAR_IF([enable_shared], [yes], [
BOLT_BINARIES="${BOLT_BINARIES} \$(INSTSONAME)"
])

AC_ARG_VAR(
[BOLT_COMMON_FLAGS],
[Common arguments to llvm-bolt when instrumenting and applying]
)

AC_MSG_CHECKING([BOLT_COMMON_FLAGS])
if test -z "${BOLT_COMMON_FLAGS}"
then
AS_VAR_SET(
[BOLT_COMMON_FLAGS],
[-update-debug-sections]
)
fi

AC_ARG_VAR(
[BOLT_INSTRUMENT_FLAGS],
[Arguments to llvm-bolt when instrumenting binaries]
)
AC_MSG_CHECKING([BOLT_INSTRUMENT_FLAGS])
if test -z "${BOLT_INSTRUMENT_FLAGS}"
then
BOLT_INSTRUMENT_FLAGS=
BOLT_INSTRUMENT_FLAGS="${BOLT_COMMON_FLAGS}"
fi
AC_MSG_RESULT([$BOLT_INSTRUMENT_FLAGS])

Expand All @@ -2181,7 +2195,7 @@ then
AS_VAR_SET(
[BOLT_APPLY_FLAGS],
[m4_normalize("
-update-debug-sections
${BOLT_COMMON_FLAGS}
-reorder-blocks=ext-tsp
-reorder-functions=cdsort
-split-functions
Expand Down

0 comments on commit 620818c

Please sign in to comment.