Skip to content

Commit

Permalink
Merge branch 'main' into pythongh-109889
Browse files Browse the repository at this point in the history
  • Loading branch information
iritkatriel authored Sep 28, 2023
2 parents f175677 + 9be283e commit cf54f14
Show file tree
Hide file tree
Showing 50 changed files with 1,943 additions and 1,407 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ jobs:
needs: check_source
if: needs.check_source.outputs.run_tests == 'true'
env:
OPENSSL_VER: 1.1.1v
OPENSSL_VER: 3.0.11
PYTHONSTRICTEXTENSIONBUILD: 1
steps:
- uses: actions/checkout@v4
Expand Down Expand Up @@ -330,7 +330,7 @@ jobs:
strategy:
fail-fast: false
matrix:
openssl_ver: [1.1.1v, 3.0.10, 3.1.2]
openssl_ver: [1.1.1w, 3.0.11, 3.1.3]
env:
OPENSSL_VER: ${{ matrix.openssl_ver }}
MULTISSL_DIR: ${{ github.workspace }}/multissl
Expand Down Expand Up @@ -382,7 +382,7 @@ jobs:
needs: check_source
if: needs.check_source.outputs.run_tests == 'true' && needs.check_source.outputs.run_hypothesis == 'true'
env:
OPENSSL_VER: 1.1.1v
OPENSSL_VER: 3.0.11
PYTHONSTRICTEXTENSIONBUILD: 1
steps:
- uses: actions/checkout@v4
Expand Down Expand Up @@ -491,7 +491,7 @@ jobs:
needs: check_source
if: needs.check_source.outputs.run_tests == 'true'
env:
OPENSSL_VER: 1.1.1v
OPENSSL_VER: 3.0.11
PYTHONSTRICTEXTENSIONBUILD: 1
ASAN_OPTIONS: detect_leaks=0:allocator_may_return_null=1:handle_segv=0
steps:
Expand Down
2 changes: 1 addition & 1 deletion Doc/library/collections.rst
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,7 @@ Common patterns for working with :class:`Counter` objects::
list(c) # list unique elements
set(c) # convert to a set
dict(c) # convert to a regular dictionary
c.items() # convert to a list of (elem, cnt) pairs
c.items() # access the (elem, cnt) pairs
Counter(dict(list_of_pairs)) # convert from a list of (elem, cnt) pairs
c.most_common()[:-n-1:-1] # n least common elements
+c # remove zero and negative counts
Expand Down
33 changes: 21 additions & 12 deletions Doc/library/copy.rst
Original file line number Diff line number Diff line change
Expand Up @@ -88,27 +88,36 @@ pickle functions from the :mod:`copyreg` module.
single: __deepcopy__() (copy protocol)

In order for a class to define its own copy implementation, it can define
special methods :meth:`__copy__` and :meth:`__deepcopy__`. The former is called
to implement the shallow copy operation; no additional arguments are passed.
The latter is called to implement the deep copy operation; it is passed one
argument, the ``memo`` dictionary. If the :meth:`__deepcopy__` implementation needs
to make a deep copy of a component, it should call the :func:`deepcopy` function
with the component as first argument and the memo dictionary as second argument.
The memo dictionary should be treated as an opaque object.
special methods :meth:`~object.__copy__` and :meth:`~object.__deepcopy__`.

.. method:: object.__copy__(self)
:noindexentry:

Called to implement the shallow copy operation;
no additional arguments are passed.

.. method:: object.__deepcopy__(self, memo)
:noindexentry:

Called to implement the deep copy operation; it is passed one
argument, the *memo* dictionary. If the ``__deepcopy__`` implementation needs
to make a deep copy of a component, it should call the :func:`deepcopy` function
with the component as first argument and the *memo* dictionary as second argument.
The *memo* dictionary should be treated as an opaque object.


.. index::
single: __replace__() (replace protocol)

Function :func:`replace` is more limited than :func:`copy` and :func:`deepcopy`,
and only supports named tuples created by :func:`~collections.namedtuple`,
:mod:`dataclasses`, and other classes which define method :meth:`!__replace__`.
:mod:`dataclasses`, and other classes which define method :meth:`~object.__replace__`.

.. method:: __replace__(self, /, **changes)
:noindex:
.. method:: object.__replace__(self, /, **changes)
:noindexentry:

:meth:`!__replace__` should create a new object of the same type,
replacing fields with values from *changes*.
This method should create a new object of the same type,
replacing fields with values from *changes*.


.. seealso::
Expand Down
15 changes: 15 additions & 0 deletions Doc/library/typing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2404,6 +2404,13 @@ types.
>>> Point3D.__total__
True

This attribute reflects *only* the value of the ``total`` argument
to the current ``TypedDict`` class, not whether the class is semantically
total. For example, a ``TypedDict`` with ``__total__`` set to True may
have keys marked with :data:`NotRequired`, or it may inherit from another
``TypedDict`` with ``total=False``. Therefore, it is generally better to use
:attr:`__required_keys__` and :attr:`__optional_keys__` for introspection.

.. attribute:: __required_keys__

.. versionadded:: 3.9
Expand Down Expand Up @@ -2439,6 +2446,14 @@ types.

.. versionadded:: 3.9

.. note::

If ``from __future__ import annotations`` is used or if annotations
are given as strings, annotations are not evaluated when the
``TypedDict`` is defined. Therefore, the runtime introspection that
``__required_keys__`` and ``__optional_keys__`` rely on may not work
properly, and the values of the attributes may be incorrect.

See :pep:`589` for more examples and detailed rules of using ``TypedDict``.

.. versionadded:: 3.8
Expand Down
1 change: 0 additions & 1 deletion Doc/tools/.nitignore
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ Doc/library/collections.rst
Doc/library/concurrent.futures.rst
Doc/library/configparser.rst
Doc/library/contextlib.rst
Doc/library/copy.rst
Doc/library/csv.rst
Doc/library/datetime.rst
Doc/library/dbm.rst
Expand Down
32 changes: 26 additions & 6 deletions Doc/whatsnew/3.12.rst
Original file line number Diff line number Diff line change
Expand Up @@ -701,6 +701,9 @@ dis
:data:`dis.hasarg` collection instead.
(Contributed by Irit Katriel in :gh:`94216`.)

* Add the :data:`dis.hasexc` collection to signify instructions that set
an exception handler. (Contributed by Irit Katriel in :gh:`94216`.)

fractions
---------

Expand Down Expand Up @@ -884,6 +887,10 @@ statistics
sys
---

* Add the :mod:`sys.monitoring` namespace to expose the new :ref:`PEP 669
<whatsnew312-pep669>` monitoring API.
(Contributed by Mark Shannon in :gh:`103082`.)

* Add :func:`sys.activate_stack_trampoline` and
:func:`sys.deactivate_stack_trampoline` for activating and deactivating
stack profiler trampolines,
Expand Down Expand Up @@ -1083,9 +1090,27 @@ CPython bytecode changes
* Remove the :opcode:`!PRECALL` instruction. (Contributed by Mark Shannon in
:gh:`92925`.)

* Add the :opcode:`BINARY_SLICE` and :opcode:`STORE_SLICE` instructions.
(Contributed by Mark Shannon in :gh:`94163`.)

* Add the :opcode:`CALL_INTRINSIC_1` instructions.
(Contributed by Mark Shannon in :gh:`99005`.)

* Add the :opcode:`CALL_INTRINSIC_2` instruction.
(Contributed by Irit Katriel in :gh:`101799`.)

* Add the :opcode:`CLEANUP_THROW` instruction.
(Contributed by Brandt Bucher in :gh:`90997`.)

* Add the :opcode:`!END_SEND` instruction.
(Contributed by Mark Shannon in :gh:`103082`.)

* Add the :opcode:`LOAD_FAST_AND_CLEAR` instruction as part of the
implementation of :pep:`709`. (Contributed by Carl Meyer in :gh:`101441`.)

* Add the :opcode:`LOAD_FAST_CHECK` instruction.
(Contributed by Dennis Sweeney in :gh:`93143`.)

* Add the :opcode:`LOAD_FROM_DICT_OR_DEREF`, :opcode:`LOAD_FROM_DICT_OR_GLOBALS`,
and :opcode:`LOAD_LOCALS` opcodes as part of the implementation of :pep:`695`.
Remove the :opcode:`!LOAD_CLASSDEREF` opcode, which can be replaced with
Expand All @@ -1095,12 +1120,7 @@ CPython bytecode changes
* Add the :opcode:`LOAD_SUPER_ATTR` instruction. (Contributed by Carl Meyer and
Vladimir Matveev in :gh:`103497`.)

FOR_ITER new behavior is not mentioned
The fact that POP_JUMP_IF_* family of instructions are now real instructions is not mentioned
YIELD_VALUE need for an argument is not mentioned



* Add the :opcode:`RETURN_CONST` instruction. (Contributed by Wenyang Wang in :gh:`101632`.)

Demos and Tools
===============
Expand Down
17 changes: 17 additions & 0 deletions Include/cpython/pyatomic.h
Original file line number Diff line number Diff line change
Expand Up @@ -501,3 +501,20 @@ static inline void _Py_atomic_fence_release(void);
#else
# error "no available pyatomic implementation for this platform/compiler"
#endif


// --- aliases ---------------------------------------------------------------

#if SIZEOF_LONG == 8
# define _Py_atomic_load_ulong _Py_atomic_load_uint64
# define _Py_atomic_load_ulong_relaxed _Py_atomic_load_uint64_relaxed
# define _Py_atomic_store_ulong _Py_atomic_store_uint64
# define _Py_atomic_store_ulong_relaxed _Py_atomic_store_uint64_relaxed
#elif SIZEOF_LONG == 4
# define _Py_atomic_load_ulong _Py_atomic_load_uint32
# define _Py_atomic_load_ulong_relaxed _Py_atomic_load_uint32_relaxed
# define _Py_atomic_store_ulong _Py_atomic_store_uint32
# define _Py_atomic_store_ulong_relaxed _Py_atomic_store_uint32_relaxed
#else
# error "long must be 4 or 8 bytes in size"
#endif // SIZEOF_LONG
16 changes: 16 additions & 0 deletions Include/internal/pycore_interp.h
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,8 @@ struct _is {
and _PyInterpreterState_SetFinalizing()
to access it, don't access it directly. */
_Py_atomic_address _finalizing;
/* The ID of the OS thread in which we are finalizing. */
unsigned long _finalizing_id;

struct _gc_runtime_state gc;

Expand Down Expand Up @@ -215,9 +217,23 @@ _PyInterpreterState_GetFinalizing(PyInterpreterState *interp) {
return (PyThreadState*)_Py_atomic_load_relaxed(&interp->_finalizing);
}

static inline unsigned long
_PyInterpreterState_GetFinalizingID(PyInterpreterState *interp) {
return _Py_atomic_load_ulong_relaxed(&interp->_finalizing_id);
}

static inline void
_PyInterpreterState_SetFinalizing(PyInterpreterState *interp, PyThreadState *tstate) {
_Py_atomic_store_relaxed(&interp->_finalizing, (uintptr_t)tstate);
if (tstate == NULL) {
_Py_atomic_store_ulong_relaxed(&interp->_finalizing_id, 0);
}
else {
// XXX Re-enable this assert once gh-109860 is fixed.
//assert(tstate->thread_id == PyThread_get_thread_ident());
_Py_atomic_store_ulong_relaxed(&interp->_finalizing_id,
tstate->thread_id);
}
}


Expand Down
Loading

0 comments on commit cf54f14

Please sign in to comment.