Skip to content

Commit 8a989dd

Browse files
committed
Merge main
2 parents 99298c7 + 2670cb0 commit 8a989dd

92 files changed

Lines changed: 3336 additions & 977 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.

Doc/c-api/type.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -639,7 +639,7 @@ but need extra remarks for use as slots:
639639
in the following situations:
640640
641641
- The base is not variable-sized (its
642-
:c:member:`~PyTypeObject.tp_itemsize`).
642+
:c:member:`~PyTypeObject.tp_itemsize` is zero).
643643
- The requested :c:member:`PyType_Spec.basicsize` is positive,
644644
suggesting that the memory layout of the base class is known.
645645
- The requested :c:member:`PyType_Spec.basicsize` is zero,

Doc/howto/curses.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,8 @@ code, all the functions described here will probably be available. The older
5252
versions of curses carried by some proprietary Unixes may not support
5353
everything, though.
5454

55-
The Windows version of Python doesn't include the :mod:`curses`
56-
module. A ported version called :pypi:`UniCurses` is available.
55+
The Windows version of Python doesn't include the :mod:`curses` module.
56+
The third-party :pypi:`windows-curses` package provides the same interface on Windows.
5757

5858

5959
The Python curses module

Doc/library/curses.rst

Lines changed: 117 additions & 61 deletions
Large diffs are not rendered by default.

Doc/library/http.client.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -433,6 +433,7 @@ HTTPConnection Objects
433433

434434
The maximum number of allowed response headers to help prevent denial-of-service
435435
attacks. By default, the maximum number of allowed headers is set to 100.
436+
The same limit applies to the trailer section of a chunked response.
436437

437438
.. versionadded:: 3.15
438439

Doc/library/itertools.rst

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,10 @@ loops that truncate the stream.
197197
for iterable in iterables:
198198
yield from iterable
199199

200+
Note that :ref:`unpacking in comprehensions <unpacking-comprehensions>`
201+
provides similar functionality so that ``list(chain(p, q))`` could be
202+
written as ``[*s for s in (p, q)]``.
203+
200204

201205
.. classmethod:: chain.from_iterable(iterable)
202206

@@ -208,6 +212,10 @@ loops that truncate the stream.
208212
for iterable in iterables:
209213
yield from iterable
210214

215+
Note that :ref:`unpacking in comprehensions <unpacking-comprehensions>`
216+
provides similar functionality so that ``list(chain.from_iterable(iterables))``
217+
could be written as ``[*s for s in iterables]``.
218+
211219

212220
.. function:: combinations(iterable, r)
213221

Doc/library/tkinter.rst

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -885,6 +885,20 @@ they are denoted in Tk, which can be useful when referring to the Tk man pages.
885885
| %d | detail | %D | delta |
886886
+----+---------------------+----+---------------------+
887887

888+
The ``add`` parameter above only affects the bindings you make yourself.
889+
Every widget also inherits *class bindings*
890+
that implement its standard behavior --
891+
for example a :class:`Text` widget binds :kbd:`Control-t`
892+
to transpose two characters.
893+
These are described in the bindings section of the widget's Tk man page
894+
(such as :manpage:`text(3tk)` or :manpage:`entry(3tk)`).
895+
896+
Class bindings are processed separately from your own,
897+
so binding an event yourself does not replace the default; both run.
898+
To suppress an unwanted default binding,
899+
bind the event on the widget
900+
and return the string ``"break"`` from your callback.
901+
888902

889903
The index parameter
890904
^^^^^^^^^^^^^^^^^^^
@@ -2685,7 +2699,8 @@ Base and mixin classes
26852699
Make *widget* a stand-alone top-level window, decorated by the window
26862700
manager with a title bar and so on.
26872701
Only :class:`Frame`, :class:`LabelFrame` and :class:`Toplevel` widgets
2688-
may be used; passing any other widget type raises an error.
2702+
may be used (the :mod:`tkinter.ttk` versions are **not** accepted);
2703+
passing any other widget type raises an error.
26892704
:meth:`wm_manage` is an alias of :meth:`!manage`.
26902705

26912706
.. versionadded:: 3.3

Doc/reference/expressions.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -848,6 +848,8 @@ appear directly in a class definition.
848848
``yield`` and ``yield from`` prohibited in the implicitly nested scope.
849849

850850

851+
.. _unpacking-comprehensions:
852+
851853
Unpacking in comprehensions
852854
^^^^^^^^^^^^^^^^^^^^^^^^^^^
853855

Doc/whatsnew/3.16.rst

Lines changed: 38 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -111,10 +111,22 @@ curses
111111
and the module functions :func:`curses.erasewchar`, :func:`curses.killwchar`
112112
and :func:`curses.wunctrl`, the wide-character counterparts of
113113
:func:`curses.erasechar`, :func:`curses.killchar` and :func:`curses.unctrl`.
114-
These features are only available when built against the wide-character
115-
ncursesw library.
114+
On a narrow (non-ncursesw) build the character cell holds a single character
115+
without combining marks, representable as one byte in the window's encoding,
116+
and :meth:`~curses.window.in_wstr` returns its decoded text.
116117
(Contributed by Serhiy Storchaka in :gh:`151757`.)
117118

119+
* The wide-character :mod:`curses` functions and methods
120+
:meth:`~curses.window.get_wch`, :meth:`~curses.window.get_wstr`,
121+
:func:`curses.unget_wch`, :func:`curses.erasewchar`,
122+
:func:`curses.killwchar` and :func:`curses.wunctrl` now also work when Python
123+
is not built against a wide-character-aware curses library, on an 8-bit
124+
locale, where each character is a single byte in the relevant encoding.
125+
:func:`curses.ungetch` now also accepts a one-character string, like
126+
:func:`curses.unget_wch`; on a wide-character build it can be any character
127+
(previously a multibyte character raised :exc:`OverflowError`).
128+
(Contributed by Serhiy Storchaka in :gh:`152470`.)
129+
118130
* Add :func:`curses.nofilter`, which undoes the effect of :func:`curses.filter`.
119131
(Contributed by Serhiy Storchaka in :gh:`151744`.)
120132

@@ -139,21 +151,26 @@ curses
139151
(Contributed by Serhiy Storchaka in :gh:`152219`.)
140152

141153
* Add the :class:`curses.complexchar` type, representing a styled
142-
wide-character cell (its text, attributes and color pair), and the window
154+
character cell (its text, attributes and color pair), and the window
143155
methods :meth:`~curses.window.in_wch` and :meth:`~curses.window.getbkgrnd`
144-
that return one --- the wide-character counterparts of
156+
that return one --- the counterparts of
145157
:meth:`~curses.window.inch` and :meth:`~curses.window.getbkgd`. The
146158
character-cell methods, such as :meth:`~curses.window.addch` and
147159
:meth:`~curses.window.border`, now also accept a
148-
:class:`~curses.complexchar`.
160+
:class:`~curses.complexchar`. These work whether or not Python was built
161+
against a wide-character-aware curses library; on a narrow build a cell holds a
162+
single character representable as one byte in the window's encoding (so only
163+
8-bit locales are supported).
149164
(Contributed by Serhiy Storchaka in :gh:`152233`.)
150165

151166
* Add the :class:`curses.complexstr` type, an immutable run of styled cells
152167
(the string counterpart of :class:`~curses.complexchar`), and the window
153168
method :meth:`~curses.window.in_wchstr` that returns one. The string-cell
154169
methods :meth:`~curses.window.addstr`, :meth:`~curses.window.addnstr`,
155170
:meth:`~curses.window.insstr` and :meth:`~curses.window.insnstr` now also
156-
accept a :class:`~curses.complexstr`.
171+
accept a :class:`~curses.complexstr`. Like :class:`~curses.complexchar`, it
172+
works whether or not Python was built against a wide-character-aware curses
173+
library.
157174
(Contributed by Serhiy Storchaka in :gh:`152233`.)
158175

159176
* Add the :mod:`curses` window method :meth:`~curses.window.dupwin`, which
@@ -165,11 +182,26 @@ curses
165182
:func:`~curses.scr_set`, which dump the whole screen to a file and restore it.
166183
(Contributed by Serhiy Storchaka in :gh:`152260`.)
167184

185+
* Add the :func:`curses.term_attrs` function, which returns the supported
186+
video attributes as :ref:`WA_* <curses-wa-constants>` values, the
187+
counterpart of :func:`curses.termattrs`.
188+
(Contributed by Serhiy Storchaka in :gh:`152332`.)
189+
168190
* Add the :mod:`curses` key-management functions :func:`~curses.define_key`,
169191
:func:`~curses.key_defined` and :func:`~curses.keyok`, available when built
170192
against an ncurses with ``NCURSES_EXT_FUNCS``.
171193
(Contributed by Serhiy Storchaka in :gh:`152334`.)
172194

195+
* Add the :func:`curses.has_mouse` function and the
196+
:meth:`curses.window.mouse_trafo` method, completing the :mod:`curses`
197+
mouse interface.
198+
(Contributed by Serhiy Storchaka in :gh:`152325`.)
199+
200+
* :class:`curses.textpad.Textbox` now supports entering and reading back the
201+
full Unicode range, including combining characters, when curses is built with
202+
wide-character support.
203+
(Contributed by Serhiy Storchaka in :gh:`133031`.)
204+
173205
gzip
174206
----
175207

Grammar/python.gram

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -820,6 +820,7 @@ is_bitwise_or[CmpopExprPair*]: 'is' a=bitwise_or { _PyPegen_cmpop_expr_pair(p, I
820820

821821
bitwise_or[expr_ty]:
822822
| a=bitwise_or '|' b=bitwise_xor { _PyAST_BinOp(a, BitOr, b, EXTRA) }
823+
| invalid_bitwise_or
823824
| bitwise_xor
824825

825826
bitwise_xor[expr_ty]:
@@ -828,6 +829,7 @@ bitwise_xor[expr_ty]:
828829

829830
bitwise_and[expr_ty]:
830831
| a=bitwise_and '&' b=shift_expr { _PyAST_BinOp(a, BitAnd, b, EXTRA) }
832+
| invalid_bitwise_and
831833
| shift_expr
832834

833835
shift_expr[expr_ty]:
@@ -1644,3 +1646,17 @@ invalid_type_params:
16441646
RAISE_SYNTAX_ERROR_STARTING_FROM(
16451647
token,
16461648
"Type parameter list cannot be empty")}
1649+
1650+
invalid_bitwise_and:
1651+
| a=bitwise_and b='&' c='&' {
1652+
_PyPegen_tokens_are_adjacent(b, c)
1653+
? RAISE_SYNTAX_ERROR_KNOWN_RANGE(b, c, "invalid syntax. Maybe you meant 'and' or '&' instead of '&&'?")
1654+
: NULL
1655+
}
1656+
1657+
invalid_bitwise_or:
1658+
| a=bitwise_or b='|' c='|' {
1659+
_PyPegen_tokens_are_adjacent(b, c)
1660+
? RAISE_SYNTAX_ERROR_KNOWN_RANGE(b, c, "invalid syntax. Maybe you meant 'or' or '|' instead of '||'?")
1661+
: NULL
1662+
}

Include/cpython/pystate.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,7 @@ struct _ts {
143143
struct _PyInterpreterFrame *base_frame;
144144

145145
struct _PyInterpreterFrame *last_profiled_frame;
146+
uintptr_t last_profiled_frame_seq;
146147

147148
Py_tracefunc c_profilefunc;
148149
Py_tracefunc c_tracefunc;

0 commit comments

Comments
 (0)