Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit cdc5cdc

Browse files
committed
Merge in the main branch
2 parents f75d7d6 + a6647d1 commit cdc5cdc

315 files changed

Lines changed: 6292 additions & 2072 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/build.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -492,6 +492,7 @@ jobs:
492492
with:
493493
config_hash: ${{ needs.check_source.outputs.config_hash }}
494494
options: ./configure --config-cache --with-thread-sanitizer --with-pydebug
495+
suppressions_path: Tools/tsan/supressions.txt
495496

496497
build_tsan_free_threading:
497498
name: 'Thread sanitizer (free-threading)'
@@ -501,6 +502,7 @@ jobs:
501502
with:
502503
config_hash: ${{ needs.check_source.outputs.config_hash }}
503504
options: ./configure --config-cache --disable-gil --with-thread-sanitizer --with-pydebug
505+
suppressions_path: Tools/tsan/suppressions_free_threading.txt
504506

505507
# CIFuzz job based on https://google.github.io/oss-fuzz/getting-started/continuous-integration/
506508
cifuzz:

.github/workflows/reusable-tsan.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ on:
77
options:
88
required: true
99
type: string
10+
suppressions_path:
11+
description: 'A repo relative path to the suppressions file'
12+
required: true
13+
type: string
1014

1115
jobs:
1216
build_tsan_reusable:
@@ -30,7 +34,7 @@ jobs:
3034
sudo sysctl -w vm.mmap_rnd_bits=28
3135
- name: TSAN Option Setup
3236
run: |
33-
echo "TSAN_OPTIONS=suppressions=${GITHUB_WORKSPACE}/Tools/tsan/supressions.txt" >> $GITHUB_ENV
37+
echo "TSAN_OPTIONS=suppressions=${GITHUB_WORKSPACE}/${{ inputs.suppressions_path }}" >> $GITHUB_ENV
3438
echo "CC=clang" >> $GITHUB_ENV
3539
echo "CXX=clang++" >> $GITHUB_ENV
3640
- name: Add ccache to PATH

Doc/bugs.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,10 @@ have a suggestion on how to fix it, include that as well.
2222
You can also open a discussion item on our
2323
`Documentation Discourse forum <https://discuss.python.org/c/documentation/26>`_.
2424

25+
If you find a bug in the theme (HTML / CSS / JavaScript) of the
26+
documentation, please submit a bug report on the `python-doc-theme bug
27+
tracker <https://github.com/python/python-docs-theme>`_.
28+
2529
If you're short on time, you can also email documentation bug reports to
2630
[email protected] (behavioral bugs can be sent to [email protected]).
2731
'docs@' is a mailing list run by volunteers; your request will be noticed,

Doc/c-api/exceptions.rst

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -221,13 +221,14 @@ For convenience, some of these functions will always return a
221221
222222
.. c:function:: PyObject* PyErr_SetFromWindowsErr(int ierr)
223223
224-
This is a convenience function to raise :exc:`WindowsError`. If called with
224+
This is a convenience function to raise :exc:`OSError`. If called with
225225
*ierr* of ``0``, the error code returned by a call to :c:func:`!GetLastError`
226226
is used instead. It calls the Win32 function :c:func:`!FormatMessage` to retrieve
227227
the Windows description of error code given by *ierr* or :c:func:`!GetLastError`,
228-
then it constructs a tuple object whose first item is the *ierr* value and whose
229-
second item is the corresponding error message (gotten from
230-
:c:func:`!FormatMessage`), and then calls ``PyErr_SetObject(PyExc_WindowsError,
228+
then it constructs a :exc:`OSError` object with the :attr:`~OSError.winerror`
229+
attribute set to the error code, the :attr:`~OSError.strerror` attribute
230+
set to the corresponding error message (gotten from
231+
:c:func:`!FormatMessage`), and then calls ``PyErr_SetObject(PyExc_OSError,
231232
object)``. This function always returns ``NULL``.
232233
233234
.. availability:: Windows.

Doc/c-api/init.rst

Lines changed: 159 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ The following functions can be safely called before Python is initialized:
2929
* :c:func:`PyMem_SetAllocator`
3030
* :c:func:`PyMem_SetupDebugHooks`
3131
* :c:func:`PyObject_SetArenaAllocator`
32+
* :c:func:`Py_SetProgramName`
33+
* :c:func:`Py_SetPythonHome`
3234
* :c:func:`PySys_ResetWarnOptions`
3335

3436
* Informative functions:
@@ -59,7 +61,7 @@ The following functions can be safely called before Python is initialized:
5961
:c:func:`Py_Initialize`: :c:func:`Py_EncodeLocale`, :c:func:`Py_GetPath`,
6062
:c:func:`Py_GetPrefix`, :c:func:`Py_GetExecPrefix`,
6163
:c:func:`Py_GetProgramFullPath`, :c:func:`Py_GetPythonHome`,
62-
and :c:func:`Py_GetProgramName`.
64+
:c:func:`Py_GetProgramName` and :c:func:`PyEval_InitThreads`.
6365

6466

6567
.. _global-conf-vars:
@@ -326,6 +328,7 @@ Initializing and finalizing the interpreter
326328
.. c:function:: void Py_Initialize()
327329
328330
.. index::
331+
single: PyEval_InitThreads()
329332
single: modules (in module sys)
330333
single: path (in module sys)
331334
pair: module; builtins
@@ -425,6 +428,34 @@ Process-wide parameters
425428
=======================
426429
427430
431+
.. c:function:: void Py_SetProgramName(const wchar_t *name)
432+
433+
.. index::
434+
single: Py_Initialize()
435+
single: main()
436+
single: Py_GetPath()
437+
438+
This API is kept for backward compatibility: setting
439+
:c:member:`PyConfig.program_name` should be used instead, see :ref:`Python
440+
Initialization Configuration <init-config>`.
441+
442+
This function should be called before :c:func:`Py_Initialize` is called for
443+
the first time, if it is called at all. It tells the interpreter the value
444+
of the ``argv[0]`` argument to the :c:func:`main` function of the program
445+
(converted to wide characters).
446+
This is used by :c:func:`Py_GetPath` and some other functions below to find
447+
the Python run-time libraries relative to the interpreter executable. The
448+
default value is ``'python'``. The argument should point to a
449+
zero-terminated wide character string in static storage whose contents will not
450+
change for the duration of the program's execution. No code in the Python
451+
interpreter will change the contents of this storage.
452+
453+
Use :c:func:`Py_DecodeLocale` to decode a bytes string to get a
454+
:c:expr:`wchar_*` string.
455+
456+
.. deprecated:: 3.11
457+
458+
428459
.. c:function:: wchar_t* Py_GetProgramName()
429460
430461
Return the program name set with :c:member:`PyConfig.program_name`, or the default.
@@ -626,6 +657,106 @@ Process-wide parameters
626657
``sys.version``.
627658
628659
660+
.. c:function:: void PySys_SetArgvEx(int argc, wchar_t **argv, int updatepath)
661+
662+
.. index::
663+
single: main()
664+
single: Py_FatalError()
665+
single: argv (in module sys)
666+
667+
This API is kept for backward compatibility: setting
668+
:c:member:`PyConfig.argv`, :c:member:`PyConfig.parse_argv` and
669+
:c:member:`PyConfig.safe_path` should be used instead, see :ref:`Python
670+
Initialization Configuration <init-config>`.
671+
672+
Set :data:`sys.argv` based on *argc* and *argv*. These parameters are
673+
similar to those passed to the program's :c:func:`main` function with the
674+
difference that the first entry should refer to the script file to be
675+
executed rather than the executable hosting the Python interpreter. If there
676+
isn't a script that will be run, the first entry in *argv* can be an empty
677+
string. If this function fails to initialize :data:`sys.argv`, a fatal
678+
condition is signalled using :c:func:`Py_FatalError`.
679+
680+
If *updatepath* is zero, this is all the function does. If *updatepath*
681+
is non-zero, the function also modifies :data:`sys.path` according to the
682+
following algorithm:
683+
684+
- If the name of an existing script is passed in ``argv[0]``, the absolute
685+
path of the directory where the script is located is prepended to
686+
:data:`sys.path`.
687+
- Otherwise (that is, if *argc* is ``0`` or ``argv[0]`` doesn't point
688+
to an existing file name), an empty string is prepended to
689+
:data:`sys.path`, which is the same as prepending the current working
690+
directory (``"."``).
691+
692+
Use :c:func:`Py_DecodeLocale` to decode a bytes string to get a
693+
:c:expr:`wchar_*` string.
694+
695+
See also :c:member:`PyConfig.orig_argv` and :c:member:`PyConfig.argv`
696+
members of the :ref:`Python Initialization Configuration <init-config>`.
697+
698+
.. note::
699+
It is recommended that applications embedding the Python interpreter
700+
for purposes other than executing a single script pass ``0`` as *updatepath*,
701+
and update :data:`sys.path` themselves if desired.
702+
See :cve:`2008-5983`.
703+
704+
On versions before 3.1.3, you can achieve the same effect by manually
705+
popping the first :data:`sys.path` element after having called
706+
:c:func:`PySys_SetArgv`, for example using::
707+
708+
PyRun_SimpleString("import sys; sys.path.pop(0)\n");
709+
710+
.. versionadded:: 3.1.3
711+
712+
.. XXX impl. doesn't seem consistent in allowing ``0``/``NULL`` for the params;
713+
check w/ Guido.
714+
715+
.. deprecated:: 3.11
716+
717+
718+
.. c:function:: void PySys_SetArgv(int argc, wchar_t **argv)
719+
720+
This API is kept for backward compatibility: setting
721+
:c:member:`PyConfig.argv` and :c:member:`PyConfig.parse_argv` should be used
722+
instead, see :ref:`Python Initialization Configuration <init-config>`.
723+
724+
This function works like :c:func:`PySys_SetArgvEx` with *updatepath* set
725+
to ``1`` unless the :program:`python` interpreter was started with the
726+
:option:`-I`.
727+
728+
Use :c:func:`Py_DecodeLocale` to decode a bytes string to get a
729+
:c:expr:`wchar_*` string.
730+
731+
See also :c:member:`PyConfig.orig_argv` and :c:member:`PyConfig.argv`
732+
members of the :ref:`Python Initialization Configuration <init-config>`.
733+
734+
.. versionchanged:: 3.4 The *updatepath* value depends on :option:`-I`.
735+
736+
.. deprecated:: 3.11
737+
738+
739+
.. c:function:: void Py_SetPythonHome(const wchar_t *home)
740+
741+
This API is kept for backward compatibility: setting
742+
:c:member:`PyConfig.home` should be used instead, see :ref:`Python
743+
Initialization Configuration <init-config>`.
744+
745+
Set the default "home" directory, that is, the location of the standard
746+
Python libraries. See :envvar:`PYTHONHOME` for the meaning of the
747+
argument string.
748+
749+
The argument should point to a zero-terminated character string in static
750+
storage whose contents will not change for the duration of the program's
751+
execution. No code in the Python interpreter will change the contents of
752+
this storage.
753+
754+
Use :c:func:`Py_DecodeLocale` to decode a bytes string to get a
755+
:c:expr:`wchar_*` string.
756+
757+
.. deprecated:: 3.11
758+
759+
629760
.. c:function:: wchar_t* Py_GetPythonHome()
630761
631762
Return the default "home", that is, the value set by
@@ -841,6 +972,33 @@ code, or when embedding the Python interpreter:
841972
This thread's interpreter state.
842973
843974
975+
.. c:function:: void PyEval_InitThreads()
976+
977+
.. index::
978+
single: PyEval_AcquireThread()
979+
single: PyEval_ReleaseThread()
980+
single: PyEval_SaveThread()
981+
single: PyEval_RestoreThread()
982+
983+
Deprecated function which does nothing.
984+
985+
In Python 3.6 and older, this function created the GIL if it didn't exist.
986+
987+
.. versionchanged:: 3.9
988+
The function now does nothing.
989+
990+
.. versionchanged:: 3.7
991+
This function is now called by :c:func:`Py_Initialize()`, so you don't
992+
have to call it yourself anymore.
993+
994+
.. versionchanged:: 3.2
995+
This function cannot be called before :c:func:`Py_Initialize()` anymore.
996+
997+
.. deprecated:: 3.9
998+
999+
.. index:: pair: module; _thread
1000+
1001+
8441002
.. c:function:: PyThreadState* PyEval_SaveThread()
8451003
8461004
Release the global interpreter lock (if it has been created) and reset the

Doc/c-api/tuple.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,12 @@ Tuple Objects
5959
Return the object at position *pos* in the tuple pointed to by *p*. If *pos* is
6060
negative or out of bounds, return ``NULL`` and set an :exc:`IndexError` exception.
6161
62+
The returned reference is borrowed from the tuple *p*
63+
(that is: it is only valid as long as you hold a reference to *p*).
64+
To get a :term:`strong reference`, use
65+
:c:func:`Py_NewRef(PyTuple_GetItem(...)) <Py_NewRef>`
66+
or :c:func:`PySequence_GetItem`.
67+
6268
6369
.. c:function:: PyObject* PyTuple_GET_ITEM(PyObject *p, Py_ssize_t pos)
6470

Doc/c-api/typeobj.rst

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1034,7 +1034,8 @@ and :c:data:`PyType_Type` effectively act as defaults.)
10341034
the type, and the type object is INCREF'ed when a new instance is created, and
10351035
DECREF'ed when an instance is destroyed (this does not apply to instances of
10361036
subtypes; only the type referenced by the instance's ob_type gets INCREF'ed or
1037-
DECREF'ed).
1037+
DECREF'ed). Heap types should also :ref:`support garbage collection <supporting-cycle-detection>`
1038+
as they can form a reference cycle with their own module object.
10381039

10391040
**Inheritance:**
10401041

Doc/conf.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
sys.path.append(os.path.abspath('tools/extensions'))
1313
sys.path.append(os.path.abspath('includes'))
1414

15+
from pyspecific import SOURCE_URI
16+
1517
# General configuration
1618
# ---------------------
1719

@@ -24,6 +26,7 @@
2426
'pyspecific',
2527
'sphinx.ext.coverage',
2628
'sphinx.ext.doctest',
29+
'sphinx.ext.extlinks',
2730
]
2831

2932
# Skip if downstream redistributors haven't installed them
@@ -513,6 +516,19 @@
513516
r'https://unix.org/version2/whatsnew/lp64_wp.html',
514517
]
515518

519+
# Options for sphinx.ext.extlinks
520+
# -------------------------------
521+
522+
# This config is a dictionary of external sites,
523+
# mapping unique short aliases to a base URL and a prefix.
524+
# https://www.sphinx-doc.org/en/master/usage/extensions/extlinks.html
525+
extlinks = {
526+
"cve": ("https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-%s", "CVE-%s"),
527+
"cwe": ("https://cwe.mitre.org/data/definitions/%s.html", "CWE-%s"),
528+
"pypi": ("https://pypi.org/project/%s/", "%s"),
529+
"source": (SOURCE_URI, "%s"),
530+
}
531+
extlinks_detect_hardcoded_links = True
516532

517533
# Options for extensions
518534
# ----------------------

Doc/data/stable_abi.dat

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Doc/faq/library.rst

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -616,16 +616,15 @@ use ``p.read(n)``.
616616
("ptys") instead of pipes. Or you can use a Python interface to Don Libes'
617617
"expect" library. A Python extension that interfaces to expect is called
618618
"expy" and available from https://expectpy.sourceforge.net. A pure Python
619-
solution that works like expect is `pexpect
620-
<https://pypi.org/project/pexpect/>`_.
619+
solution that works like expect is :pypi:`pexpect`.
621620
622621
623622
How do I access the serial (RS232) port?
624623
----------------------------------------
625624
626625
For Win32, OSX, Linux, BSD, Jython, IronPython:
627626
628-
https://pypi.org/project/pyserial/
627+
:pypi:`pyserial`
629628
630629
For Unix, see a Usenet post by Mitch Chapman:
631630

0 commit comments

Comments
 (0)