Skip to content

Commit b7cb2b3

Browse files
committed
Merge in the main branch
2 parents 1db3418 + 4ed4014 commit b7cb2b3

41 files changed

Lines changed: 939 additions & 376 deletions

Some content is hidden

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

Doc/c-api/exceptions.rst

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1348,3 +1348,67 @@ Tracebacks
13481348
13491349
This function returns ``0`` on success, and returns ``-1`` with an
13501350
exception set on failure.
1351+
1352+
.. c:function:: const char* PyUnstable_DumpTraceback(int fd, PyThreadState *tstate)
1353+
1354+
Write a trace of the Python stack in *tstate* into the file *fd*. The format
1355+
looks like::
1356+
1357+
Traceback (most recent call first):
1358+
File "xxx", line xxx in <xxx>
1359+
File "xxx", line xxx in <xxx>
1360+
...
1361+
File "xxx", line xxx in <xxx>
1362+
1363+
This function is meant to debug situations such as segfaults, fatal errors,
1364+
and similar. The file and function names it outputs are encoded to ASCII with
1365+
backslashreplace and truncated to 500 characters. It writes only the first
1366+
100 frames; further frames are truncated with the line ``...``.
1367+
1368+
This function will return ``NULL`` on success, or an error message on error.
1369+
1370+
This function is intended for use in crash scenarios such as signal handlers
1371+
for SIGSEGV, where the interpreter may be in an inconsistent state. Given
1372+
that it reads interpreter data structures that may be partially modified, the
1373+
function might produce incomplete output or it may even crash itself.
1374+
1375+
The caller does not need to hold an :term:`attached thread state`, nor does
1376+
*tstate* need to be attached.
1377+
1378+
.. versionadded:: next
1379+
1380+
.. c:function:: const char* PyUnstable_DumpTracebackThreads(int fd, PyInterpreterState *interp, PyThreadState *current_tstate, Py_ssize_t max_threads)
1381+
1382+
Write the traces of all Python threads in *interp* into the file *fd*.
1383+
1384+
If *interp* is ``NULL`` then this function will try to identify the current
1385+
interpreter using thread-specific storage. If it cannot, it will return an
1386+
error.
1387+
1388+
If *current_tstate* is not ``NULL`` then it will be used to identify what the
1389+
current thread is in the written output. If it is ``NULL`` then this function
1390+
will identify the current thread using thread-specific storage. It is not an
1391+
error if the function is unable to get the current Python thread state.
1392+
1393+
This function will return ``NULL`` on success, or an error message on error.
1394+
1395+
This function is meant to debug debug situations such as segfaults, fatal
1396+
errors, and similar. It calls :c:func:`PyUnstable_DumpTraceback` for each
1397+
thread. It only writes the tracebacks of the first *max_threads* threads,
1398+
further output is truncated with the line ``...``. If *max_threads* is 0, the
1399+
function will use a default value of 100 for the argument.
1400+
1401+
This function is intended for use in crash scenarios such as signal handlers
1402+
for SIGSEGV, where the interpreter may be in an inconsistent state. Given
1403+
that it reads interpreter data structures that may be partially modified, the
1404+
function might produce incomplete output or it may even crash itself.
1405+
1406+
The caller does not need to hold an :term:`attached thread state`, nor does
1407+
*current_tstate* need to be attached.
1408+
1409+
.. warning::
1410+
On the :term:`free-threaded build`, this function is not thread-safe. If
1411+
another thread deletes its :term:`thread state` while this function is being
1412+
called, the process will likely crash.
1413+
1414+
.. versionadded:: next

Doc/deprecations/pending-removal-in-3.17.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,11 @@ Pending removal in Python 3.17
3737
is deprecated and scheduled for removal in Python 3.17.
3838
(Contributed by Stan Ulbrych in :gh:`136702`.)
3939

40+
* :mod:`webbrowser`:
41+
42+
- :class:`!webbrowser.MacOSXOSAScript` is deprecated in favour of
43+
:class:`!webbrowser.MacOS`. (:gh:`137586`)
44+
4045
* :mod:`typing`:
4146

4247
- Before Python 3.14, old-style unions were implemented using the private class

Doc/deprecations/pending-removal-in-3.19.rst

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,3 +31,12 @@ Pending removal in Python 3.19
3131
* :meth:`http.cookies.BaseCookie.js_output` is deprecated and will be
3232
removed in Python 3.19.
3333

34+
* :mod:`imaplib`:
35+
36+
* Altering :attr:`IMAP4.file <imaplib.IMAP4.file>` is now deprecated
37+
and slated for removal in Python 3.19. This property is now unused
38+
and changing its value does not automatically close the current file.
39+
40+
Before Python 3.14, this property was used to implement the corresponding
41+
``read()`` and ``readline()`` methods for :class:`~imaplib.IMAP4` but this
42+
is no longer the case since then.

Doc/library/functions.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1107,13 +1107,13 @@ are always available. They are listed here in alphabetical order.
11071107
*classinfo* can be a :ref:`types-union`.
11081108

11091109

1110-
.. function:: issubclass(class, classinfo, /)
1110+
.. function:: issubclass(cls, classinfo, /)
11111111

1112-
Return ``True`` if *class* is a subclass (direct, indirect, or :term:`virtual
1112+
Return ``True`` if *cls* is a subclass (direct, indirect, or :term:`virtual
11131113
<abstract base class>`) of *classinfo*. A
11141114
class is considered a subclass of itself. *classinfo* may be a tuple of class
11151115
objects (or recursively, other such tuples)
1116-
or a :ref:`types-union`, in which case return ``True`` if *class* is a
1116+
or a :ref:`types-union`, in which case return ``True`` if *cls* is a
11171117
subclass of any entry in *classinfo*. In any other case, a :exc:`TypeError`
11181118
exception is raised.
11191119

Doc/library/imaplib.rst

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -695,6 +695,16 @@ The following attributes are defined on instances of :class:`IMAP4`:
695695
.. versionadded:: 3.5
696696

697697

698+
.. property:: IMAP4.file
699+
700+
Internal :class:`~io.BufferedReader` associated with the underlying socket.
701+
This property is documented for legacy purposes but not part of the public
702+
interface. The caller is responsible to ensure that the current file is
703+
closed before changing it.
704+
705+
.. deprecated-removed:: next 3.19
706+
707+
698708
.. _imap4-example:
699709

700710
IMAP4 Example

Doc/library/webbrowser.rst

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -172,13 +172,15 @@ for the controller classes, all defined in this module.
172172
+------------------------+-----------------------------------------+-------+
173173
| ``'windows-default'`` | ``WindowsDefault`` | \(2) |
174174
+------------------------+-----------------------------------------+-------+
175-
| ``'macosx'`` | ``MacOSXOSAScript('default')`` | \(3) |
175+
| ``'macos'`` | ``MacOS('default')`` | \(3) |
176176
+------------------------+-----------------------------------------+-------+
177-
| ``'safari'`` | ``MacOSXOSAScript('safari')`` | \(3) |
177+
| ``'safari'`` | ``MacOS('safari')`` | \(3) |
178178
+------------------------+-----------------------------------------+-------+
179-
| ``'google-chrome'`` | ``Chrome('google-chrome')`` | |
179+
| ``'chrome'`` | ``MacOS('google chrome')`` | \(3) |
180+
+------------------------+-----------------------------------------+-------+
181+
| ``'firefox'`` | ``MacOS('firefox')`` | \(3) |
180182
+------------------------+-----------------------------------------+-------+
181-
| ``'chrome'`` | ``Chrome('chrome')`` | |
183+
| ``'google-chrome'`` | ``Chrome('google-chrome')`` | |
182184
+------------------------+-----------------------------------------+-------+
183185
| ``'chromium'`` | ``Chromium('chromium')`` | |
184186
+------------------------+-----------------------------------------+-------+
@@ -221,6 +223,17 @@ Notes:
221223
.. versionchanged:: 3.13
222224
Support for iOS has been added.
223225

226+
.. versionadded:: next
227+
:class:`!MacOS` has been added as a replacement for :class:`!MacOSXOSAScript`,
228+
opening browsers via :program:`/usr/bin/open` instead of :program:`osascript`.
229+
230+
.. deprecated-removed:: next 3.17
231+
:class:`!MacOSXOSAScript` is deprecated in favour of :class:`!MacOS`.
232+
Using :program:`/usr/bin/open` instead of :program:`osascript` is a
233+
security and usability improvement: :program:`osascript` may be blocked
234+
on managed systems due to its abuse potential as a general-purpose
235+
scripting interpreter.
236+
224237
Here are some simple examples::
225238

226239
url = 'https://docs.python.org/'

Doc/library/xml.rst

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,19 @@ This module also defines utility functions.
5454
"!", "?", and "=" are forbidden.
5555
The name cannot start with a digit or a character like "-", ".", and "·".
5656

57-
..versionadded:: next
57+
.. versionadded:: next
58+
59+
60+
.. function:: is_valid_text(data)
61+
62+
Return ``True`` if the string is a sequence of legal XML 1.0 characters,
63+
``False`` otherwise.
64+
65+
Almost all characters are permitted in XML 1.0 documents, except C0 control
66+
characters (excluding TAB, CR and LF), surrogate characters and special
67+
Unicode characters U+FFFE and U+FFFF.
68+
69+
.. versionadded:: next
5870

5971

6072
.. _xml-security:

Doc/using/configure.rst

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -788,15 +788,14 @@ also be used to improve performance.
788788
pointers to ``BASECFLAGS``:
789789

790790
- ``-fno-omit-frame-pointer`` and/or ``-mno-omit-leaf-frame-pointer``
791-
are added when the compiler supports them,
791+
are added when the compiler supports them.
792792
- ``-marm`` and/or ``-mno-thumb`` is added on 32-bit ARM when supported,
793-
- on s390x platforms, when supported, ``-mbackchain`` is added *instead*
794-
of the above frame pointer flags
793+
- on s390x platforms, when supported, ``-mbackchain`` is added *instead*.
794+
of the above frame pointer flags.
795795

796796
Frame pointers enable profilers, debuggers, and system tracing tools
797797
(``perf``, ``eBPF``, ``dtrace``, ``gdb``) to walk the C call stack
798-
without DWARF metadata.
799-
The flags propagate to third-party C
798+
without DWARF metadata. The flags propagate to third-party C
800799
extensions through :mod:`sysconfig`. On compilers that do not
801800
understand them, the build silently skips them.
802801

Doc/whatsnew/3.15.rst

Lines changed: 67 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ Summary -- Release highlights
8181
<whatsnew315-unpacking-in-comprehensions>`
8282
* :pep:`686`: :ref:`Python now uses UTF-8 as the default encoding
8383
<whatsnew315-utf8-default>`
84+
* :pep:`829`: :ref:`Package startup configuration files <whatsnew315-startup-files>`
8485
* :pep:`728`: :ref:`TypedDict with typed extra items <whatsnew315-typeddict>`
8586
* :pep:`747`: :ref:`Annotating type forms with TypeForm
8687
<whatsnew315-typeform>`
@@ -94,7 +95,6 @@ Summary -- Release highlights
9495
* :ref:`Improved error messages <whatsnew315-improved-error-messages>`
9596
* :ref:`The official Windows 64-bit binaries now use the tail-calling interpreter
9697
<whatsnew315-windows-tail-calling-interpreter>`
97-
* :pep:`829`: Package Startup Configuration Files
9898

9999
New features
100100
============
@@ -452,6 +452,31 @@ agen() for x in a)``.
452452

453453
(Contributed by Adam Hartz in :gh:`143055`.)
454454

455+
.. _whatsnew315-startup-files:
456+
457+
:pep:`829`: Package startup configuration files
458+
-----------------------------------------------
459+
460+
Loaded by the :mod:`site` module when ``-S`` is not given, :ref:`.pth files <site-pth-files>`
461+
can contain lines that both extend :data:`sys.path` and execute arbitrary code
462+
when the line starts with ``import`` (followed by a space or tab). The latter
463+
functionality can be problematic, since it is difficult to know exactly what
464+
gets executed when Python starts up.
465+
466+
As a step towards improving the ability to audit pre-start executable code,
467+
Python 3.15 introduces :ref:`.start files <site-start-files>` which contain entry point
468+
specifications of the form ``pkg.mod:callable`` where ``pkg.mod`` is the
469+
import path to the given callable. When Python starts up, the callable is
470+
located and called with no arguments.
471+
472+
``import`` lines in :file:`.pth` files are silently deprecated. When a
473+
matching :file:`.start` file is found, ``import`` lines in :file:`.pth` files
474+
are ignored. There is no change to :data:`sys.path` extension lines in
475+
:file:`.pth` files.
476+
477+
(Contributed by Barry Warsaw in :gh:`148641`.)
478+
479+
455480
.. _whatsnew315-abi3t:
456481

457482
:pep:`803` -- Stable ABI for Free-Threaded Builds
@@ -627,6 +652,11 @@ Other language changes
627652

628653
(Contributed by Adam Turner in :gh:`133711`; PEP 686 written by Inada Naoki.)
629654

655+
* The interpreter help (such as ``python --help``) is now in color.
656+
This can be controlled by :ref:`environment variables
657+
<using-on-controlling-color>`.
658+
(Contributed by Hugo van Kemenade in :gh:`148766`.)
659+
630660
* Unraisable exceptions are now highlighted with color by default. This can be
631661
controlled by :ref:`environment variables <using-on-controlling-color>`.
632662
(Contributed by Peter Bierma in :gh:`134170`.)
@@ -1663,13 +1693,31 @@ wave
16631693
(Contributed by Lionel Koenig and Michiel W. Beijen in :gh:`60729`.)
16641694

16651695

1696+
webbrowser
1697+
----------
1698+
1699+
* On macOS, the new :class:`!webbrowser.MacOS` class opens URLs via
1700+
:program:`/usr/bin/open` instead of constructing and executing AppleScript
1701+
via :program:`osascript`. The default browser is detected from the
1702+
LaunchServices preferences file using :mod:`plistlib`, with
1703+
:class:`!com.apple.Safari` as the fallback on fresh installations.
1704+
For non-HTTP(S) URLs, :program:`open -b <bundle-id>` is used to route the
1705+
URL through a browser rather than the OS file handler, preventing
1706+
file injection attacks.
1707+
(Contributed by Jeff Lyon in :gh:`137586`.)
1708+
1709+
16661710
xml
16671711
---
16681712

16691713
* Add the :func:`xml.is_valid_name` function, which allows to check
16701714
whether a string can be used as an element or attribute name in XML.
16711715
(Contributed by Serhiy Storchaka in :gh:`139489`.)
16721716

1717+
* Add the :func:`xml.is_valid_text` function, which allows to check
1718+
whether a string can be used in the XML document.
1719+
(Contributed by Serhiy Storchaka in :gh:`139489`.)
1720+
16731721

16741722
xml.parsers.expat
16751723
-----------------
@@ -2059,6 +2107,13 @@ New deprecations
20592107
(Contributed by kishorhange111 in :gh:`148849`.)
20602108

20612109

2110+
* :mod:`imaplib`:
2111+
2112+
* Altering :attr:`IMAP4.file <imaplib.IMAP4.file>` is now deprecated
2113+
and slated for removal in Python 3.19. This property is now unused
2114+
and changing its value does *not* explicitly close the current file.
2115+
2116+
20622117
* :mod:`re`:
20632118

20642119
* :func:`re.match` and :meth:`re.Pattern.match` are now
@@ -2102,6 +2157,12 @@ New deprecations
21022157
merely imported or accessed from the :mod:`!typing` module.
21032158

21042159

2160+
* :mod:`webbrowser`:
2161+
2162+
* :class:`!webbrowser.MacOSXOSAScript` is deprecated in favour of
2163+
:class:`!webbrowser.MacOS` and scheduled for removal in Python 3.17.
2164+
(Contributed by Jeff Lyon in :gh:`137586`.)
2165+
21052166
* ``__version__``
21062167

21072168
* The ``__version__``, ``version`` and ``VERSION`` attributes have been
@@ -2291,6 +2352,11 @@ New features
22912352
Python 3.14.
22922353
(Contributed by Victor Stinner in :gh:`142417`.)
22932354

2355+
* Add :c:func:`PyUnstable_DumpTraceback` and
2356+
:c:func:`PyUnstable_DumpTracebackThreads` functions to output Python
2357+
stacktraces.
2358+
(Contributed by Alex Malyshev in :gh:`145559`.)
2359+
22942360
Changed C APIs
22952361
--------------
22962362

Include/cpython/traceback.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,11 @@ struct _traceback {
1111
int tb_lasti;
1212
int tb_lineno;
1313
};
14+
15+
PyAPI_FUNC(const char*) PyUnstable_DumpTraceback(int fd, PyThreadState *tstate);
16+
17+
PyAPI_FUNC(const char*) PyUnstable_DumpTracebackThreads(
18+
int fd,
19+
PyInterpreterState *interp,
20+
PyThreadState *current_tstate,
21+
Py_ssize_t max_threads);

0 commit comments

Comments
 (0)