Skip to content

Commit 550fd07

Browse files
committed
Merge branch 'main' into tstrings
2 parents 2addef7 + 05d0559 commit 550fd07

File tree

64 files changed

+2239
-800
lines changed

Some content is hidden

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

64 files changed

+2239
-800
lines changed

Doc/c-api/unicode.rst

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -674,6 +674,21 @@ APIs:
674674
.. versionadded:: 3.3
675675
676676
677+
.. c:function:: int PyUnicode_Resize(PyObject **unicode, Py_ssize_t length);
678+
679+
Resize a Unicode object *\*unicode* to the new *length* in code points.
680+
681+
Try to resize the string in place (which is usually faster than allocating
682+
a new string and copying characters), or create a new string.
683+
684+
*\*unicode* is modified to point to the new (resized) object and ``0`` is
685+
returned on success. Otherwise, ``-1`` is returned and an exception is set,
686+
and *\*unicode* is left untouched.
687+
688+
The function doesn't check string content, the result may not be a
689+
string in canonical representation.
690+
691+
677692
.. c:function:: Py_ssize_t PyUnicode_Fill(PyObject *unicode, Py_ssize_t start, \
678693
Py_ssize_t length, Py_UCS4 fill_char)
679694

Doc/data/refcounts.dat

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2794,6 +2794,10 @@ PyUnicode_CopyCharacters:PyObject*:from:0:
27942794
PyUnicode_CopyCharacters:Py_ssize_t:from_start::
27952795
PyUnicode_CopyCharacters:Py_ssize_t:how_many::
27962796

2797+
PyUnicode_Resize:int:::
2798+
PyUnicode_Resize:PyObject**:unicode:0:
2799+
PyUnicode_Resize:Py_ssize_t:length::
2800+
27972801
PyUnicode_Fill:Py_ssize_t:::
27982802
PyUnicode_Fill:PyObject*:unicode:0:
27992803
PyUnicode_Fill:Py_ssize_t:start::

Doc/howto/index.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ Python Library Reference.
3434
mro.rst
3535
free-threading-python.rst
3636
free-threading-extensions.rst
37+
remote_debugging.rst
3738

3839
General:
3940

@@ -66,3 +67,4 @@ Debugging and profiling:
6667
* :ref:`gdb`
6768
* :ref:`instrumentation`
6869
* :ref:`perf_profiling`
70+
* :ref:`remote-debugging`

Doc/howto/remote_debugging.rst

Lines changed: 545 additions & 0 deletions
Large diffs are not rendered by default.

Doc/library/faulthandler.rst

Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,10 +66,41 @@ Dumping the traceback
6666
Added support for passing file descriptor to this function.
6767

6868

69+
Dumping the C stack
70+
-------------------
71+
72+
.. versionadded:: next
73+
74+
.. function:: dump_c_stack(file=sys.stderr)
75+
76+
Dump the C stack trace of the current thread into *file*.
77+
78+
If the Python build does not support it or the operating system
79+
does not provide a stack trace, then this prints an error in place
80+
of a dumped C stack.
81+
82+
.. _c-stack-compatibility:
83+
84+
C Stack Compatibility
85+
*********************
86+
87+
If the system does not support the C-level :manpage:`backtrace(3)`,
88+
:manpage:`backtrace_symbols(3)`, or :manpage:`dladdr(3)`, then C stack dumps
89+
will not work. An error will be printed instead of the stack.
90+
91+
Additionally, some compilers do not support :term:`CPython's <CPython>`
92+
implementation of C stack dumps. As a result, a different error may be printed
93+
instead of the stack, even if the the operating system supports dumping stacks.
94+
95+
.. note::
96+
97+
Dumping C stacks can be arbitrarily slow, depending on the DWARF level
98+
of the binaries in the call stack.
99+
69100
Fault handler state
70101
-------------------
71102

72-
.. function:: enable(file=sys.stderr, all_threads=True)
103+
.. function:: enable(file=sys.stderr, all_threads=True, c_stack=True)
73104

74105
Enable the fault handler: install handlers for the :const:`~signal.SIGSEGV`,
75106
:const:`~signal.SIGFPE`, :const:`~signal.SIGABRT`, :const:`~signal.SIGBUS`
@@ -81,6 +112,10 @@ Fault handler state
81112
The *file* must be kept open until the fault handler is disabled: see
82113
:ref:`issue with file descriptors <faulthandler-fd>`.
83114

115+
If *c_stack* is ``True``, then the C stack trace is printed after the Python
116+
traceback, unless the system does not support it. See :func:`dump_c_stack` for
117+
more information on compatibility.
118+
84119
.. versionchanged:: 3.5
85120
Added support for passing file descriptor to this function.
86121

@@ -95,6 +130,9 @@ Fault handler state
95130
Only the current thread is dumped if the :term:`GIL` is disabled to
96131
prevent the risk of data races.
97132

133+
.. versionchanged:: next
134+
The dump now displays the C stack trace if *c_stack* is true.
135+
98136
.. function:: disable()
99137

100138
Disable the fault handler: uninstall the signal handlers installed by

Doc/library/hashlib.rst

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,10 @@ a file or file-like object.
270270
*fileobj* must be a file-like object opened for reading in binary mode.
271271
It accepts file objects from builtin :func:`open`, :class:`~io.BytesIO`
272272
instances, SocketIO objects from :meth:`socket.socket.makefile`, and
273-
similar. The function may bypass Python's I/O and use the file descriptor
273+
similar. *fileobj* must be opened in blocking mode, otherwise a
274+
:exc:`BlockingIOError` may be raised.
275+
276+
The function may bypass Python's I/O and use the file descriptor
274277
from :meth:`~io.IOBase.fileno` directly. *fileobj* must be assumed to be
275278
in an unknown state after this function returns or raises. It is up to
276279
the caller to close *fileobj*.
@@ -299,6 +302,10 @@ a file or file-like object.
299302

300303
.. versionadded:: 3.11
301304

305+
.. versionchanged:: next
306+
Now raises a :exc:`BlockingIOError` if the file is opened in blocking
307+
mode. Previously, spurious null bytes were added to the digest.
308+
302309

303310
Key derivation
304311
--------------

Doc/whatsnew/3.14.rst

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -769,6 +769,15 @@ errno
769769
(Contributed by James Roy in :gh:`126585`.)
770770

771771

772+
faulthandler
773+
------------
774+
775+
* Add support for printing the C stack trace on systems that
776+
:ref:`support it <c-stack-compatibility>` via :func:`faulthandler.dump_c_stack`
777+
or via the *c_stack* argument in :func:`faulthandler.enable`.
778+
(Contributed by Peter Bierma in :gh:`127604`.)
779+
780+
772781
fnmatch
773782
-------
774783

@@ -921,6 +930,13 @@ logging.handlers
921930
(Contributed by Charles Machalow in :gh:`132106`.)
922931

923932

933+
math
934+
----
935+
936+
* Added more detailed error messages for domain errors in the module.
937+
(Contributed by by Charlie Zhao and Sergey B Kirpichev in :gh:`101410`.)
938+
939+
924940
mimetypes
925941
---------
926942

Grammar/python.gram

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -94,12 +94,18 @@ func_type[mod_ty]: '(' a=[type_expressions] ')' '->' b=expression NEWLINE* ENDMA
9494
# GENERAL STATEMENTS
9595
# ==================
9696

97-
statements[asdl_stmt_seq*]: a=statement+ { (asdl_stmt_seq*)_PyPegen_seq_flatten(p, a) }
97+
statements[asdl_stmt_seq*]: a=statement+ { _PyPegen_register_stmts(p, (asdl_stmt_seq*)_PyPegen_seq_flatten(p, a)) }
9898

99-
statement[asdl_stmt_seq*]: a=compound_stmt { (asdl_stmt_seq*)_PyPegen_singleton_seq(p, a) } | a[asdl_stmt_seq*]=simple_stmts { a }
99+
statement[asdl_stmt_seq*]:
100+
| a=compound_stmt { (asdl_stmt_seq*)_PyPegen_singleton_seq(p, a) }
101+
| a[asdl_stmt_seq*]=simple_stmts { a }
102+
103+
single_compound_stmt[asdl_stmt_seq*]:
104+
| a=compound_stmt {
105+
_PyPegen_register_stmts(p, (asdl_stmt_seq*)_PyPegen_singleton_seq(p, a)) }
100106

101107
statement_newline[asdl_stmt_seq*]:
102-
| a=compound_stmt NEWLINE { (asdl_stmt_seq*)_PyPegen_singleton_seq(p, a) }
108+
| a=single_compound_stmt NEWLINE { a }
103109
| simple_stmts
104110
| NEWLINE { (asdl_stmt_seq*)_PyPegen_singleton_seq(p, CHECK(stmt_ty, _PyAST_Pass(EXTRA))) }
105111
| ENDMARKER { _PyPegen_interactive_exit(p) }

Include/cpython/pyerrors.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ typedef struct {
3030
PyObject *end_offset;
3131
PyObject *text;
3232
PyObject *print_file_and_line;
33+
PyObject *metadata;
3334
} PySyntaxErrorObject;
3435

3536
typedef struct {

Include/internal/pycore_faulthandler.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ struct _faulthandler_runtime_state {
5656
#ifdef MS_WINDOWS
5757
void *exc_handler;
5858
#endif
59+
int c_stack;
5960
} fatal_error;
6061

6162
struct {

0 commit comments

Comments
 (0)