Skip to content

Commit f0d5301

Browse files
Merge remote-tracking branch 'upstream/main' into tkinter-gc-protocol
2 parents 1721941 + 7ccdbab commit f0d5301

29 files changed

Lines changed: 1936 additions & 1194 deletions

Doc/howto/mro.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ The Python 2.3 Method Resolution Order
1010
The Method Resolution Order discussed here was *introduced* in Python 2.3,
1111
but it is still used in later versions -- including Python 3.
1212

13-
By `Michele Simionato <https://www.phyast.pitt.edu/~micheles/>`__.
13+
By `Michele Simionato <https://github.com/micheles>`__.
1414

1515
:Abstract:
1616

Doc/library/curses.rst

Lines changed: 1062 additions & 1126 deletions
Large diffs are not rendered by default.

Doc/library/numbers.rst

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -90,20 +90,7 @@ Notes for type implementers
9090

9191
Implementers should be careful to make equal numbers equal and hash
9292
them to the same values. This may be subtle if there are two different
93-
extensions of the real numbers. For example, :class:`fractions.Fraction`
94-
implements :func:`hash` as follows::
95-
96-
def __hash__(self):
97-
if self.denominator == 1:
98-
# Get integers right.
99-
return hash(self.numerator)
100-
# Expensive check, but definitely correct.
101-
if self == float(self):
102-
return hash(float(self))
103-
else:
104-
# Use tuple's hash to avoid a high collision rate on
105-
# simple fractions.
106-
return hash((self.numerator, self.denominator))
93+
extensions of the real numbers. See also :ref:`numeric-hash`.
10794

10895

10996
Adding More Numeric ABCs

Doc/library/tkinter.rst

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1056,11 +1056,11 @@ Base and mixin classes
10561056
:class:`int`.
10571057
Raise :exc:`ValueError` if *s* is not a valid integer.
10581058

1059-
.. method:: getvar(name='PY_VAR')
1059+
.. method:: getvar(name)
10601060

10611061
Return the value of the Tcl global variable named *name*.
10621062

1063-
.. method:: setvar(name='PY_VAR', value='1')
1063+
.. method:: setvar(name, value)
10641064

10651065
Set the Tcl global variable named *name* to *value*.
10661066

@@ -1524,10 +1524,10 @@ Base and mixin classes
15241524
This updates the display of windows, for example after geometry changes,
15251525
but does not process events caused by the user.
15261526

1527-
.. method:: waitvar(name='PY_VAR')
1527+
.. method:: waitvar(name)
15281528
:no-typesetting:
15291529

1530-
.. method:: wait_variable(name='PY_VAR')
1530+
.. method:: wait_variable(name)
15311531

15321532
Wait until the Tcl variable *name* is modified, continuing to process
15331533
events in the meantime so that the application stays responsive.
@@ -3394,6 +3394,14 @@ Toplevel widgets
33943394
profile files is the :envvar:`HOME` environment variable or, if that
33953395
isn't defined, then :data:`os.curdir`.
33963396

3397+
.. note::
3398+
3399+
On Windows, creating a Tcl interpreter (by instantiating :class:`Tk` or
3400+
calling :func:`Tcl`) sets the :envvar:`HOME` environment variable for
3401+
the process, if it is not already set, to ``%HOMEDRIVE%%HOMEPATH%`` (or
3402+
:envvar:`USERPROFILE`, or ``c:\``). This is done by Tcl and can affect
3403+
other code that reads :envvar:`HOME`.
3404+
33973405
.. attribute:: tk
33983406

33993407
The Tk application object created by instantiating :class:`Tk`. This

Doc/whatsnew/3.16.rst

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -559,6 +559,14 @@ Porting to Python 3.16
559559
This section lists previously described changes and other bugfixes
560560
that may require changes to your code.
561561

562+
* In :mod:`tkinter`, the *name* parameter of the
563+
:meth:`~tkinter.Misc.wait_variable`, :meth:`~tkinter.Misc.setvar` and
564+
:meth:`~tkinter.Misc.getvar` methods and the *value* parameter of
565+
:meth:`!setvar` are now required. Calling these methods without
566+
them, which formerly defaulted to ``'PY_VAR'`` and ``'1'``, now raises
567+
:exc:`TypeError`.
568+
(Contributed by Serhiy Storchaka in :gh:`152587`.)
569+
562570

563571
Build changes
564572
=============

Include/cpython/code.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,13 @@ typedef struct {
3434
char *entries[1];
3535
} _PyCodeArray;
3636

37+
#define _PyCode_DEF_UNIQUE_ID() \
38+
Py_ssize_t _co_unique_id; /* ID used for per-thread refcounting */
39+
3740
#define _PyCode_DEF_THREAD_LOCAL_BYTECODE() \
3841
_PyCodeArray *co_tlbc;
3942
#else
43+
#define _PyCode_DEF_UNIQUE_ID()
4044
#define _PyCode_DEF_THREAD_LOCAL_BYTECODE()
4145
#endif
4246

@@ -101,7 +105,7 @@ typedef struct {
101105
_PyCoCached *_co_cached; /* cached co_* attributes */ \
102106
uintptr_t _co_instrumentation_version; /* current instrumentation version */ \
103107
struct _PyCoMonitoringData *_co_monitoring; /* Monitoring data */ \
104-
Py_ssize_t _co_unique_id; /* ID used for per-thread refcounting */ \
108+
_PyCode_DEF_UNIQUE_ID() \
105109
int _co_firsttraceable; /* index of first traceable instruction */ \
106110
/* Scratch space for extra data relating to the code object. \
107111
Type is a void* to keep the format private in codeobject.c to force \

Lib/ntpath.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -345,7 +345,7 @@ def _isreservedname(name):
345345
def expanduser(path):
346346
"""Expand ~ and ~user constructs.
347347
348-
If user or $HOME is unknown, do nothing."""
348+
If user or home directory is unknown, do nothing."""
349349
path = os.fspath(path)
350350
if isinstance(path, bytes):
351351
seps = b'\\/'

Lib/tarfile.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2534,7 +2534,8 @@ def extract(self, member, path="", set_attrs=True, *, numeric_owner=False,
25342534
tarinfo, unfiltered = self._get_extract_tarinfo(
25352535
member, filter_function, path)
25362536
if tarinfo is not None:
2537-
self._extract_one(tarinfo, path, set_attrs, numeric_owner)
2537+
self._extract_one(tarinfo, path, set_attrs, numeric_owner,
2538+
filter_function=filter_function)
25382539

25392540
def _get_extract_tarinfo(self, member, filter_function, path):
25402541
"""Get (filtered, unfiltered) TarInfos from *member*

Lib/test/test_curses.py

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1563,7 +1563,8 @@ def test_env_queries(self):
15631563
self.assertIsInstance(curses.has_ic(), bool)
15641564
self.assertIsInstance(curses.has_il(), bool)
15651565
self.assertIsInstance(curses.termattrs(), int)
1566-
self.assertIsInstance(curses.term_attrs(), int)
1566+
if hasattr(curses, 'term_attrs'):
1567+
self.assertIsInstance(curses.term_attrs(), int)
15671568

15681569
c = curses.killchar()
15691570
self.assertIsInstance(c, bytes)
@@ -2365,15 +2366,19 @@ def test_textbox_combining(self):
23652366
self.assertEqual(box.gather(), text + ' ')
23662367

23672368
def test_textbox_edit_wide(self):
2368-
# edit() reads characters through get_wch(). Each is used only if
2369-
# encodable in the current locale.
2369+
# edit() reads characters through get_wch(). Each character is pushed
2370+
# with unget_wch(), which on a narrow build requires it to encode to a
2371+
# single byte, so a non-ASCII case needs a wide build or an 8-bit locale.
23702372
for ch in ['A', 'é', '¤', '€', 'д']:
2371-
if self._encodable(ch):
2372-
with self.subTest(ch=ch):
2373-
box, win = self._make_textbox(1, 10)
2374-
for c in reversed(['a', ch, chr(curses.ascii.BEL)]):
2375-
curses.unget_wch(c)
2376-
self.assertEqual(box.edit(), 'a' + ch + ' ')
2373+
if not self._encodable(ch):
2374+
continue
2375+
if not WIDE_BUILD and len(ch.encode(self.stdscr.encoding)) != 1:
2376+
continue
2377+
with self.subTest(ch=ch):
2378+
box, win = self._make_textbox(1, 10)
2379+
for c in reversed(['a', ch, chr(curses.ascii.BEL)]):
2380+
curses.unget_wch(c)
2381+
self.assertEqual(box.edit(), 'a' + ch + ' ')
23772382

23782383
def test_textbox_movement(self):
23792384
box, win = self._make_textbox(3, 10)

Lib/test/test_embed.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1458,7 +1458,7 @@ def module_search_paths(self, prefix=None, exec_prefix=None):
14581458
if prefix is None:
14591459
prefix = config['config']['prefix']
14601460
if exec_prefix is None:
1461-
exec_prefix = config['config']['prefix']
1461+
exec_prefix = config['config']['exec_prefix']
14621462
if MS_WINDOWS:
14631463
return config['config']['module_search_paths']
14641464
else:
@@ -1614,8 +1614,10 @@ def test_init_is_python_build_with_home(self):
16141614
expected_paths[1 if MS_WINDOWS else 2] = os.path.normpath(
16151615
os.path.join(exedir, f'{f.read()}\n$'.splitlines()[0]))
16161616
if not MS_WINDOWS:
1617-
# PREFIX (default) is set when running in build directory
1618-
prefix = exec_prefix = sys.prefix
1617+
# PREFIX and EXEC_PREFIX (defaults) are set when running in the
1618+
# build directory and may differ with --exec-prefix (gh-151096).
1619+
prefix = sys.prefix
1620+
exec_prefix = sys.exec_prefix
16191621
# stdlib calculation (/Lib) is not yet supported
16201622
expected_paths[0] = self.module_search_paths(prefix=prefix)[0]
16211623
config.update(prefix=prefix, base_prefix=prefix,

0 commit comments

Comments
 (0)