Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
79 changes: 41 additions & 38 deletions Doc/library/_thread.rst
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,6 @@ This module defines the following constants and functions:
This is now a synonym of the built-in :exc:`RuntimeError`.


.. data:: LockType

This is the type of lock objects.


.. function:: start_new_thread(function, args[, kwargs])

Start a new thread and return its identifier. The thread executes the
Expand Down Expand Up @@ -162,58 +157,66 @@ This module defines the following constants and functions:
.. versionadded:: 3.2


Lock objects have the following methods:
.. raw:: html

<!-- Keep the old URL fragments working (see gh-89554) -->
<span id='thread.lock.acquire'></span>
<span id='thread.lock.release'></span>
<span id='thread.lock.locked'></span>

.. class:: LockType

.. method:: lock.acquire(blocking=True, timeout=-1)
This is the type of lock objects.

Without any optional argument, this method acquires the lock unconditionally, if
necessary waiting until it is released by another thread (only one thread at a
time can acquire a lock --- that's their reason for existence).
Lock objects have the following methods:

If the *blocking* argument is present, the action depends on its
value: if it is false, the lock is only acquired if it can be acquired
immediately without waiting, while if it is true, the lock is acquired
unconditionally as above.
.. method:: acquire(blocking=True, timeout=-1)

If the floating-point *timeout* argument is present and positive, it
specifies the maximum wait time in seconds before returning. A negative
*timeout* argument specifies an unbounded wait. You cannot specify
a *timeout* if *blocking* is false.
Without any optional argument, this method acquires the lock unconditionally, if
necessary waiting until it is released by another thread (only one thread at a
time can acquire a lock --- that's their reason for existence).

The return value is ``True`` if the lock is acquired successfully,
``False`` if not.
If the *blocking* argument is present, the action depends on its
value: if it is false, the lock is only acquired if it can be acquired
immediately without waiting, while if it is true, the lock is acquired
unconditionally as above.

.. versionchanged:: 3.2
The *timeout* parameter is new.
If the floating-point *timeout* argument is present and positive, it
specifies the maximum wait time in seconds before returning. A negative
*timeout* argument specifies an unbounded wait. You cannot specify
a *timeout* if *blocking* is false.

.. versionchanged:: 3.2
Lock acquires can now be interrupted by signals on POSIX.
The return value is ``True`` if the lock is acquired successfully,
``False`` if not.

.. versionchanged:: 3.14
Lock acquires can now be interrupted by signals on Windows.
.. versionchanged:: 3.2
The *timeout* parameter is new.

.. versionchanged:: 3.2
Lock acquires can now be interrupted by signals on POSIX.

.. method:: lock.release()
.. versionchanged:: 3.14
Lock acquires can now be interrupted by signals on Windows.

Releases the lock. The lock must have been acquired earlier, but not
necessarily by the same thread.
.. method:: release()

Releases the lock. The lock must have been acquired earlier, but not
necessarily by the same thread.

.. method:: lock.locked()
.. method:: locked()

Return the status of the lock: ``True`` if it has been acquired by some thread,
``False`` if not.
Return the status of the lock: ``True`` if it has been acquired by some thread,
``False`` if not.

In addition to these methods, lock objects can also be used via the
:keyword:`with` statement, e.g.::
In addition to these methods, lock objects can also be used via the
:keyword:`with` statement, e.g.::

import _thread
import _thread

a_lock = _thread.allocate_lock()
a_lock = _thread.allocate_lock()

with a_lock:
print("a_lock is locked while this executes")
with a_lock:
print("a_lock is locked while this executes")

**Caveats:**

Expand Down
57 changes: 37 additions & 20 deletions Doc/library/functions.rst
Original file line number Diff line number Diff line change
Expand Up @@ -19,31 +19,33 @@ are always available. They are listed here in alphabetical order.
| | :func:`ascii` | | :func:`filter` | | :func:`map` | | **S** |
| | | | :func:`float` | | :func:`max` | | |func-set|_ |
| | **B** | | :func:`format` | | |func-memoryview|_ | | :func:`setattr` |
| | :func:`bin` | | |func-frozenset|_ | | :func:`min` | | :func:`sentinel` |
| | :func:`bool` | | | | | | :func:`slice` |
| | :func:`breakpoint` | | **G** | | **N** | | :func:`sorted` |
| | |func-bytearray|_ | | :func:`getattr` | | :func:`next` | | :func:`staticmethod` |
| | |func-bytes|_ | | :func:`globals` | | | | |func-str|_ |
| | | | | | **O** | | :func:`sum` |
| | **C** | | **H** | | :func:`object` | | :func:`super` |
| | :func:`callable` | | :func:`hasattr` | | :func:`oct` | | **T** |
| | :func:`chr` | | :func:`hash` | | :func:`open` | | |func-tuple|_ |
| | :func:`classmethod` | | :func:`help` | | :func:`ord` | | :func:`type` |
| | :func:`compile` | | :func:`hex` | | | | |
| | :func:`complex` | | | | **P** | | **V** |
| | | | **I** | | :func:`pow` | | :func:`vars` |
| | **D** | | :func:`id` | | :func:`print` | | |
| | :func:`delattr` | | :func:`input` | | :func:`property` | | **Z** |
| | |func-dict|_ | | :func:`int` | | | | :func:`zip` |
| | :func:`dir` | | :func:`isinstance` | | | | |
| | :func:`divmod` | | :func:`issubclass` | | | | **_** |
| | :func:`bin` | | |func-frozendict|_ | | :func:`min` | | :func:`sentinel` |
| | :func:`bool` | | |func-frozenset|_ | | | | :func:`slice` |
| | :func:`breakpoint` | | | | **N** | | :func:`sorted` |
| | |func-bytearray|_ | | **G** | | :func:`next` | | :func:`staticmethod` |
| | |func-bytes|_ | | :func:`getattr` | | | | |func-str|_ |
| | | | :func:`globals` | | **O** | | :func:`sum` |
| | **C** | | | | :func:`object` | | :func:`super` |
| | :func:`callable` | | **H** | | :func:`oct` | | |
| | :func:`chr` | | :func:`hasattr` | | :func:`open` | | **T** |
| | :func:`classmethod` | | :func:`hash` | | :func:`ord` | | |func-tuple|_ |
| | :func:`compile` | | :func:`help` | | | | :func:`type` |
| | :func:`complex` | | :func:`hex` | | **P** | | |
| | | | | | :func:`pow` | | **V** |
| | **D** | | **I** | | :func:`print` | | :func:`vars` |
| | :func:`delattr` | | :func:`id` | | :func:`property` | | |
| | |func-dict|_ | | :func:`input` | | | | **Z** |
| | :func:`dir` | | :func:`int` | | | | :func:`zip` |
| | :func:`divmod` | | :func:`isinstance` | | | | |
| | | | :func:`issubclass` | | | | **_** |
| | | | :func:`iter` | | | | :func:`__import__` |
+-------------------------+-----------------------+-----------------------+-------------------------+

.. using :func:`dict` would create a link to another page, so local targets are
used, with replacement texts to make the output in the table consistent

.. |func-dict| replace:: ``dict()``
.. |func-frozendict| replace:: ``frozendict()``
.. |func-frozenset| replace:: ``frozenset()``
.. |func-memoryview| replace:: ``memoryview()``
.. |func-set| replace:: ``set()``
Expand Down Expand Up @@ -485,8 +487,8 @@ are always available. They are listed here in alphabetical order.
Create a new dictionary. The :class:`dict` object is the dictionary class.
See :class:`dict` and :ref:`typesmapping` for documentation about this class.

For other containers see the built-in :class:`list`, :class:`set`, and
:class:`tuple` classes, as well as the :mod:`collections` module.
For other containers see the built-in :class:`frozendict`, :class:`list`,
:class:`set`, and :class:`tuple` classes, as well as the :mod:`collections` module.


.. function:: dir()
Expand Down Expand Up @@ -864,6 +866,21 @@ are always available. They are listed here in alphabetical order.
if *format_spec* is not an empty string.


.. _func-frozendict:
.. class:: frozendict(**kwargs)
frozendict(mapping, /, **kwargs)
frozendict(iterable, /, **kwargs)
:noindex:

Create a new frozen dictionary. The :class:`frozendict` object is a built-in class.
See :class:`frozendict` and :ref:`typesmapping` for documentation about this class.

For other containers see the built-in :class:`dict`, :class:`list`, :class:`set`,
and :class:`tuple` classes, as well as the :mod:`collections` module.

.. versionadded:: 3.15


.. _func-frozenset:
.. class:: frozenset(iterable=(), /)
:noindex:
Expand Down
15 changes: 15 additions & 0 deletions Doc/library/sys.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1481,6 +1481,21 @@ always available. Unless explicitly noted otherwise, all variables are read-only
They hold the legacy representation of ``sys.last_exc``, as returned
from :func:`exc_info` above.


.. data:: lazy_modules

A :class:`set` of fully qualified module name strings that have been lazily
imported in the current interpreter but not yet loaded. When a
lazily imported module is accessed for the first time, its name is removed
from this set.

This attribute is intended for debugging and introspection.

See also :func:`set_lazy_imports` and :pep:`810`.

.. versionadded:: 3.15


.. data:: maxsize

An integer giving the maximum value a variable of type :c:type:`Py_ssize_t` can
Expand Down
5 changes: 3 additions & 2 deletions Include/internal/pycore_gc.h
Original file line number Diff line number Diff line change
Expand Up @@ -335,8 +335,9 @@ extern void _Py_RunGC(PyThreadState *tstate);
union _PyStackRef;

// GC visit callback for tracked interpreter frames
extern int _PyGC_VisitFrameStack(_PyInterpreterFrame *frame, visitproc visit, void *arg);
extern int _PyGC_VisitStackRef(union _PyStackRef *ref, visitproc visit, void *arg);
// GH-150766: exported for greenlet
PyAPI_FUNC(int) _PyGC_VisitFrameStack(_PyInterpreterFrame *frame, visitproc visit, void *arg);
PyAPI_FUNC(int) _PyGC_VisitStackRef(union _PyStackRef *ref, visitproc visit, void *arg);

#ifdef Py_GIL_DISABLED
extern void _PyGC_VisitObjectsWorldStopped(PyInterpreterState *interp,
Expand Down
2 changes: 1 addition & 1 deletion Lib/email/_parseaddr.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ def _parsedate_tz(data):

The last (additional) element is the time zone offset in seconds, except if
the timezone was specified as -0000. In that case the last element is
None. This indicates a UTC timestamp that explicitly declaims knowledge of
None. This indicates a UTC timestamp that explicitly disclaims knowledge of
the source timezone, as opposed to a +0000 timestamp that indicates the
source timezone really was UTC.

Expand Down
2 changes: 1 addition & 1 deletion Misc/NEWS.d/3.15.0a8.rst
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,7 @@ Fix :func:`repr` for lists and tuples containing ``NULL``\ s.
.. nonce: aB3xKm
.. section: Core and Builtins

Fixed ``sys.lazy_modules`` to include lazy modules without submodules. Patch
Fixed :py:attr:`sys.lazy_modules` to include lazy modules without submodules. Patch
by Bartosz Sławecki.

..
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
``sys.lazy_modules`` is now a set instead of a dict as initially spelled out in PEP 810.
:py:attr:`sys.lazy_modules` is now a set instead of a dict as initially spelled out in PEP 810.
1 change: 1 addition & 0 deletions PC/python_uwp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#if defined(__clang__)
#define _SILENCE_CLANG_COROUTINE_MESSAGE
#endif
#define _SILENCE_EXPERIMENTAL_COROUTINE_DEPRECATION_WARNINGS

#include <appmodel.h>
#include <winrt\Windows.ApplicationModel.h>
Expand Down
Loading