Skip to content

Commit 8252a89

Browse files
authored
Merge branch 'main' into wasi-refactor
2 parents 60568ba + 107863e commit 8252a89

39 files changed

+520
-122
lines changed

Doc/c-api/exceptions.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -699,6 +699,8 @@ Signal Handling
699699
700700
- Executing a pending :ref:`remote debugger <remote-debugging>` script.
701701
702+
- Raise the exception set by :c:func:`PyThreadState_SetAsyncExc`.
703+
702704
If any handler raises an exception, immediately return ``-1`` with that
703705
exception set.
704706
Any remaining interruptions are left to be processed on the next
@@ -714,6 +716,9 @@ Signal Handling
714716
This function may now execute a remote debugger script, if remote
715717
debugging is enabled.
716718
719+
.. versionchanged:: next
720+
The exception set by :c:func:`PyThreadState_SetAsyncExc` is now raised.
721+
717722
718723
.. c:function:: void PyErr_SetInterrupt()
719724

Doc/c-api/threads.rst

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -699,13 +699,25 @@ pointer and a void pointer argument.
699699
700700
.. c:function:: int PyThreadState_SetAsyncExc(unsigned long id, PyObject *exc)
701701
702-
Asynchronously raise an exception in a thread. The *id* argument is the thread
703-
id of the target thread; *exc* is the exception object to be raised. This
704-
function does not steal any references to *exc*. To prevent naive misuse, you
705-
must write your own C extension to call this. Must be called with an :term:`attached thread state`.
706-
Returns the number of thread states modified; this is normally one, but will be
707-
zero if the thread id isn't found. If *exc* is ``NULL``, the pending
708-
exception (if any) for the thread is cleared. This raises no exceptions.
702+
Schedule an exception to be raised asynchronously in a thread.
703+
If the thread has a previously scheduled exception, it is overwritten.
704+
705+
The *id* argument is the thread id of the target thread, as returned by
706+
:c:func:`PyThread_get_thread_ident`.
707+
*exc* is the class of the exception to be raised, or ``NULL`` to clear
708+
the pending exception (if any).
709+
710+
Return the number of affected thread states.
711+
This is normally ``1`` if *id* is found, even when no change was
712+
made (the given *exc* was already pending, or *exc* is ``NULL`` but
713+
no exception is pending).
714+
If the thread id isn't found, return ``0``. This raises no exceptions.
715+
716+
To prevent naive misuse, you must write your own C extension to call this.
717+
This function must be called with an :term:`attached thread state`.
718+
This function does not steal any references to *exc*.
719+
This function does not necessarily interrupt system calls such as
720+
:py:func:`~time.sleep`.
709721
710722
.. versionchanged:: 3.7
711723
The type of the *id* parameter changed from :c:expr:`long` to
@@ -743,7 +755,8 @@ Operating system thread APIs
743755
:term:`attached thread state`.
744756
745757
.. seealso::
746-
:py:func:`threading.get_ident`
758+
:py:func:`threading.get_ident` and :py:attr:`threading.Thread.ident`
759+
expose this identifier to Python.
747760
748761
749762
.. c:function:: PyObject *PyThread_GetInfo(void)

Doc/library/site.rst

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,8 @@ When running under a :ref:`virtual environment <sys-path-init-virtual-environmen
6464
the ``pyvenv.cfg`` file in :data:`sys.prefix` is checked for site-specific
6565
configurations. If the ``include-system-site-packages`` key exists and is set to
6666
``true`` (case-insensitive), the system-level prefixes will be searched for
67-
site-packages, otherwise they won't.
67+
site-packages, otherwise they won't. If the system-level prefixes are not searched then
68+
the user site prefixes are also implicitly not searched for site-packages.
6869

6970
.. index::
7071
single: # (hash); comment

Doc/library/sys_path_init.rst

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -57,15 +57,19 @@ otherwise they are set to the same value as :data:`sys.base_prefix` and
5757
:data:`sys.base_exec_prefix`, respectively.
5858
This is used by :ref:`sys-path-init-virtual-environments`.
5959

60-
Finally, the :mod:`site` module is processed and :file:`site-packages` directories
61-
are added to the module search path. A common way to customize the search path is
62-
to create :mod:`sitecustomize` or :mod:`usercustomize` modules as described in
63-
the :mod:`site` module documentation.
60+
Finally, the :mod:`site` module is processed and :file:`site-packages`
61+
directories are added to the module search path. The :envvar:`PYTHONUSERBASE`
62+
environment variable controls where is searched for user site-packages and the
63+
:envvar:`PYTHONNOUSERSITE` environment variable prevents searching for user
64+
site-packages all together. A common way to customize the search path is to
65+
create :mod:`sitecustomize` or :mod:`usercustomize` modules as described in the
66+
:mod:`site` module documentation.
6467

6568
.. note::
6669

67-
Certain command line options may further affect path calculations.
68-
See :option:`-E`, :option:`-I`, :option:`-s` and :option:`-S` for further details.
70+
The command line options :option:`-E`, :option:`-P`, :option:`-I`,
71+
:option:`-S` and :option:`-s` further affect path calculations, see their
72+
documentation for details.
6973

7074
.. versionchanged:: 3.14
7175

@@ -96,11 +100,10 @@ Please refer to :mod:`site`'s
96100

97101
.. note::
98102

99-
There are other ways how "virtual environments" could be implemented, this
100-
documentation refers implementations based on the ``pyvenv.cfg`` mechanism,
101-
such as :mod:`venv`. Most virtual environment implementations follow the
102-
model set by :mod:`venv`, but there may be exotic implementations that
103-
diverge from it.
103+
There are other ways "virtual environments" could be implemented.
104+
This documentation refers to implementations based on the ``pyvenv.cfg``
105+
mechanism, such as :mod:`venv`, that many virtual environment implementations
106+
follow.
104107

105108
_pth files
106109
----------

Doc/using/cmdline.rst

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -949,8 +949,9 @@ conflict.
949949

950950
.. envvar:: PYTHONNOUSERSITE
951951

952-
If this is set, Python won't add the :data:`user site-packages directory
953-
<site.USER_SITE>` to :data:`sys.path`.
952+
This is equivalent to the :option:`-s` option. If this is set, Python won't
953+
add the :data:`user site-packages directory <site.USER_SITE>` to
954+
:data:`sys.path`.
954955

955956
.. seealso::
956957

@@ -964,6 +965,9 @@ conflict.
964965
and :ref:`installation paths <sysconfig-user-scheme>` for
965966
``python -m pip install --user``.
966967

968+
To disable the user site-packages, see :envvar:`PYTHONNOUSERSITE` or the :option:`-s`
969+
option.
970+
967971
.. seealso::
968972

969973
:pep:`370` -- Per user site-packages directory

Include/cpython/ceval.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@ _PyEval_RequestCodeExtraIndex(freefunc f) {
2323

2424
PyAPI_FUNC(int) _PyEval_SliceIndex(PyObject *, Py_ssize_t *);
2525
PyAPI_FUNC(int) _PyEval_SliceIndexNotNone(PyObject *, Py_ssize_t *);
26+
PyAPI_FUNC(int) _PyEval_UnpackIndices(PyObject *, PyObject *,
27+
Py_ssize_t,
28+
Py_ssize_t *, Py_ssize_t *);
2629

2730

2831
// Trampoline API

Include/internal/pycore_ceval.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -286,6 +286,9 @@ PyAPI_FUNC(PyObject *)_Py_MakeCoro(PyFunctionObject *func);
286286
and asynchronous exception */
287287
PyAPI_FUNC(int) _Py_HandlePending(PyThreadState *tstate);
288288

289+
/* Raise exception set by PyThreadState_SetAsyncExc, if any */
290+
PyAPI_FUNC(int) _PyEval_RaiseAsyncExc(PyThreadState *tstate);
291+
289292
extern PyObject * _PyEval_GetFrameLocals(void);
290293

291294
typedef PyObject *(*conversion_func)(PyObject *);

Include/internal/pycore_list.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ extern "C" {
1414

1515
PyAPI_FUNC(PyObject*) _PyList_Extend(PyListObject *, PyObject *);
1616
PyAPI_FUNC(PyObject) *_PyList_SliceSubscript(PyObject*, PyObject*);
17+
PyAPI_FUNC(PyObject *) _PyList_BinarySlice(PyObject *, PyObject *, PyObject *);
1718
extern void _PyList_DebugMallocStats(FILE *out);
1819
// _PyList_GetItemRef should be used only when the object is known as a list
1920
// because it doesn't raise TypeError when the object is not a list, whereas PyList_GetItemRef does.

Include/internal/pycore_tuple.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ extern PyStatus _PyTuple_InitGlobalObjects(PyInterpreterState *);
2525

2626
PyAPI_FUNC(PyObject *)_PyTuple_FromStackRefStealOnSuccess(const union _PyStackRef *, Py_ssize_t);
2727
PyAPI_FUNC(PyObject *)_PyTuple_FromArraySteal(PyObject *const *, Py_ssize_t);
28+
PyAPI_FUNC(PyObject *) _PyTuple_BinarySlice(PyObject *, PyObject *, PyObject *);
2829

2930
typedef struct {
3031
PyObject_HEAD

Include/internal/pycore_unicodeobject.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ extern PyObject* _PyUnicode_ResizeCompact(
3232
PyObject *unicode,
3333
Py_ssize_t length);
3434
extern PyObject* _PyUnicode_GetEmpty(void);
35+
PyAPI_FUNC(PyObject*) _PyUnicode_BinarySlice(PyObject *, PyObject *, PyObject *);
3536

3637

3738
/* Generic helper macro to convert characters of different types.

0 commit comments

Comments
 (0)