Skip to content

Commit 015d000

Browse files
committed
Merge branch 'main' into make-opcode-static
2 parents 536ee25 + 808071b commit 015d000

File tree

117 files changed

+4834
-3163
lines changed

Some content is hidden

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

117 files changed

+4834
-3163
lines changed

Doc/c-api/init.rst

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -622,7 +622,8 @@ Process-wide parameters
622622
It now returns ``NULL`` if called before :c:func:`Py_Initialize`.
623623
624624
.. deprecated-removed:: 3.13 3.15
625-
Get :data:`sys.executable` instead.
625+
Use :c:func:`PyConfig_Get("executable") <PyConfig_Get>`
626+
(:data:`sys.executable`) instead.
626627
627628
628629
.. c:function:: wchar_t* Py_GetPrefix()
@@ -644,8 +645,10 @@ Process-wide parameters
644645
It now returns ``NULL`` if called before :c:func:`Py_Initialize`.
645646
646647
.. deprecated-removed:: 3.13 3.15
647-
Get :data:`sys.base_prefix` instead, or :data:`sys.prefix` if
648-
:ref:`virtual environments <venv-def>` need to be handled.
648+
Use :c:func:`PyConfig_Get("base_prefix") <PyConfig_Get>`
649+
(:data:`sys.base_prefix`) instead. Use :c:func:`PyConfig_Get("prefix")
650+
<PyConfig_Get>` (:data:`sys.prefix`) if :ref:`virtual environments
651+
<venv-def>` need to be handled.
649652
650653
651654
.. c:function:: wchar_t* Py_GetExecPrefix()
@@ -690,9 +693,11 @@ Process-wide parameters
690693
It now returns ``NULL`` if called before :c:func:`Py_Initialize`.
691694

692695
.. deprecated-removed:: 3.13 3.15
693-
Get :data:`sys.base_exec_prefix` instead, or :data:`sys.exec_prefix` if
694-
:ref:`virtual environments <venv-def>` need to be handled.
695-
696+
Use :c:func:`PyConfig_Get("base_exec_prefix") <PyConfig_Get>`
697+
(:data:`sys.base_exec_prefix`) instead. Use
698+
:c:func:`PyConfig_Get("exec_prefix") <PyConfig_Get>`
699+
(:data:`sys.exec_prefix`) if :ref:`virtual environments <venv-def>` need
700+
to be handled.
696701

697702
.. c:function:: wchar_t* Py_GetProgramFullPath()
698703
@@ -712,7 +717,8 @@ Process-wide parameters
712717
It now returns ``NULL`` if called before :c:func:`Py_Initialize`.
713718

714719
.. deprecated-removed:: 3.13 3.15
715-
Get :data:`sys.executable` instead.
720+
Use :c:func:`PyConfig_Get("executable") <PyConfig_Get>`
721+
(:data:`sys.executable`) instead.
716722

717723

718724
.. c:function:: wchar_t* Py_GetPath()
@@ -740,8 +746,8 @@ Process-wide parameters
740746
It now returns ``NULL`` if called before :c:func:`Py_Initialize`.
741747

742748
.. deprecated-removed:: 3.13 3.15
743-
Get :data:`sys.path` instead.
744-
749+
Use :c:func:`PyConfig_Get("module_search_paths") <PyConfig_Get>`
750+
(:data:`sys.path`) instead.
745751

746752
.. c:function:: const char* Py_GetVersion()
747753
@@ -926,8 +932,8 @@ Process-wide parameters
926932
It now returns ``NULL`` if called before :c:func:`Py_Initialize`.
927933
928934
.. deprecated-removed:: 3.13 3.15
929-
Get :c:member:`PyConfig.home` or :envvar:`PYTHONHOME` environment
930-
variable instead.
935+
Use :c:func:`PyConfig_Get("home") <PyConfig_Get>` or the
936+
:envvar:`PYTHONHOME` environment variable instead.
931937
932938
933939
.. _threads:

Doc/c-api/module.rst

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -523,9 +523,6 @@ state:
523523
524524
On success, return ``0``. On error, raise an exception and return ``-1``.
525525
526-
Return ``-1`` if *value* is ``NULL``. It must be called with an exception
527-
raised in this case.
528-
529526
Example usage::
530527
531528
static int
@@ -540,6 +537,10 @@ state:
540537
return res;
541538
}
542539
540+
To be convenient, the function accepts ``NULL`` *value* with an exception
541+
set. In this case, return ``-1`` and just leave the raised exception
542+
unchanged.
543+
543544
The example can also be written without checking explicitly if *obj* is
544545
``NULL``::
545546

Doc/conf.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
'changes',
2929
'glossary_search',
3030
'lexers',
31+
'misc_news',
3132
'pydoc_topics',
3233
'pyspecific',
3334
'sphinx.ext.coverage',

Doc/data/stable_abi.dat

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

Doc/deprecations/c-api-pending-removal-in-3.15.rst

Lines changed: 24 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -10,25 +10,35 @@ Pending removal in Python 3.15
1010
:c:func:`PyWeakref_GetRef` on Python 3.12 and older.
1111
* :c:type:`Py_UNICODE` type and the :c:macro:`!Py_UNICODE_WIDE` macro:
1212
Use :c:type:`wchar_t` instead.
13-
* Python initialization functions:
13+
* Python initialization functions, deprecated in Python 3.13:
1414

15-
* :c:func:`PySys_ResetWarnOptions`:
16-
Clear :data:`sys.warnoptions` and :data:`!warnings.filters` instead.
17-
* :c:func:`Py_GetExecPrefix`:
18-
Get :data:`sys.base_exec_prefix` and :data:`sys.exec_prefix` instead.
1915
* :c:func:`Py_GetPath`:
20-
Get :data:`sys.path` instead.
16+
Use :c:func:`PyConfig_Get("module_search_paths") <PyConfig_Get>`
17+
(:data:`sys.path`) instead.
2118
* :c:func:`Py_GetPrefix`:
22-
Get :data:`sys.base_prefix` and :data:`sys.prefix` instead.
19+
Use :c:func:`PyConfig_Get("base_prefix") <PyConfig_Get>`
20+
(:data:`sys.base_prefix`) instead. Use :c:func:`PyConfig_Get("prefix")
21+
<PyConfig_Get>` (:data:`sys.prefix`) if :ref:`virtual environments
22+
<venv-def>` need to be handled.
23+
* :c:func:`Py_GetExecPrefix`:
24+
Use :c:func:`PyConfig_Get("base_exec_prefix") <PyConfig_Get>`
25+
(:data:`sys.base_exec_prefix`) instead. Use
26+
:c:func:`PyConfig_Get("exec_prefix") <PyConfig_Get>`
27+
(:data:`sys.exec_prefix`) if :ref:`virtual environments <venv-def>` need to
28+
be handled.
2329
* :c:func:`Py_GetProgramFullPath`:
24-
Get :data:`sys.executable` instead.
30+
Use :c:func:`PyConfig_Get("executable") <PyConfig_Get>`
31+
(:data:`sys.executable`) instead.
2532
* :c:func:`Py_GetProgramName`:
26-
Get :data:`sys.executable` instead.
33+
Use :c:func:`PyConfig_Get("executable") <PyConfig_Get>`
34+
(:data:`sys.executable`) instead.
2735
* :c:func:`Py_GetPythonHome`:
28-
Get :c:func:`PyConfig_Get("home") <PyConfig_Get>`
29-
or the :envvar:`PYTHONHOME` environment variable instead.
36+
Use :c:func:`PyConfig_Get("home") <PyConfig_Get>` or the
37+
:envvar:`PYTHONHOME` environment variable instead.
3038

31-
See also the :c:func:`PyConfig_Get` function.
39+
The `pythoncapi-compat project
40+
<https://github.com/python/pythoncapi-compat/>`__ can be used to get
41+
:c:func:`PyConfig_Get` on Python 3.13 and older.
3242

3343
* Functions to configure Python's initialization, deprecated in Python 3.11:
3444

@@ -40,6 +50,8 @@ Pending removal in Python 3.15
4050
Set :c:member:`PyConfig.program_name` instead.
4151
* :c:func:`!Py_SetPythonHome()`:
4252
Set :c:member:`PyConfig.home` instead.
53+
* :c:func:`PySys_ResetWarnOptions`:
54+
Clear :data:`sys.warnoptions` and :data:`!warnings.filters` instead.
4355

4456
The :c:func:`Py_InitializeFromConfig` API should be used with
4557
:c:type:`PyConfig` instead.

Doc/glossary.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -658,6 +658,9 @@ Glossary
658658
and therefore it is never deallocated while the interpreter is running.
659659
For example, :const:`True` and :const:`None` are immortal in CPython.
660660

661+
Immortal objects can be identified via :func:`sys._is_immortal`, or
662+
via :c:func:`PyUnstable_IsImmortal` in the C API.
663+
661664
immutable
662665
An object with a fixed value. Immutable objects include numbers, strings and
663666
tuples. Such an object cannot be altered. A new object has to

Doc/library/exceptions.rst

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -562,9 +562,13 @@ The following exceptions are the exceptions that are usually raised.
562562

563563
Raised when the interpreter finds an internal error, but the situation does not
564564
look so serious to cause it to abandon all hope. The associated value is a
565-
string indicating what went wrong (in low-level terms).
565+
string indicating what went wrong (in low-level terms). In :term:`CPython`,
566+
this could be raised by incorrectly using Python's C API, such as returning
567+
a ``NULL`` value without an exception set.
566568

567-
You should report this to the author or maintainer of your Python interpreter.
569+
If you're confident that this exception wasn't your fault, or the fault of
570+
a package you're using, you should report this to the author or maintainer
571+
of your Python interpreter.
568572
Be sure to report the version of the Python interpreter (``sys.version``; it is
569573
also printed at the start of an interactive Python session), the exact error
570574
message (the exception's associated value) and if possible the source of the

Doc/library/shutil.rst

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -512,7 +512,9 @@ the use of userspace buffers in Python as in "``outfd.write(infd.read())``".
512512

513513
On macOS `fcopyfile`_ is used to copy the file content (not metadata).
514514

515-
On Linux and Solaris :func:`os.sendfile` is used.
515+
On Linux :func:`os.copy_file_range` or :func:`os.sendfile` is used.
516+
517+
On Solaris :func:`os.sendfile` is used.
516518

517519
On Windows :func:`shutil.copyfile` uses a bigger default buffer size (1 MiB
518520
instead of 64 KiB) and a :func:`memoryview`-based variant of
@@ -527,6 +529,10 @@ file then shutil will silently fallback on using less efficient
527529
.. versionchanged:: 3.14
528530
Solaris now uses :func:`os.sendfile`.
529531

532+
.. versionchanged:: next
533+
Copy-on-write or server-side copy may be used internally via
534+
:func:`os.copy_file_range` on supported Linux filesystems.
535+
530536
.. _shutil-copytree-example:
531537

532538
copytree example

Doc/library/sys.rst

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -855,6 +855,11 @@ always available. Unless explicitly noted otherwise, all variables are read-only
855855
reflect the actual number of references. Consequently, do not rely
856856
on the returned value to be accurate, other than a value of 0 or 1.
857857

858+
.. impl-detail::
859+
860+
:term:`Immortal <immortal>` objects with a large reference count can be
861+
identified via :func:`_is_immortal`.
862+
858863
.. versionchanged:: 3.12
859864
Immortal objects have very large refcounts that do not match
860865
the actual number of references to the object.
@@ -1264,6 +1269,24 @@ always available. Unless explicitly noted otherwise, all variables are read-only
12641269

12651270
.. versionadded:: 3.12
12661271

1272+
.. function:: _is_immortal(op)
1273+
1274+
Return :const:`True` if the given object is :term:`immortal`, :const:`False`
1275+
otherwise.
1276+
1277+
.. note::
1278+
1279+
Objects that are immortal (and thus return ``True`` upon being passed
1280+
to this function) are not guaranteed to be immortal in future versions,
1281+
and vice versa for mortal objects.
1282+
1283+
.. versionadded:: next
1284+
1285+
.. impl-detail::
1286+
1287+
This function should be used for specialized purposes only.
1288+
It is not guaranteed to exist in all implementations of Python.
1289+
12671290
.. function:: _is_interned(string)
12681291

12691292
Return :const:`True` if the given string is "interned", :const:`False`

Doc/license.rst

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -374,7 +374,7 @@ Project, https://www.wide.ad.jp/. ::
374374
may be used to endorse or promote products derived from this software
375375
without specific prior written permission.
376376

377-
THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
377+
THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS "AS IS" AND
378378
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
379379
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
380380
ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
@@ -583,7 +583,7 @@ interface::
583583
notice, this list of conditions and the following disclaimer in the
584584
documentation and/or other materials provided with the distribution.
585585

586-
THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
586+
THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS "AS IS" AND
587587
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
588588
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
589589
ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
@@ -884,7 +884,7 @@ sources unless the build is configured ``--with-system-libffi``::
884884

885885
Permission is hereby granted, free of charge, to any person obtaining
886886
a copy of this software and associated documentation files (the
887-
``Software''), to deal in the Software without restriction, including
887+
"Software"), to deal in the Software without restriction, including
888888
without limitation the rights to use, copy, modify, merge, publish,
889889
distribute, sublicense, and/or sell copies of the Software, and to
890890
permit persons to whom the Software is furnished to do so, subject to
@@ -893,7 +893,7 @@ sources unless the build is configured ``--with-system-libffi``::
893893
The above copyright notice and this permission notice shall be included
894894
in all copies or substantial portions of the Software.
895895

896-
THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND,
896+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
897897
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
898898
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
899899
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
@@ -1122,7 +1122,7 @@ The file is distributed under the 2-Clause BSD License::
11221122
notice, this list of conditions and the following disclaimer in the
11231123
documentation and/or other materials provided with the distribution.
11241124

1125-
THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
1125+
THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR
11261126
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
11271127
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
11281128
IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,

0 commit comments

Comments
 (0)