Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions Doc/deprecations/pending-removal-in-3.21.rst
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,9 @@ Pending removal in Python 3.21
are not generated by the parser or accepted by the code generator.
* The ``dims`` property of ``ast.Tuple`` will be removed in Python 3.21. Use
the ``ast.Tuple.elts`` property instead.

* :mod:`struct`:

* Soft-deprecated since Python 3.15, using ``'F'`` and ``'D'`` type codes are now
deprecated. These codes will be removed in Python 3.21. Use instead
two-letter forms ``'Zf'`` and ``'Zd'``.
5 changes: 0 additions & 5 deletions Doc/deprecations/soft-deprecations.rst
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,3 @@ There are no plans to remove :term:`soft deprecated` APIs.

(Contributed by Gregory P. Smith in :gh:`86519` and
Hugo van Kemenade in :gh:`148100`.)

* Using ``'F'`` and ``'D'`` format type codes of the :mod:`struct` module
now are :term:`soft deprecated` in favor of two-letter forms ``'Zf'``
and ``'Zd'``.
(Contributed by Sergey B Kirpichev in :gh:`121249`.)
2 changes: 2 additions & 0 deletions Doc/faq/design.rst
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,8 @@ In general, structured switch statements execute one block of code
when an expression has a particular value or set of values.
Since Python 3.10 one can easily match literal values, or constants
within a namespace, with a ``match ... case`` statement.
See :ref:`the specification <match>` and :ref:`the tutorial <tut-match>`
for more information about :keyword:`match` statements.
An older alternative is a sequence of ``if... elif... elif... else``.

For cases where you need to choose from a very large number of possibilities,
Expand Down
2 changes: 2 additions & 0 deletions Doc/library/curses.rst
Original file line number Diff line number Diff line change
Expand Up @@ -465,6 +465,8 @@ Mouse

Return ``True`` if the mouse driver has been successfully initialized.

Availability: ncurses 5.8 or later.

.. versionadded:: next


Expand Down
4 changes: 3 additions & 1 deletion Doc/library/struct.rst
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,9 @@ platform-dependent.

.. versionchanged:: 3.15
Added support for the ``'Zf'`` and ``'Zd'`` formats.
``'F'`` and ``'D'`` formats are :term:`soft deprecated`.

.. versionchanged:: 3.16
``'F'`` and ``'D'`` formats are deprecated.

.. seealso::

Expand Down
7 changes: 7 additions & 0 deletions Doc/whatsnew/3.16.rst
Original file line number Diff line number Diff line change
Expand Up @@ -550,6 +550,13 @@ New deprecations
3.9, now issues a deprecation warning on use. This property is slated for
removal in 3.21. Use ``ast.Tuple.elts`` instead.

* :mod:`struct`:

* Soft-deprecated since Python 3.15, using ``'F'`` and ``'D'`` type codes are now
deprecated. These codes will be removed in Python 3.21. Use instead
two-letter forms ``'Zf'`` and ``'Zd'``.
(Contributed by Sergey B Kirpichev in :gh:`121249`.)

.. Add deprecations above alphabetically, not here at the end.

.. include:: ../deprecations/pending-removal-in-3.17.rst
Expand Down
2 changes: 1 addition & 1 deletion Lib/idlelib/idle_test/template.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def setUpClass(cls):
@classmethod
def tearDownClass(cls):
cls.root.update_idletasks()
## for id in cls.root.tk.call('after', 'info'):
## for id in cls.root.after_info():
## cls.root.after_cancel(id) # Need for EditorWindow.
cls.root.destroy()
del cls.root
Expand Down
4 changes: 2 additions & 2 deletions Lib/idlelib/idle_test/test_codecontext.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ def test_del_with_timer(self):
timer = self.cc.t1 = self.text.after(10000, lambda: None)
self.cc.__del__()
with self.assertRaises(TclError) as cm:
self.root.tk.call('after', 'info', timer)
self.root.after_info(timer)
self.assertIn("doesn't exist", str(cm.exception))

def test_reload(self):
Expand All @@ -151,7 +151,7 @@ def test_toggle_code_context_event(self):
eq(cc.context['bg'], self.highlight_cfg['background'])
eq(cc.context.get('1.0', 'end-1c'), '')
eq(cc.editwin.label, 'Hide Code Context')
eq(self.root.tk.call('after', 'info', self.cc.t1)[1], 'timer')
eq(self.root.after_info(self.cc.t1)[1], 'timer')

# Toggle off.
toggle()
Expand Down
10 changes: 5 additions & 5 deletions Lib/idlelib/idle_test/test_colorizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ def test_notify_range(self):

# Colorizing already scheduled.
save_id = color.after_id
eq(self.root.tk.call('after', 'info', save_id)[1], 'timer')
eq(self.root.after_info(save_id)[1], 'timer')
self.assertFalse(color.colorizing)
self.assertFalse(color.stop_colorizing)
self.assertTrue(color.allow_colorizing)
Expand All @@ -277,7 +277,7 @@ def test_notify_range(self):
color.notify_range('1.0', '1.0+3c')
self.assertTrue(color.stop_colorizing)
self.assertIsNotNone(color.after_id)
eq(self.root.tk.call('after', 'info', color.after_id)[1], 'timer')
eq(self.root.after_info(color.after_id)[1], 'timer')
# New event scheduled.
self.assertNotEqual(color.after_id, save_id)

Expand All @@ -297,7 +297,7 @@ def test_toggle_colorize_event(self):
self.assertFalse(color.colorizing)
self.assertFalse(color.stop_colorizing)
self.assertTrue(color.allow_colorizing)
eq(self.root.tk.call('after', 'info', color.after_id)[1], 'timer')
eq(self.root.after_info(color.after_id)[1], 'timer')

# Toggle colorizing off.
color.toggle_colorize_event()
Expand All @@ -324,7 +324,7 @@ def test_toggle_colorize_event(self):
# Toggle on while colorizing not in progress.
color.colorizing = False
color.toggle_colorize_event()
eq(self.root.tk.call('after', 'info', color.after_id)[1], 'timer')
eq(self.root.after_info(color.after_id)[1], 'timer')
self.assertFalse(color.colorizing)
self.assertTrue(color.stop_colorizing)
self.assertTrue(color.allow_colorizing)
Expand Down Expand Up @@ -363,7 +363,7 @@ def test_recolorize(self, mock_recmain):
mock_recmain.assert_called()
eq(mock_recmain.call_count, 1)
# Rescheduled when TODO tag still exists.
eq(self.root.tk.call('after', 'info', color.after_id)[1], 'timer')
eq(self.root.after_info(color.after_id)[1], 'timer')

# No changes to text, so no scheduling added.
text.tag_remove('TODO', '1.0', 'end')
Expand Down
6 changes: 3 additions & 3 deletions Lib/idlelib/idle_test/test_editor.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def setUpClass(cls):
@classmethod
def tearDownClass(cls):
cls.root.update_idletasks()
for id in cls.root.tk.call('after', 'info'):
for id in cls.root.after_info():
cls.root.after_cancel(id)
cls.root.destroy()
del cls.root
Expand Down Expand Up @@ -114,7 +114,7 @@ def tearDownClass(cls):
cls.window._close()
del cls.window
cls.root.update_idletasks()
for id in cls.root.tk.call('after', 'info'):
for id in cls.root.after_info():
cls.root.after_cancel(id)
cls.root.destroy()
del cls.root
Expand Down Expand Up @@ -225,7 +225,7 @@ def tearDownClass(cls):
cls.window._close()
del cls.window
cls.root.update_idletasks()
for id in cls.root.tk.call('after', 'info'):
for id in cls.root.after_info():
cls.root.after_cancel(id)
cls.root.destroy()
del cls.root
Expand Down
2 changes: 1 addition & 1 deletion Lib/idlelib/idle_test/test_filelist.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def setUpClass(cls):
@classmethod
def tearDownClass(cls):
cls.root.update_idletasks()
for id in cls.root.tk.call('after', 'info'):
for id in cls.root.after_info():
cls.root.after_cancel(id)
cls.root.destroy()
del cls.root
Expand Down
2 changes: 1 addition & 1 deletion Lib/idlelib/idle_test/test_iomenu.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def tearDownClass(cls):
cls.editwin._close()
del cls.editwin
cls.root.update_idletasks()
for id in cls.root.tk.call('after', 'info'):
for id in cls.root.after_info():
cls.root.after_cancel(id) # Need for EditorWindow.
cls.root.destroy()
del cls.root
Expand Down
2 changes: 1 addition & 1 deletion Lib/idlelib/idle_test/test_multicall.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def setUpClass(cls):
def tearDownClass(cls):
del cls.mc
cls.root.update_idletasks()
## for id in cls.root.tk.call('after', 'info'):
## for id in cls.root.after_info():
## cls.root.after_cancel(id) # Need for EditorWindow.
cls.root.destroy()
del cls.root
Expand Down
2 changes: 1 addition & 1 deletion Lib/idlelib/idle_test/test_pyshell.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def setUpClass(cls):
@classmethod
def tearDownClass(cls):
#cls.root.update_idletasks()
## for id in cls.root.tk.call('after', 'info'):
## for id in cls.root.after_info():
## cls.root.after_cancel(id) # Need for EditorWindow.
cls.root.destroy()
del cls.root
Expand Down
2 changes: 1 addition & 1 deletion Lib/idlelib/idle_test/test_runscript.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def setUpClass(cls):
@classmethod
def tearDownClass(cls):
cls.root.update_idletasks()
for id in cls.root.tk.call('after', 'info'):
for id in cls.root.after_info():
cls.root.after_cancel(id) # Need for EditorWindow.
cls.root.destroy()
del cls.root
Expand Down
2 changes: 1 addition & 1 deletion Lib/idlelib/idle_test/test_stackviewer.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def setUpClass(cls):
def tearDownClass(cls):

cls.root.update_idletasks()
## for id in cls.root.tk.call('after', 'info'):
## for id in cls.root.after_info():
## cls.root.after_cancel(id) # Need for EditorWindow.
cls.root.destroy()
del cls.root
Expand Down
2 changes: 1 addition & 1 deletion Lib/idlelib/idle_test/test_window.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def setUpClass(cls):
def tearDownClass(cls):
window.registry = window.WindowList()
cls.root.update_idletasks()
## for id in cls.root.tk.call('after', 'info'):
## for id in cls.root.after_info():
## cls.root.after_cancel(id) # Need for EditorWindow.
cls.root.destroy()
del cls.root
Expand Down
2 changes: 1 addition & 1 deletion Lib/idlelib/idle_test/test_zoomheight.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def setUpClass(cls):
def tearDownClass(cls):
cls.editwin._close()
cls.root.update_idletasks()
for id in cls.root.tk.call('after', 'info'):
for id in cls.root.after_info():
cls.root.after_cancel(id) # Need for EditorWindow.
cls.root.destroy()
del cls.root
Expand Down
2 changes: 1 addition & 1 deletion Lib/idlelib/idle_test/test_zzdummy.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ def tearDownClass(cls):
zzdummy.idleConf.userCfg = usercfg
del cls.editor, cls.text
cls.root.update_idletasks()
for id in cls.root.tk.call('after', 'info'):
for id in cls.root.after_info():
cls.root.after_cancel(id) # Need for EditorWindow.
cls.root.destroy()
del cls.root
Expand Down
2 changes: 1 addition & 1 deletion Lib/idlelib/idle_test/test_zzdummy_user.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ def tearDownClass(cls):
zzdummy.idleConf.userCfg = real_usercfg
del cls.editor, cls.text
cls.root.update_idletasks()
for id in cls.root.tk.call('after', 'info'):
for id in cls.root.after_info():
cls.root.after_cancel(id) # Need for EditorWindow.
cls.root.destroy()
del cls.root
Expand Down
2 changes: 1 addition & 1 deletion Lib/idlelib/macosx.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def _init_tk_type():
_tk_type = "xquartz"
elif 'aqua' not in ws:
_tk_type = "other"
elif 'AppKit' in root.tk.call('winfo', 'server', '.'):
elif 'AppKit' in root.winfo_server():
_tk_type = "cocoa"
else:
_tk_type = "carbon"
Expand Down
23 changes: 23 additions & 0 deletions Lib/test/test_capi/test_opt.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import contextlib
import dis
import itertools
import sys
import textwrap
Expand Down Expand Up @@ -247,6 +248,28 @@ def many_vars():
self.assertTrue(any((opcode, oparg, operand) == ("_LOAD_FAST_BORROW", 259, 0)
for opcode, oparg, _, operand in list(ex)))

def test_jump_backward_extended_arg(self):
# gh-152192: a JUMP_BACKWARD that needs an EXTENDED_ARG must record its
# deopt target at the EXTENDED_ARG, not the JUMP_BACKWARD.
ns = {}
src = ("def f(n):\n"
" i = 0\n"
" while i < n:\n"
" i += 1\n"
+ "".join(f" a = {j}\n" for j in range(140)))
exec(src, ns)
f = ns["f"]

instrs = list(dis.get_instructions(f))
ext, jb = next((p, i) for p, i in zip(instrs, instrs[1:])
if i.opname == "JUMP_BACKWARD" and p.opname == "EXTENDED_ARG")

f(TIER2_THRESHOLD + 1)
ex = _opcode.get_executor(f.__code__, ext.offset)
set_ips = {t for op, _, t, _ in ex if op == "_SET_IP"}
self.assertIn(ext.offset // 2, set_ips)
self.assertNotIn(jb.offset // 2, set_ips)

def test_unspecialized_unpack(self):
# An example of an unspecialized opcode
def testfunc(x):
Expand Down
12 changes: 6 additions & 6 deletions Lib/test/test_ctypes/test_byteswap.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,14 +178,14 @@ def test_endian_float_complex(self):
self.assertIs(c_float_complex.__ctype_le__.__ctype_be__,
c_float_complex)
s = c_float_complex(math.pi+1j)
self.assertEqual(bin(struct.pack("F", math.pi+1j)), bin(s))
self.assertEqual(bin(struct.pack("Zf", math.pi+1j)), bin(s))
self.assertAlmostEqual(s.value, math.pi+1j, places=6)
s = c_float_complex.__ctype_le__(math.pi+1j)
self.assertAlmostEqual(s.value, math.pi+1j, places=6)
self.assertEqual(bin(struct.pack("<F", math.pi+1j)), bin(s))
self.assertEqual(bin(struct.pack("<Zf", math.pi+1j)), bin(s))
s = c_float_complex.__ctype_be__(math.pi+1j)
self.assertAlmostEqual(s.value, math.pi+1j, places=6)
self.assertEqual(bin(struct.pack(">F", math.pi+1j)), bin(s))
self.assertEqual(bin(struct.pack(">Zf", math.pi+1j)), bin(s))

@unittest.skipUnless(hasattr(ctypes, 'c_double_complex'), "No complex types")
def test_endian_double_complex(self):
Expand All @@ -199,14 +199,14 @@ def test_endian_double_complex(self):
self.assertIs(c_double_complex.__ctype_le__.__ctype_be__,
c_double_complex)
s = c_double_complex(math.pi+1j)
self.assertEqual(bin(struct.pack("D", math.pi+1j)), bin(s))
self.assertEqual(bin(struct.pack("Zd", math.pi+1j)), bin(s))
self.assertAlmostEqual(s.value, math.pi+1j, places=6)
s = c_double_complex.__ctype_le__(math.pi+1j)
self.assertAlmostEqual(s.value, math.pi+1j, places=6)
self.assertEqual(bin(struct.pack("<D", math.pi+1j)), bin(s))
self.assertEqual(bin(struct.pack("<Zd", math.pi+1j)), bin(s))
s = c_double_complex.__ctype_be__(math.pi+1j)
self.assertAlmostEqual(s.value, math.pi+1j, places=6)
self.assertEqual(bin(struct.pack(">D", math.pi+1j)), bin(s))
self.assertEqual(bin(struct.pack(">Zd", math.pi+1j)), bin(s))

def test_endian_other(self):
self.assertIs(c_byte.__ctype_le__, c_byte)
Expand Down
4 changes: 2 additions & 2 deletions Lib/test/test_memoryview.py
Original file line number Diff line number Diff line change
Expand Up @@ -717,8 +717,8 @@ def test_half_float(self):
self.assertListEqual(half_view.tolist(), float_view.tolist())

def test_complex_types(self):
float_complex_data = struct.pack('FFF', 0.0, -1.5j, 1+2j)
double_complex_data = struct.pack('DDD', 0.0, -1.5j, 1+2j)
float_complex_data = struct.pack('ZfZfZf', 0.0, -1.5j, 1+2j)
double_complex_data = struct.pack('ZdZdZd', 0.0, -1.5j, 1+2j)
float_complex_view = memoryview(float_complex_data).cast('Zf')
double_complex_view = memoryview(double_complex_data).cast('Zd')
self.assertEqual(float_complex_view.nbytes * 2, double_complex_view.nbytes)
Expand Down
Loading
Loading