[Python-checkins] [3.12] gh-104855: Update Tkinter tests for Tcl/Tk 8.7 and 9.0 (GH-120824) (GH-120865)

2024-06-22 Thread serhiy-storchaka
https://github.com/python/cpython/commit/f1acb3a5927ef813381d40be6fec068a655ddb7a
commit: f1acb3a5927ef813381d40be6fec068a655ddb7a
branch: 3.12
author: Miss Islington (bot) <[email protected]>
committer: serhiy-storchaka 
date: 2024-06-22T07:10:04Z
summary:

[3.12] gh-104855: Update Tkinter tests for Tcl/Tk 8.7 and 9.0 (GH-120824) 
(GH-120865)

The tests are now passed with the current version of Tcl/Tk under
development (8.7b1+ and 9.0b3+).

The following changes were also made to make the tests more flexible:

* Helper methods like checkParam() now interpret the expected error message
  as a regular expression instead of a literal.
* Add support of new arguments in checkEnumParam():
  - allow_empty=True skips testing with empty string;
  - fullname= specifies the name for error message if it differs from the
option name;
  - sort=True sorts values for error message.
* Add support of the allow_empty argument in checkReliefParam():
  allow_empty=True adds an empty string to the list of accepted values.
* Attributes _clip_highlightthickness, _clip_pad and  _clip_borderwidth
  specify how negative values of options -highlightthickness, -padx, -pady
  and -borderwidth are handled.
* Use global variables for some common error messages.

(cherry picked from commit 6ad26de6e8ab61b035e7ecfff9791c2b349c3ad0)

Co-authored-by: Serhiy Storchaka 
Co-authored-by: Terry Jan Reedy 

files:
M Lib/test/test_tcl.py
M Lib/test/test_tkinter/test_geometry_managers.py
M Lib/test/test_tkinter/test_variables.py
M Lib/test/test_tkinter/test_widgets.py
M Lib/test/test_tkinter/widget_tests.py
M Lib/test/test_ttk/test_widgets.py

diff --git a/Lib/test/test_tcl.py b/Lib/test/test_tcl.py
index ebdb58f91d3d8a..dbec5ea7e80433 100644
--- a/Lib/test/test_tcl.py
+++ b/Lib/test/test_tcl.py
@@ -219,10 +219,18 @@ def test_evalfile_surrogates_in_result(self):
 with open(filename, 'wb') as f:
 f.write(b"""
 set a "<\xed\xa0\xbd\xed\xb2\xbb>"
+""")
+if tcl_version >= (9, 0):
+self.assertRaises(TclError, tcl.evalfile, filename)
+else:
+tcl.evalfile(filename)
+self.assertEqual(tcl.eval('set a'), '<\U0001f4bb>')
+
+with open(filename, 'wb') as f:
+f.write(b"""
 set b "<\\ud83d\\udcbb>"
 """)
 tcl.evalfile(filename)
-self.assertEqual(tcl.eval('set a'), '<\U0001f4bb>')
 self.assertEqual(tcl.eval('set b'), '<\U0001f4bb>')
 
 def testEvalFileException(self):
diff --git a/Lib/test/test_tkinter/test_geometry_managers.py 
b/Lib/test/test_tkinter/test_geometry_managers.py
index 59fe592b492adc..1be474b3019b0a 100644
--- a/Lib/test/test_tkinter/test_geometry_managers.py
+++ b/Lib/test/test_tkinter/test_geometry_managers.py
@@ -10,6 +10,11 @@
 requires('gui')
 
 
+EXPECTED_FLOAT_ERRMSG = 'expected floating-point number but got "{}"'
+EXPECTED_FLOAT_OR_EMPTY_ERRMSG = 'expected floating-point number (or "" )?but 
got "{}"'
+EXPECTED_SCREEN_DISTANCE_ERRMSG = '(bad|expected) screen distance (but got 
)?"{}"'
+EXPECTED_SCREEN_DISTANCE_OR_EMPTY_ERRMSG = '(bad|expected) screen distance (or 
"" but got )?"{}"'
+
 class PackTest(AbstractWidgetTest, unittest.TestCase):
 
 test_keys = None
@@ -317,7 +322,8 @@ def test_place_configure_x(self):
 self.assertEqual(f2.place_info()['x'], '-10')
 self.root.update()
 self.assertEqual(f2.winfo_x(), 190)
-with self.assertRaisesRegex(TclError, 'bad screen distance "spam"'):
+with self.assertRaisesRegex(TclError,
+EXPECTED_SCREEN_DISTANCE_ERRMSG.format('spam')):
 f2.place_configure(in_=f, x='spam')
 
 def test_place_configure_y(self):
@@ -334,7 +340,8 @@ def test_place_configure_y(self):
 self.assertEqual(f2.place_info()['y'], '-10')
 self.root.update()
 self.assertEqual(f2.winfo_y(), 110)
-with self.assertRaisesRegex(TclError, 'bad screen distance "spam"'):
+with self.assertRaisesRegex(TclError,
+EXPECTED_SCREEN_DISTANCE_ERRMSG.format('spam')):
 f2.place_configure(in_=f, y='spam')
 
 def test_place_configure_relx(self):
@@ -351,8 +358,7 @@ def test_place_configure_relx(self):
 self.assertEqual(f2.place_info()['relx'], '1')
 self.root.update()
 self.assertEqual(f2.winfo_x(), 200)
-with self.assertRaisesRegex(TclError, 'expected floating-point number '
-'but got "spam"'):
+with self.assertRaisesRegex(TclError, 
EXPECTED_FLOAT_ERRMSG.format('spam')):
 f2.place_configure(in_=f, relx='spam')
 
 def test_place_configure_rely(self):
@@ -369,8 +375,7 @@ def test_place_configure_rely(self):
 self.assertEqual(f2.place_info()['rely'], '1')
 self.root.update()
 self.assertEqual(f2.winfo_y(), 120)
-with self.assertRaisesRegex(TclError, 'expected floating-point number '
-

[Python-checkins] [3.13] gh-104855: Update Tkinter tests for Tcl/Tk 8.7 and 9.0 (GH-120824) (GH-120864)

2024-06-22 Thread serhiy-storchaka
https://github.com/python/cpython/commit/4fabbf97735ea6d91b32011fb7413d3909b082a0
commit: 4fabbf97735ea6d91b32011fb7413d3909b082a0
branch: 3.13
author: Miss Islington (bot) <[email protected]>
committer: serhiy-storchaka 
date: 2024-06-22T07:17:55Z
summary:

[3.13] gh-104855: Update Tkinter tests for Tcl/Tk 8.7 and 9.0 (GH-120824) 
(GH-120864)

The tests are now passed with the current version of Tcl/Tk under
development (8.7b1+ and 9.0b3+).

The following changes were also made to make the tests more flexible:

* Helper methods like checkParam() now interpret the expected error message
  as a regular expression instead of a literal.
* Add support of new arguments in checkEnumParam():
  - allow_empty=True skips testing with empty string;
  - fullname= specifies the name for error message if it differs from the
option name;
  - sort=True sorts values for error message.
* Add support of the allow_empty argument in checkReliefParam():
  allow_empty=True adds an empty string to the list of accepted values.
* Attributes _clip_highlightthickness, _clip_pad and  _clip_borderwidth
  specify how negative values of options -highlightthickness, -padx, -pady
  and -borderwidth are handled.
* Use global variables for some common error messages.

(cherry picked from commit 6ad26de6e8ab61b035e7ecfff9791c2b349c3ad0)

Co-authored-by: Serhiy Storchaka 
Co-authored-by: Terry Jan Reedy 

files:
M Lib/test/test_tcl.py
M Lib/test/test_tkinter/test_geometry_managers.py
M Lib/test/test_tkinter/test_variables.py
M Lib/test/test_tkinter/test_widgets.py
M Lib/test/test_tkinter/widget_tests.py
M Lib/test/test_ttk/test_widgets.py

diff --git a/Lib/test/test_tcl.py b/Lib/test/test_tcl.py
index 553d54329d7939..e6cf2c7ace0617 100644
--- a/Lib/test/test_tcl.py
+++ b/Lib/test/test_tcl.py
@@ -219,10 +219,18 @@ def test_evalfile_surrogates_in_result(self):
 with open(filename, 'wb') as f:
 f.write(b"""
 set a "<\xed\xa0\xbd\xed\xb2\xbb>"
+""")
+if tcl_version >= (9, 0):
+self.assertRaises(TclError, tcl.evalfile, filename)
+else:
+tcl.evalfile(filename)
+self.assertEqual(tcl.eval('set a'), '<\U0001f4bb>')
+
+with open(filename, 'wb') as f:
+f.write(b"""
 set b "<\\ud83d\\udcbb>"
 """)
 tcl.evalfile(filename)
-self.assertEqual(tcl.eval('set a'), '<\U0001f4bb>')
 self.assertEqual(tcl.eval('set b'), '<\U0001f4bb>')
 
 def testEvalFileException(self):
diff --git a/Lib/test/test_tkinter/test_geometry_managers.py 
b/Lib/test/test_tkinter/test_geometry_managers.py
index f8f1c895c56340..d71a634a767310 100644
--- a/Lib/test/test_tkinter/test_geometry_managers.py
+++ b/Lib/test/test_tkinter/test_geometry_managers.py
@@ -10,6 +10,11 @@
 requires('gui')
 
 
+EXPECTED_FLOAT_ERRMSG = 'expected floating-point number but got "{}"'
+EXPECTED_FLOAT_OR_EMPTY_ERRMSG = 'expected floating-point number (or "" )?but 
got "{}"'
+EXPECTED_SCREEN_DISTANCE_ERRMSG = '(bad|expected) screen distance (but got 
)?"{}"'
+EXPECTED_SCREEN_DISTANCE_OR_EMPTY_ERRMSG = '(bad|expected) screen distance (or 
"" but got )?"{}"'
+
 class PackTest(AbstractWidgetTest, unittest.TestCase):
 
 test_keys = None
@@ -317,7 +322,8 @@ def test_place_configure_x(self):
 self.assertEqual(f2.place_info()['x'], '-10')
 self.root.update()
 self.assertEqual(f2.winfo_x(), 190)
-with self.assertRaisesRegex(TclError, 'bad screen distance "spam"'):
+with self.assertRaisesRegex(TclError,
+EXPECTED_SCREEN_DISTANCE_ERRMSG.format('spam')):
 f2.place_configure(in_=f, x='spam')
 
 def test_place_configure_y(self):
@@ -334,7 +340,8 @@ def test_place_configure_y(self):
 self.assertEqual(f2.place_info()['y'], '-10')
 self.root.update()
 self.assertEqual(f2.winfo_y(), 110)
-with self.assertRaisesRegex(TclError, 'bad screen distance "spam"'):
+with self.assertRaisesRegex(TclError,
+EXPECTED_SCREEN_DISTANCE_ERRMSG.format('spam')):
 f2.place_configure(in_=f, y='spam')
 
 def test_place_configure_relx(self):
@@ -351,8 +358,7 @@ def test_place_configure_relx(self):
 self.assertEqual(f2.place_info()['relx'], '1')
 self.root.update()
 self.assertEqual(f2.winfo_x(), 200)
-with self.assertRaisesRegex(TclError, 'expected floating-point number '
-'but got "spam"'):
+with self.assertRaisesRegex(TclError, 
EXPECTED_FLOAT_ERRMSG.format('spam')):
 f2.place_configure(in_=f, relx='spam')
 
 def test_place_configure_rely(self):
@@ -369,8 +375,7 @@ def test_place_configure_rely(self):
 self.assertEqual(f2.place_info()['rely'], '1')
 self.root.update()
 self.assertEqual(f2.winfo_y(), 120)
-with self.assertRaisesRegex(TclError, 'expected floating-point number '
-

[Python-checkins] [3.12] gh-120811: Fix reference leak upon `_PyContext_Exit` failure (GH-120812) (#120844)

2024-06-22 Thread kumaraditya303
https://github.com/python/cpython/commit/b1bccab588b978220f16eedf839af70cb8bb76ea
commit: b1bccab588b978220f16eedf839af70cb8bb76ea
branch: 3.12
author: Miss Islington (bot) <[email protected]>
committer: kumaraditya303 
date: 2024-06-22T16:44:31+05:30
summary:

[3.12] gh-120811: Fix reference leak upon `_PyContext_Exit` failure (GH-120812) 
(#120844)

gh-120811: Fix reference leak upon `_PyContext_Exit` failure (GH-120812)
(cherry picked from commit aed31beca9a54b85a1392631a48da80602210f18)

Co-authored-by: Peter 
Co-authored-by: Kumar Aditya 

files:
A Misc/NEWS.d/next/Library/2024-06-21-14-32-56.gh-issue-120811.eBmVTV.rst
M Python/context.c

diff --git 
a/Misc/NEWS.d/next/Library/2024-06-21-14-32-56.gh-issue-120811.eBmVTV.rst 
b/Misc/NEWS.d/next/Library/2024-06-21-14-32-56.gh-issue-120811.eBmVTV.rst
new file mode 100644
index 00..62cd7b5620474a
--- /dev/null
+++ b/Misc/NEWS.d/next/Library/2024-06-21-14-32-56.gh-issue-120811.eBmVTV.rst
@@ -0,0 +1 @@
+Fix possible memory leak in :meth:`contextvars.Context.run`.
diff --git a/Python/context.c b/Python/context.c
index 1ffae9871be7b3..7bccfad11a45b1 100644
--- a/Python/context.c
+++ b/Python/context.c
@@ -669,6 +669,7 @@ context_run(PyContext *self, PyObject *const *args,
 ts, args[0], args + 1, nargs - 1, kwnames);
 
 if (_PyContext_Exit(ts, (PyObject *)self)) {
+Py_XDECREF(call_result);
 return NULL;
 }
 

___
Python-checkins mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-checkins.python.org/
Member address: [email protected]


[Python-checkins] [3.13] gh-120811: Fix reference leak upon `_PyContext_Exit` failure (GH-120812) (#120843)

2024-06-22 Thread kumaraditya303
https://github.com/python/cpython/commit/a860b1d60b8e3d09c58daf6996a38606f407a009
commit: a860b1d60b8e3d09c58daf6996a38606f407a009
branch: 3.13
author: Miss Islington (bot) <[email protected]>
committer: kumaraditya303 
date: 2024-06-22T16:44:46+05:30
summary:

[3.13] gh-120811: Fix reference leak upon `_PyContext_Exit` failure (GH-120812) 
(#120843)

gh-120811: Fix reference leak upon `_PyContext_Exit` failure (GH-120812)
(cherry picked from commit aed31beca9a54b85a1392631a48da80602210f18)

Co-authored-by: Peter 
Co-authored-by: Kumar Aditya 

files:
A Misc/NEWS.d/next/Library/2024-06-21-14-32-56.gh-issue-120811.eBmVTV.rst
M Python/context.c

diff --git 
a/Misc/NEWS.d/next/Library/2024-06-21-14-32-56.gh-issue-120811.eBmVTV.rst 
b/Misc/NEWS.d/next/Library/2024-06-21-14-32-56.gh-issue-120811.eBmVTV.rst
new file mode 100644
index 00..62cd7b5620474a
--- /dev/null
+++ b/Misc/NEWS.d/next/Library/2024-06-21-14-32-56.gh-issue-120811.eBmVTV.rst
@@ -0,0 +1 @@
+Fix possible memory leak in :meth:`contextvars.Context.run`.
diff --git a/Python/context.c b/Python/context.c
index 3937819b3c386c..63318d1e597439 100644
--- a/Python/context.c
+++ b/Python/context.c
@@ -661,6 +661,7 @@ context_run(PyContext *self, PyObject *const *args,
 ts, args[0], args + 1, nargs - 1, kwnames);
 
 if (_PyContext_Exit(ts, (PyObject *)self)) {
+Py_XDECREF(call_result);
 return NULL;
 }
 

___
Python-checkins mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-checkins.python.org/
Member address: [email protected]


[Python-checkins] gh-120873: Add test for "state" option in ttk.Scale (GH-120874)

2024-06-22 Thread serhiy-storchaka
https://github.com/python/cpython/commit/974a978631bfbfa6f617e927d5eaa82b06694ae5
commit: 974a978631bfbfa6f617e927d5eaa82b06694ae5
branch: main
author: Serhiy Storchaka 
committer: serhiy-storchaka 
date: 2024-06-22T11:18:04Z
summary:

gh-120873: Add test for "state" option in ttk.Scale (GH-120874)

Also refactor the "state" option tests for other ttk widgets.

files:
M Lib/test/test_ttk/test_widgets.py

diff --git a/Lib/test/test_ttk/test_widgets.py 
b/Lib/test/test_ttk/test_widgets.py
index 2eb2c446366517..0c8931b384c6c9 100644
--- a/Lib/test/test_ttk/test_widgets.py
+++ b/Lib/test/test_ttk/test_widgets.py
@@ -5,8 +5,9 @@
 import sys
 
 from test.test_ttk_textonly import MockTclObj
-from test.test_tkinter.support import (AbstractTkTest, tk_version, 
get_tk_patchlevel,
-  simulate_mouse_click, 
AbstractDefaultRootTest)
+from test.test_tkinter.support import (
+AbstractTkTest, requires_tk, tk_version, get_tk_patchlevel,
+simulate_mouse_click, AbstractDefaultRootTest)
 from test.test_tkinter.widget_tests import (add_standard_options,
 AbstractWidgetTest, StandardOptionsTests, IntegerSizeTests, PixelSizeTests)
 
@@ -44,6 +45,10 @@ def padding_conv(value):
 self.checkParam(widget, 'padding', ('5p', '6p', '7p', '8p'))
 self.checkParam(widget, 'padding', (), expected='')
 
+def test_configure_state(self):
+widget = self.create()
+self.checkParams(widget, 'state', 'active', 'disabled', 'readonly')
+
 def test_configure_style(self):
 widget = self.create()
 self.assertEqual(widget['style'], '')
@@ -183,10 +188,6 @@ def test_configure_compound(self):
 widget = self.create()
 self.checkEnumParam(widget, 'compound', *values, allow_empty=True)
 
-def test_configure_state(self):
-widget = self.create()
-self.checkParams(widget, 'state', 'active', 'disabled', 'normal')
-
 def test_configure_width(self):
 widget = self.create()
 self.checkParams(widget, 'width', 402, -402, 0)
@@ -359,11 +360,6 @@ def test_configure_show(self):
 self.checkParam(widget, 'show', '')
 self.checkParam(widget, 'show', ' ')
 
-def test_configure_state(self):
-widget = self.create()
-self.checkParams(widget, 'state',
- 'disabled', 'normal', 'readonly')
-
 def test_configure_validate(self):
 widget = self.create()
 self.checkEnumParam(widget, 'validate',
@@ -803,7 +799,7 @@ def test_configure_menu(self):
 class ScaleTest(AbstractWidgetTest, unittest.TestCase):
 OPTIONS = (
 'class', 'command', 'cursor', 'from', 'length',
-'orient', 'style', 'takefocus', 'to', 'value', 'variable',
+'orient', 'state', 'style', 'takefocus', 'to', 'value', 'variable',
 )
 _conv_pixels = False
 default_orient = 'horizontal'
@@ -825,6 +821,8 @@ def test_configure_length(self):
 widget = self.create()
 self.checkPixelsParam(widget, 'length', 130, 131.2, 135.6, '5i')
 
+test_configure_state = requires_tk(8, 6, 
9)(StandardTtkOptionsTests.test_configure_state)
+
 def test_configure_to(self):
 widget = self.create()
 self.checkFloatParam(widget, 'to', 300, 14.9, 15.1, -10, conv=False)

___
Python-checkins mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-checkins.python.org/
Member address: [email protected]


[Python-checkins] [3.12] gh-120873: Add test for "state" option in ttk.Scale (GH-120874) (GH-120876)

2024-06-22 Thread serhiy-storchaka
https://github.com/python/cpython/commit/22a276ff15654206a648f22e667f348c706a9813
commit: 22a276ff15654206a648f22e667f348c706a9813
branch: 3.12
author: Miss Islington (bot) <[email protected]>
committer: serhiy-storchaka 
date: 2024-06-22T11:39:33Z
summary:

[3.12] gh-120873: Add test for "state" option in ttk.Scale (GH-120874) 
(GH-120876)

Also refactor the "state" option tests for other ttk widgets.
(cherry picked from commit 974a978631bfbfa6f617e927d5eaa82b06694ae5)

Co-authored-by: Serhiy Storchaka 

files:
M Lib/test/test_ttk/test_widgets.py

diff --git a/Lib/test/test_ttk/test_widgets.py 
b/Lib/test/test_ttk/test_widgets.py
index 989f2f17fed452..4c6178cfe4cd25 100644
--- a/Lib/test/test_ttk/test_widgets.py
+++ b/Lib/test/test_ttk/test_widgets.py
@@ -5,8 +5,9 @@
 import sys
 
 from test.test_ttk_textonly import MockTclObj
-from test.test_tkinter.support import (AbstractTkTest, tk_version, 
get_tk_patchlevel,
-  simulate_mouse_click, 
AbstractDefaultRootTest)
+from test.test_tkinter.support import (
+AbstractTkTest, requires_tk, tk_version, get_tk_patchlevel,
+simulate_mouse_click, AbstractDefaultRootTest)
 from test.test_tkinter.widget_tests import (add_standard_options,
 AbstractWidgetTest, StandardOptionsTests, IntegerSizeTests, PixelSizeTests)
 
@@ -44,6 +45,10 @@ def padding_conv(value):
 self.checkParam(widget, 'padding', ('5p', '6p', '7p', '8p'))
 self.checkParam(widget, 'padding', (), expected='')
 
+def test_configure_state(self):
+widget = self.create()
+self.checkParams(widget, 'state', 'active', 'disabled', 'readonly')
+
 def test_configure_style(self):
 widget = self.create()
 self.assertEqual(widget['style'], '')
@@ -183,10 +188,6 @@ def test_configure_compound(self):
 widget = self.create()
 self.checkEnumParam(widget, 'compound', *values, allow_empty=True)
 
-def test_configure_state(self):
-widget = self.create()
-self.checkParams(widget, 'state', 'active', 'disabled', 'normal')
-
 def test_configure_width(self):
 widget = self.create()
 self.checkParams(widget, 'width', 402, -402, 0)
@@ -359,11 +360,6 @@ def test_configure_show(self):
 self.checkParam(widget, 'show', '')
 self.checkParam(widget, 'show', ' ')
 
-def test_configure_state(self):
-widget = self.create()
-self.checkParams(widget, 'state',
- 'disabled', 'normal', 'readonly')
-
 def test_configure_validate(self):
 widget = self.create()
 self.checkEnumParam(widget, 'validate',
@@ -803,7 +799,7 @@ def test_configure_menu(self):
 class ScaleTest(AbstractWidgetTest, unittest.TestCase):
 OPTIONS = (
 'class', 'command', 'cursor', 'from', 'length',
-'orient', 'style', 'takefocus', 'to', 'value', 'variable',
+'orient', 'state', 'style', 'takefocus', 'to', 'value', 'variable',
 )
 _conv_pixels = False
 default_orient = 'horizontal'
@@ -825,6 +821,8 @@ def test_configure_length(self):
 widget = self.create()
 self.checkPixelsParam(widget, 'length', 130, 131.2, 135.6, '5i')
 
+test_configure_state = requires_tk(8, 6, 
9)(StandardTtkOptionsTests.test_configure_state)
+
 def test_configure_to(self):
 widget = self.create()
 self.checkFloatParam(widget, 'to', 300, 14.9, 15.1, -10, conv=False)

___
Python-checkins mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-checkins.python.org/
Member address: [email protected]


[Python-checkins] [3.13] gh-120873: Add test for "state" option in ttk.Scale (GH-120874) (GH-120875)

2024-06-22 Thread serhiy-storchaka
https://github.com/python/cpython/commit/61e6b6ab4abc36fe82f42677e3212caf973da467
commit: 61e6b6ab4abc36fe82f42677e3212caf973da467
branch: 3.13
author: Miss Islington (bot) <[email protected]>
committer: serhiy-storchaka 
date: 2024-06-22T11:45:19Z
summary:

[3.13] gh-120873: Add test for "state" option in ttk.Scale (GH-120874) 
(GH-120875)

Also refactor the "state" option tests for other ttk widgets.
(cherry picked from commit 974a978631bfbfa6f617e927d5eaa82b06694ae5)

Co-authored-by: Serhiy Storchaka 

files:
M Lib/test/test_ttk/test_widgets.py

diff --git a/Lib/test/test_ttk/test_widgets.py 
b/Lib/test/test_ttk/test_widgets.py
index 2eb2c446366517..0c8931b384c6c9 100644
--- a/Lib/test/test_ttk/test_widgets.py
+++ b/Lib/test/test_ttk/test_widgets.py
@@ -5,8 +5,9 @@
 import sys
 
 from test.test_ttk_textonly import MockTclObj
-from test.test_tkinter.support import (AbstractTkTest, tk_version, 
get_tk_patchlevel,
-  simulate_mouse_click, 
AbstractDefaultRootTest)
+from test.test_tkinter.support import (
+AbstractTkTest, requires_tk, tk_version, get_tk_patchlevel,
+simulate_mouse_click, AbstractDefaultRootTest)
 from test.test_tkinter.widget_tests import (add_standard_options,
 AbstractWidgetTest, StandardOptionsTests, IntegerSizeTests, PixelSizeTests)
 
@@ -44,6 +45,10 @@ def padding_conv(value):
 self.checkParam(widget, 'padding', ('5p', '6p', '7p', '8p'))
 self.checkParam(widget, 'padding', (), expected='')
 
+def test_configure_state(self):
+widget = self.create()
+self.checkParams(widget, 'state', 'active', 'disabled', 'readonly')
+
 def test_configure_style(self):
 widget = self.create()
 self.assertEqual(widget['style'], '')
@@ -183,10 +188,6 @@ def test_configure_compound(self):
 widget = self.create()
 self.checkEnumParam(widget, 'compound', *values, allow_empty=True)
 
-def test_configure_state(self):
-widget = self.create()
-self.checkParams(widget, 'state', 'active', 'disabled', 'normal')
-
 def test_configure_width(self):
 widget = self.create()
 self.checkParams(widget, 'width', 402, -402, 0)
@@ -359,11 +360,6 @@ def test_configure_show(self):
 self.checkParam(widget, 'show', '')
 self.checkParam(widget, 'show', ' ')
 
-def test_configure_state(self):
-widget = self.create()
-self.checkParams(widget, 'state',
- 'disabled', 'normal', 'readonly')
-
 def test_configure_validate(self):
 widget = self.create()
 self.checkEnumParam(widget, 'validate',
@@ -803,7 +799,7 @@ def test_configure_menu(self):
 class ScaleTest(AbstractWidgetTest, unittest.TestCase):
 OPTIONS = (
 'class', 'command', 'cursor', 'from', 'length',
-'orient', 'style', 'takefocus', 'to', 'value', 'variable',
+'orient', 'state', 'style', 'takefocus', 'to', 'value', 'variable',
 )
 _conv_pixels = False
 default_orient = 'horizontal'
@@ -825,6 +821,8 @@ def test_configure_length(self):
 widget = self.create()
 self.checkPixelsParam(widget, 'length', 130, 131.2, 135.6, '5i')
 
+test_configure_state = requires_tk(8, 6, 
9)(StandardTtkOptionsTests.test_configure_state)
+
 def test_configure_to(self):
 widget = self.create()
 self.checkFloatParam(widget, 'to', 300, 14.9, 15.1, -10, conv=False)

___
Python-checkins mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-checkins.python.org/
Member address: [email protected]


[Python-checkins] gh-120873: Add tests for new widget options in Tk 8.7 (GH-120877)

2024-06-22 Thread serhiy-storchaka
https://github.com/python/cpython/commit/a046c848c1df0cf98092e9696594d3fb836e3530
commit: a046c848c1df0cf98092e9696594d3fb836e3530
branch: main
author: Serhiy Storchaka 
committer: serhiy-storchaka 
date: 2024-06-22T16:19:42+03:00
summary:

gh-120873: Add tests for new widget options in Tk 8.7 (GH-120877)

files:
M Lib/test/test_tkinter/test_widgets.py
M Lib/test/test_tkinter/widget_tests.py
M Lib/test/test_ttk/test_widgets.py

diff --git a/Lib/test/test_tkinter/test_widgets.py 
b/Lib/test/test_tkinter/test_widgets.py
index 64ea87e647cf8b..9ea764ca2a39d8 100644
--- a/Lib/test/test_tkinter/test_widgets.py
+++ b/Lib/test/test_tkinter/test_widgets.py
@@ -61,11 +61,11 @@ def test_configure_visual(self):
 @add_standard_options(StandardOptionsTests)
 class ToplevelTest(AbstractToplevelTest, unittest.TestCase):
 OPTIONS = (
-'background', 'borderwidth',
+'background', 'backgroundimage', 'borderwidth',
 'class', 'colormap', 'container', 'cursor', 'height',
 'highlightbackground', 'highlightcolor', 'highlightthickness',
 'menu', 'padx', 'pady', 'relief', 'screen',
-'takefocus', 'use', 'visual', 'width',
+'takefocus', 'tile', 'use', 'visual', 'width',
 )
 
 def create(self, **kwargs):
@@ -104,10 +104,10 @@ def test_configure_use(self):
 @add_standard_options(StandardOptionsTests)
 class FrameTest(AbstractToplevelTest, unittest.TestCase):
 OPTIONS = (
-'background', 'borderwidth',
+'background', 'backgroundimage', 'borderwidth',
 'class', 'colormap', 'container', 'cursor', 'height',
 'highlightbackground', 'highlightcolor', 'highlightthickness',
-'padx', 'pady', 'relief', 'takefocus', 'visual', 'width',
+'padx', 'pady', 'relief', 'takefocus', 'tile', 'visual', 'width',
 )
 
 def create(self, **kwargs):
@@ -338,7 +338,8 @@ class EntryTest(AbstractWidgetTest, unittest.TestCase):
 'highlightbackground', 'highlightcolor', 'highlightthickness',
 'insertbackground', 'insertborderwidth',
 'insertofftime', 'insertontime', 'insertwidth',
-'invalidcommand', 'justify', 'readonlybackground', 'relief',
+'invalidcommand', 'justify', 'placeholder', 'placeholderforeground',
+'readonlybackground', 'relief',
 'selectbackground', 'selectborderwidth', 'selectforeground',
 'show', 'state', 'takefocus', 'textvariable',
 'validate', 'validatecommand', 'width', 'xscrollcommand',
@@ -432,8 +433,8 @@ class SpinboxTest(EntryTest, unittest.TestCase):
 'increment',
 'insertbackground', 'insertborderwidth',
 'insertofftime', 'insertontime', 'insertwidth',
-'invalidcommand', 'justify', 'relief', 'readonlybackground',
-'repeatdelay', 'repeatinterval',
+'invalidcommand', 'justify', 'placeholder', 'placeholderforeground',
+'relief', 'readonlybackground', 'repeatdelay', 'repeatinterval',
 'selectbackground', 'selectborderwidth', 'selectforeground',
 'state', 'takefocus', 'textvariable', 'to',
 'validate', 'validatecommand', 'values',
@@ -1176,10 +1177,6 @@ class ScrollbarTest(AbstractWidgetTest, 
unittest.TestCase):
 def create(self, **kwargs):
 return tkinter.Scrollbar(self.root, **kwargs)
 
-def test_configure_activerelief(self):
-widget = self.create()
-self.checkReliefParam(widget, 'activerelief')
-
 def test_configure_elementborderwidth(self):
 widget = self.create()
 self.checkPixelsParam(widget, 'elementborderwidth', 4.3, 5.6, '1m')
@@ -1386,6 +1383,7 @@ def test_paneconfigure_width(self):
 class MenuTest(AbstractWidgetTest, unittest.TestCase):
 OPTIONS = (
 'activebackground', 'activeborderwidth', 'activeforeground',
+'activerelief',
 'background', 'borderwidth', 'cursor',
 'disabledforeground', 'font', 'foreground',
 'postcommand', 'relief', 'selectcolor', 'takefocus',
@@ -1401,6 +1399,8 @@ def test_indexcommand_none(self):
 i = widget.index('none')
 self.assertIsNone(i)
 
+test_configure_activerelief = requires_tk(8, 
7)(StandardOptionsTests.test_configure_activerelief)
+
 def test_configure_postcommand(self):
 widget = self.create()
 self.checkCommandParam(widget, 'postcommand')
diff --git a/Lib/test/test_tkinter/widget_tests.py 
b/Lib/test/test_tkinter/widget_tests.py
index eef2efb3856b1f..8ab2f74245095d 100644
--- a/Lib/test/test_tkinter/widget_tests.py
+++ b/Lib/test/test_tkinter/widget_tests.py
@@ -2,7 +2,7 @@
 
 import re
 import tkinter
-from test.test_tkinter.support import (AbstractTkTest, tk_version,
+from test.test_tkinter.support import (AbstractTkTest, requires_tk, tk_version,
   pixels_conv, tcl_obj_eq)
 import test.support
 
@@ -17,6 +17,7 @@ class AbstractWidgetTest(AbstractTkTest):
 _clip_highlightthickness = True
 _clip_pad = False
 _clip_borderwidth = False
+_allow_em

[Python-checkins] [3.12] gh-120873: Add tests for new widget options in Tk 8.7 (GH-120877) (GH-120880)

2024-06-22 Thread serhiy-storchaka
https://github.com/python/cpython/commit/7f64c2fb4344301fbc022ec1e3b47b5a9f001399
commit: 7f64c2fb4344301fbc022ec1e3b47b5a9f001399
branch: 3.12
author: Miss Islington (bot) <[email protected]>
committer: serhiy-storchaka 
date: 2024-06-22T13:38:08Z
summary:

[3.12] gh-120873: Add tests for new widget options in Tk 8.7 (GH-120877) 
(GH-120880)

(cherry picked from commit a046c848c1df0cf98092e9696594d3fb836e3530)

Co-authored-by: Serhiy Storchaka 

files:
M Lib/test/test_tkinter/test_widgets.py
M Lib/test/test_tkinter/widget_tests.py
M Lib/test/test_ttk/test_widgets.py

diff --git a/Lib/test/test_tkinter/test_widgets.py 
b/Lib/test/test_tkinter/test_widgets.py
index a78e8a665ac505..b020e1be6a2784 100644
--- a/Lib/test/test_tkinter/test_widgets.py
+++ b/Lib/test/test_tkinter/test_widgets.py
@@ -61,11 +61,11 @@ def test_configure_visual(self):
 @add_standard_options(StandardOptionsTests)
 class ToplevelTest(AbstractToplevelTest, unittest.TestCase):
 OPTIONS = (
-'background', 'borderwidth',
+'background', 'backgroundimage', 'borderwidth',
 'class', 'colormap', 'container', 'cursor', 'height',
 'highlightbackground', 'highlightcolor', 'highlightthickness',
 'menu', 'padx', 'pady', 'relief', 'screen',
-'takefocus', 'use', 'visual', 'width',
+'takefocus', 'tile', 'use', 'visual', 'width',
 )
 
 def create(self, **kwargs):
@@ -104,10 +104,10 @@ def test_configure_use(self):
 @add_standard_options(StandardOptionsTests)
 class FrameTest(AbstractToplevelTest, unittest.TestCase):
 OPTIONS = (
-'background', 'borderwidth',
+'background', 'backgroundimage', 'borderwidth',
 'class', 'colormap', 'container', 'cursor', 'height',
 'highlightbackground', 'highlightcolor', 'highlightthickness',
-'padx', 'pady', 'relief', 'takefocus', 'visual', 'width',
+'padx', 'pady', 'relief', 'takefocus', 'tile', 'visual', 'width',
 )
 
 def create(self, **kwargs):
@@ -338,7 +338,8 @@ class EntryTest(AbstractWidgetTest, unittest.TestCase):
 'highlightbackground', 'highlightcolor', 'highlightthickness',
 'insertbackground', 'insertborderwidth',
 'insertofftime', 'insertontime', 'insertwidth',
-'invalidcommand', 'justify', 'readonlybackground', 'relief',
+'invalidcommand', 'justify', 'placeholder', 'placeholderforeground',
+'readonlybackground', 'relief',
 'selectbackground', 'selectborderwidth', 'selectforeground',
 'show', 'state', 'takefocus', 'textvariable',
 'validate', 'validatecommand', 'width', 'xscrollcommand',
@@ -432,8 +433,8 @@ class SpinboxTest(EntryTest, unittest.TestCase):
 'increment',
 'insertbackground', 'insertborderwidth',
 'insertofftime', 'insertontime', 'insertwidth',
-'invalidcommand', 'justify', 'relief', 'readonlybackground',
-'repeatdelay', 'repeatinterval',
+'invalidcommand', 'justify', 'placeholder', 'placeholderforeground',
+'relief', 'readonlybackground', 'repeatdelay', 'repeatinterval',
 'selectbackground', 'selectborderwidth', 'selectforeground',
 'state', 'takefocus', 'textvariable', 'to',
 'validate', 'validatecommand', 'values',
@@ -1176,10 +1177,6 @@ class ScrollbarTest(AbstractWidgetTest, 
unittest.TestCase):
 def create(self, **kwargs):
 return tkinter.Scrollbar(self.root, **kwargs)
 
-def test_configure_activerelief(self):
-widget = self.create()
-self.checkReliefParam(widget, 'activerelief')
-
 def test_configure_elementborderwidth(self):
 widget = self.create()
 self.checkPixelsParam(widget, 'elementborderwidth', 4.3, 5.6, '1m')
@@ -1386,6 +1383,7 @@ def test_paneconfigure_width(self):
 class MenuTest(AbstractWidgetTest, unittest.TestCase):
 OPTIONS = (
 'activebackground', 'activeborderwidth', 'activeforeground',
+'activerelief',
 'background', 'borderwidth', 'cursor',
 'disabledforeground', 'font', 'foreground',
 'postcommand', 'relief', 'selectcolor', 'takefocus',
@@ -1401,6 +1399,8 @@ def test_indexcommand_none(self):
 i = widget.index('none')
 self.assertIsNone(i)
 
+test_configure_activerelief = requires_tk(8, 
7)(StandardOptionsTests.test_configure_activerelief)
+
 def test_configure_postcommand(self):
 widget = self.create()
 self.checkCommandParam(widget, 'postcommand')
diff --git a/Lib/test/test_tkinter/widget_tests.py 
b/Lib/test/test_tkinter/widget_tests.py
index 314c22b693b583..3b75dc7b2c17e2 100644
--- a/Lib/test/test_tkinter/widget_tests.py
+++ b/Lib/test/test_tkinter/widget_tests.py
@@ -2,7 +2,7 @@
 
 import re
 import tkinter
-from test.test_tkinter.support import (AbstractTkTest, tk_version,
+from test.test_tkinter.support import (AbstractTkTest, requires_tk, tk_version,
   pixels_conv, tcl_obj_eq)
 import test.s

[Python-checkins] [3.13] gh-120873: Add tests for new widget options in Tk 8.7 (GH-120877) (GH-120879)

2024-06-22 Thread serhiy-storchaka
https://github.com/python/cpython/commit/cffead81fae34aa678ef2f89dff4a0175a619c85
commit: cffead81fae34aa678ef2f89dff4a0175a619c85
branch: 3.13
author: Miss Islington (bot) <[email protected]>
committer: serhiy-storchaka 
date: 2024-06-22T13:43:30Z
summary:

[3.13] gh-120873: Add tests for new widget options in Tk 8.7 (GH-120877) 
(GH-120879)

(cherry picked from commit a046c848c1df0cf98092e9696594d3fb836e3530)

Co-authored-by: Serhiy Storchaka 

files:
M Lib/test/test_tkinter/test_widgets.py
M Lib/test/test_tkinter/widget_tests.py
M Lib/test/test_ttk/test_widgets.py

diff --git a/Lib/test/test_tkinter/test_widgets.py 
b/Lib/test/test_tkinter/test_widgets.py
index 64ea87e647cf8b..9ea764ca2a39d8 100644
--- a/Lib/test/test_tkinter/test_widgets.py
+++ b/Lib/test/test_tkinter/test_widgets.py
@@ -61,11 +61,11 @@ def test_configure_visual(self):
 @add_standard_options(StandardOptionsTests)
 class ToplevelTest(AbstractToplevelTest, unittest.TestCase):
 OPTIONS = (
-'background', 'borderwidth',
+'background', 'backgroundimage', 'borderwidth',
 'class', 'colormap', 'container', 'cursor', 'height',
 'highlightbackground', 'highlightcolor', 'highlightthickness',
 'menu', 'padx', 'pady', 'relief', 'screen',
-'takefocus', 'use', 'visual', 'width',
+'takefocus', 'tile', 'use', 'visual', 'width',
 )
 
 def create(self, **kwargs):
@@ -104,10 +104,10 @@ def test_configure_use(self):
 @add_standard_options(StandardOptionsTests)
 class FrameTest(AbstractToplevelTest, unittest.TestCase):
 OPTIONS = (
-'background', 'borderwidth',
+'background', 'backgroundimage', 'borderwidth',
 'class', 'colormap', 'container', 'cursor', 'height',
 'highlightbackground', 'highlightcolor', 'highlightthickness',
-'padx', 'pady', 'relief', 'takefocus', 'visual', 'width',
+'padx', 'pady', 'relief', 'takefocus', 'tile', 'visual', 'width',
 )
 
 def create(self, **kwargs):
@@ -338,7 +338,8 @@ class EntryTest(AbstractWidgetTest, unittest.TestCase):
 'highlightbackground', 'highlightcolor', 'highlightthickness',
 'insertbackground', 'insertborderwidth',
 'insertofftime', 'insertontime', 'insertwidth',
-'invalidcommand', 'justify', 'readonlybackground', 'relief',
+'invalidcommand', 'justify', 'placeholder', 'placeholderforeground',
+'readonlybackground', 'relief',
 'selectbackground', 'selectborderwidth', 'selectforeground',
 'show', 'state', 'takefocus', 'textvariable',
 'validate', 'validatecommand', 'width', 'xscrollcommand',
@@ -432,8 +433,8 @@ class SpinboxTest(EntryTest, unittest.TestCase):
 'increment',
 'insertbackground', 'insertborderwidth',
 'insertofftime', 'insertontime', 'insertwidth',
-'invalidcommand', 'justify', 'relief', 'readonlybackground',
-'repeatdelay', 'repeatinterval',
+'invalidcommand', 'justify', 'placeholder', 'placeholderforeground',
+'relief', 'readonlybackground', 'repeatdelay', 'repeatinterval',
 'selectbackground', 'selectborderwidth', 'selectforeground',
 'state', 'takefocus', 'textvariable', 'to',
 'validate', 'validatecommand', 'values',
@@ -1176,10 +1177,6 @@ class ScrollbarTest(AbstractWidgetTest, 
unittest.TestCase):
 def create(self, **kwargs):
 return tkinter.Scrollbar(self.root, **kwargs)
 
-def test_configure_activerelief(self):
-widget = self.create()
-self.checkReliefParam(widget, 'activerelief')
-
 def test_configure_elementborderwidth(self):
 widget = self.create()
 self.checkPixelsParam(widget, 'elementborderwidth', 4.3, 5.6, '1m')
@@ -1386,6 +1383,7 @@ def test_paneconfigure_width(self):
 class MenuTest(AbstractWidgetTest, unittest.TestCase):
 OPTIONS = (
 'activebackground', 'activeborderwidth', 'activeforeground',
+'activerelief',
 'background', 'borderwidth', 'cursor',
 'disabledforeground', 'font', 'foreground',
 'postcommand', 'relief', 'selectcolor', 'takefocus',
@@ -1401,6 +1399,8 @@ def test_indexcommand_none(self):
 i = widget.index('none')
 self.assertIsNone(i)
 
+test_configure_activerelief = requires_tk(8, 
7)(StandardOptionsTests.test_configure_activerelief)
+
 def test_configure_postcommand(self):
 widget = self.create()
 self.checkCommandParam(widget, 'postcommand')
diff --git a/Lib/test/test_tkinter/widget_tests.py 
b/Lib/test/test_tkinter/widget_tests.py
index eef2efb3856b1f..8ab2f74245095d 100644
--- a/Lib/test/test_tkinter/widget_tests.py
+++ b/Lib/test/test_tkinter/widget_tests.py
@@ -2,7 +2,7 @@
 
 import re
 import tkinter
-from test.test_tkinter.support import (AbstractTkTest, tk_version,
+from test.test_tkinter.support import (AbstractTkTest, requires_tk, tk_version,
   pixels_conv, tcl_obj_eq)
 import test.s

[Python-checkins] gh-119182: Add checks to PyUnicodeWriter APIs (#120870)

2024-06-22 Thread vstinner
https://github.com/python/cpython/commit/e21347549535b16f51a39986b78a2c2cd4ed09f4
commit: e21347549535b16f51a39986b78a2c2cd4ed09f4
branch: main
author: Victor Stinner 
committer: vstinner 
date: 2024-06-22T17:25:55+02:00
summary:

gh-119182: Add checks to PyUnicodeWriter APIs (#120870)

files:
M Objects/unicodeobject.c

diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c
index 4c174cbc751091..279cdaa668e291 100644
--- a/Objects/unicodeobject.c
+++ b/Objects/unicodeobject.c
@@ -13347,6 +13347,12 @@ _PyUnicodeWriter_Init(_PyUnicodeWriter *writer)
 PyUnicodeWriter*
 PyUnicodeWriter_Create(Py_ssize_t length)
 {
+if (length < 0) {
+PyErr_SetString(PyExc_TypeError,
+"length must be positive");
+return NULL;
+}
+
 const size_t size = sizeof(_PyUnicodeWriter);
 PyUnicodeWriter *pub_writer = (PyUnicodeWriter *)PyMem_Malloc(size);
 if (pub_writer == NULL) {
@@ -13390,6 +13396,7 @@ _PyUnicodeWriter_PrepareInternal(_PyUnicodeWriter 
*writer,
 Py_ssize_t newlen;
 PyObject *newbuffer;
 
+assert(length >= 0);
 assert(maxchar <= MAX_UNICODE);
 
 /* ensure that the _PyUnicodeWriter_Prepare macro was used */
@@ -13501,6 +13508,12 @@ _PyUnicodeWriter_WriteChar(_PyUnicodeWriter *writer, 
Py_UCS4 ch)
 int
 PyUnicodeWriter_WriteChar(PyUnicodeWriter *writer, Py_UCS4 ch)
 {
+if (ch > MAX_UNICODE) {
+PyErr_SetString(PyExc_ValueError,
+"character must be in range(0x11)");
+return -1;
+}
+
 return _PyUnicodeWriter_WriteChar((_PyUnicodeWriter*)writer, ch);
 }
 

___
Python-checkins mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-checkins.python.org/
Member address: [email protected]


[Python-checkins] GH-107803: double linked list implementation for asyncio tasks (GH-107804)

2024-06-22 Thread willingc
https://github.com/python/cpython/commit/4717aaa1a72d1964f1531a7c613f37ce3d9056d9
commit: 4717aaa1a72d1964f1531a7c613f37ce3d9056d9
branch: main
author: Kumar Aditya 
committer: willingc 
date: 2024-06-22T10:58:35-07:00
summary:

GH-107803: double linked list implementation for asyncio tasks (GH-107804)

* linked list

* add tail optmiization to linked list

* wip

* wip

* wip

* more fixes

* finally it works

* add tests

* remove weakreflist

* add some comments

* reduce code duplication in _asynciomodule.c

* address some review comments

* add invariants about the state of the linked list

* add better explanation

* clinic regen

* reorder branches for better branch prediction

* Update Modules/_asynciomodule.c

* Apply suggestions from code review

Co-authored-by: Itamar Oren 

* fix capturing of eager tasks

* add comment to task finalization

* fix tests and couple c implmentation to c task

improved linked-list logic and more comments

* fix test

-

Co-authored-by: Itamar Oren 

files:
M Include/internal/pycore_global_objects_fini_generated.h
M Include/internal/pycore_global_strings.h
M Include/internal/pycore_runtime_init_generated.h
M Include/internal/pycore_unicodeobject_generated.h
M Lib/asyncio/tasks.py
M Lib/test/test_asyncio/test_tasks.py
M Modules/_asynciomodule.c
M Modules/clinic/_asynciomodule.c.h

diff --git a/Include/internal/pycore_global_objects_fini_generated.h 
b/Include/internal/pycore_global_objects_fini_generated.h
index 62e10e2325b8fb..c0840f9eb7eca2 100644
--- a/Include/internal/pycore_global_objects_fini_generated.h
+++ b/Include/internal/pycore_global_objects_fini_generated.h
@@ -899,6 +899,7 @@ _PyStaticObjects_CheckRefcnt(PyInterpreterState *interp) {
 _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(displayhook));
 _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(dklen));
 _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(doc));
+_PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(done));
 _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(dont_inherit));
 _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(dst));
 _PyStaticObject_CheckRefcnt((PyObject *)&_Py_ID(dst_dir_fd));
diff --git a/Include/internal/pycore_global_strings.h 
b/Include/internal/pycore_global_strings.h
index 0e3d1a5a9a9c76..51735a8a726e11 100644
--- a/Include/internal/pycore_global_strings.h
+++ b/Include/internal/pycore_global_strings.h
@@ -388,6 +388,7 @@ struct _Py_global_strings {
 STRUCT_FOR_ID(displayhook)
 STRUCT_FOR_ID(dklen)
 STRUCT_FOR_ID(doc)
+STRUCT_FOR_ID(done)
 STRUCT_FOR_ID(dont_inherit)
 STRUCT_FOR_ID(dst)
 STRUCT_FOR_ID(dst_dir_fd)
diff --git a/Include/internal/pycore_runtime_init_generated.h 
b/Include/internal/pycore_runtime_init_generated.h
index 5b8f29146287a3..c5be67c6d80b9d 100644
--- a/Include/internal/pycore_runtime_init_generated.h
+++ b/Include/internal/pycore_runtime_init_generated.h
@@ -897,6 +897,7 @@ extern "C" {
 INIT_ID(displayhook), \
 INIT_ID(dklen), \
 INIT_ID(doc), \
+INIT_ID(done), \
 INIT_ID(dont_inherit), \
 INIT_ID(dst), \
 INIT_ID(dst_dir_fd), \
diff --git a/Include/internal/pycore_unicodeobject_generated.h 
b/Include/internal/pycore_unicodeobject_generated.h
index 7fa7bb79e21dc6..0e0ad6518771e9 100644
--- a/Include/internal/pycore_unicodeobject_generated.h
+++ b/Include/internal/pycore_unicodeobject_generated.h
@@ -1352,6 +1352,10 @@ _PyUnicode_InitStaticStrings(PyInterpreterState *interp) 
{
 _PyUnicode_InternStatic(interp, &string);
 assert(_PyUnicode_CheckConsistency(string, 1));
 assert(PyUnicode_GET_LENGTH(string) != 1);
+string = &_Py_ID(done);
+_PyUnicode_InternStatic(interp, &string);
+assert(_PyUnicode_CheckConsistency(string, 1));
+assert(PyUnicode_GET_LENGTH(string) != 1);
 string = &_Py_ID(dont_inherit);
 _PyUnicode_InternStatic(interp, &string);
 assert(_PyUnicode_CheckConsistency(string, 1));
diff --git a/Lib/asyncio/tasks.py b/Lib/asyncio/tasks.py
index dadcb5b5f36bd7..cd869931e01409 100644
--- a/Lib/asyncio/tasks.py
+++ b/Lib/asyncio/tasks.py
@@ -1097,14 +1097,14 @@ def _unregister_eager_task(task):
 _py_enter_task = _enter_task
 _py_leave_task = _leave_task
 _py_swap_current_task = _swap_current_task
-
+_py_all_tasks = all_tasks
 
 try:
 from _asyncio import (_register_task, _register_eager_task,
   _unregister_task, _unregister_eager_task,
   _enter_task, _leave_task, _swap_current_task,
   _scheduled_tasks, _eager_tasks, _current_tasks,
-  current_task)
+  current_task, all_tasks)
 except ImportError:
 pass
 else:
@@ -1116,3 +1116,4 @@ def _unregister_eager_task(task):
 _c_enter_task = _enter_task
 _c_leave_task = _leave_task
 _c_swap_current_task = _swap_current_task
+_c_all_tasks = all_tasks
diff --git a/Lib/test/test_asyncio/test_tasks.py 
b/Lib/test/t

[Python-checkins] [3.13] Amend categories of @nineteendo's news entries (GH-120735) (#120850)

2024-06-22 Thread carljm
https://github.com/python/cpython/commit/41b2d199122b22fc1578ce73baf7537c8ed45e84
commit: 41b2d199122b22fc1578ce73baf7537c8ed45e84
branch: 3.13
author: Nice Zombies 
committer: carljm 
date: 2024-06-22T15:05:15-05:00
summary:

[3.13] Amend categories of @nineteendo's news entries (GH-120735) (#120850)

files:
M Misc/NEWS.d/3.13.0a6.rst
M Misc/NEWS.d/3.13.0b1.rst
M Misc/NEWS.d/3.13.0b2.rst

diff --git a/Misc/NEWS.d/3.13.0a6.rst b/Misc/NEWS.d/3.13.0a6.rst
index 4d44bc664ef8b0..fff29083e0dab7 100644
--- a/Misc/NEWS.d/3.13.0a6.rst
+++ b/Misc/NEWS.d/3.13.0a6.rst
@@ -1,25 +1,7 @@
-.. date: 2024-04-08-20-26-15
-.. gh-issue: 117648
-.. nonce: NzVEa7
-.. release date: 2024-04-09
-.. section: Core and Builtins
-
-Improve performance of :func:`os.path.join` and :func:`os.path.expanduser`.
-
-..
-
-.. date: 2024-04-06-16-42-34
-.. gh-issue: 117584
-.. nonce: hqk9Hn
-.. section: Core and Builtins
-
-Raise :exc:`TypeError` for non-paths in :func:`posixpath.relpath()`.
-
-..
-
 .. date: 2024-04-04-13-42-59
 .. gh-issue: 117494
 .. nonce: GPQH64
+.. release date: 2024-04-09
 .. section: Core and Builtins
 
 Refactored the instruction sequence data structure out of compile.c into
@@ -97,33 +79,6 @@ Grigoryev Semyon
 
 ..
 
-.. date: 2024-03-29-21-43-19
-.. gh-issue: 117381
-.. nonce: fT0JFM
-.. section: Core and Builtins
-
-Fix error message for :func:`ntpath.commonpath`.
-
-..
-
-.. date: 2024-03-29-15-04-13
-.. gh-issue: 117349
-.. nonce: OB9kQQ
-.. section: Core and Builtins
-
-Optimise several functions in :mod:`os.path`.
-
-..
-
-.. date: 2024-03-28-19-13-20
-.. gh-issue: 117335
-.. nonce: d6uKJu
-.. section: Core and Builtins
-
-Raise TypeError for non-sequences for :func:`ntpath.commonpath`.
-
-..
-
 .. date: 2024-03-26-17-22-38
 .. gh-issue: 117266
 .. nonce: Kwh79O
@@ -170,16 +125,6 @@ up with growing heaps.
 
 ..
 
-.. date: 2024-03-21-09-57-57
-.. gh-issue: 117114
-.. nonce: Qu-p55
-.. section: Core and Builtins
-
-Make :func:`os.path.isdevdrive` available on all platforms. For those that
-do not offer Dev Drives, it will always return ``False``.
-
-..
-
 .. date: 2024-03-13-16-55-25
 .. gh-issue: 116735
 .. nonce: o3w6y8
@@ -305,6 +250,24 @@ operator. Patch by Pablo Galindo
 
 ..
 
+.. date: 2024-04-08-20-26-15
+.. gh-issue: 117648
+.. nonce: NzVEa7
+.. section: Library
+
+Improve performance of :func:`os.path.join` and :func:`os.path.expanduser`.
+
+..
+
+.. date: 2024-04-06-16-42-34
+.. gh-issue: 117584
+.. nonce: hqk9Hn
+.. section: Library
+
+Raise :exc:`TypeError` for non-paths in :func:`posixpath.relpath()`.
+
+..
+
 .. date: 2024-04-03-18-36-53
 .. gh-issue: 117467
 .. nonce: l6rWlj
@@ -336,6 +299,15 @@ which can happen on Linux >= 2.6.36 with glibc < 2.27.
 
 ..
 
+.. date: 2024-03-29-21-43-19
+.. gh-issue: 117381
+.. nonce: fT0JFM
+.. section: Library
+
+Fix error message for :func:`ntpath.commonpath`.
+
+..
+
 .. date: 2024-03-29-15-58-01
 .. gh-issue: 117337
 .. nonce: 7w3Qwp
@@ -347,6 +319,15 @@ argument instead.
 
 ..
 
+.. date: 2024-03-29-15-04-13
+.. gh-issue: 117349
+.. nonce: OB9kQQ
+.. section: Library
+
+Optimise several functions in :mod:`os.path`.
+
+..
+
 .. date: 2024-03-29-12-07-26
 .. gh-issue: 117348
 .. nonce: WjCYvK
@@ -357,6 +338,15 @@ complexity and improve comprehensibility.
 
 ..
 
+.. date: 2024-03-28-19-13-20
+.. gh-issue: 117335
+.. nonce: d6uKJu
+.. section: Library
+
+Raise TypeError for non-sequences for :func:`ntpath.commonpath`.
+
+..
+
 .. date: 2024-03-28-17-55-22
 .. gh-issue: 66449
 .. nonce: 4jhuEV
@@ -470,6 +460,16 @@ backslashes on Windows.
 
 ..
 
+.. date: 2024-03-21-09-57-57
+.. gh-issue: 117114
+.. nonce: Qu-p55
+.. section: Library
+
+Make :func:`os.path.isdevdrive` available on all platforms. For those that
+do not offer Dev Drives, it will always return ``False``.
+
+..
+
 .. date: 2024-03-21-07-27-36
 .. gh-issue: 117110
 .. nonce: 9K1InX
diff --git a/Misc/NEWS.d/3.13.0b1.rst b/Misc/NEWS.d/3.13.0b1.rst
index 09b62c8377aabd..ab5f24fe345af9 100644
--- a/Misc/NEWS.d/3.13.0b1.rst
+++ b/Misc/NEWS.d/3.13.0b1.rst
@@ -295,16 +295,6 @@ Improve :exc:`SyntaxError` message for empty type param 
brackets.
 
 ..
 
-.. date: 2024-04-19-08-50-48
-.. gh-issue: 102511
-.. nonce: qDEB66
-.. section: Core and Builtins
-
-Fix :func:`os.path.normpath` for UNC paths on Windows.
-Speed up :func:`os.path.splitroot` with a native implementation.
-
-..
-
 .. date: 2024-04-18-03-49-41
 .. gh-issue: 117958
 .. nonce: -EsfUs
@@ -450,33 +440,6 @@ as such regardless of whether they are in extension 
modules or not.
 
 ..
 
-.. date: 2024-04-08-19-30-38
-.. gh-issue: 117641
-.. nonce: oaBGSJ
-.. section: Core and Builtins
-
-Speedup :func:`os.path.commonpath` on Unix.
-
-..
-
-.. date: 2024-04-08-14-33-38
-.. gh-issue: 117636
-.. nonce: exnRKd
-.. section: Core and Builtins
-
-Speedup :func:`os.path.join`.
-
-..
-
-.. date: 2024-04-07-18-42-09
-.. gh-issue: 117607
-.. nonce: C978BD
-.. section: Core and Builtins
-
-Speedup :func:`os.path.relpath`.
-
-..
-
 .. date: 2024-03-30-00-37-53
 ..

[Python-checkins] [3.12] Amend categories of @nineteendo's news entries (GH-120735) (#120736)

2024-06-22 Thread carljm
https://github.com/python/cpython/commit/b64488545f17c6c86d5cb5ba64f55db94d3a08ad
commit: b64488545f17c6c86d5cb5ba64f55db94d3a08ad
branch: 3.12
author: Nice Zombies 
committer: carljm 
date: 2024-06-22T15:05:37-05:00
summary:

[3.12] Amend categories of @nineteendo's news entries (GH-120735) (#120736)

files:
M Misc/NEWS.d/3.12.4.rst

diff --git a/Misc/NEWS.d/3.12.4.rst b/Misc/NEWS.d/3.12.4.rst
index ca3e1bad0c4f86..419228b9fc9a7f 100644
--- a/Misc/NEWS.d/3.12.4.rst
+++ b/Misc/NEWS.d/3.12.4.rst
@@ -41,15 +41,6 @@ when ``globals`` is set to a non-dict. Patch by Jelle 
Zijlstra.
 
 ..
 
-.. date: 2024-05-27-15-22-41
-.. gh-issue: 118263
-.. nonce: QfcDja
-.. section: Core and Builtins
-
-Speed up :func:`os.path.normpath` with a direct C call.
-
-..
-
 .. date: 2024-05-23-06-34-45
 .. gh-issue: 119311
 .. nonce: 2DBwKR
@@ -70,15 +61,6 @@ are in the generic class.
 
 ..
 
-.. date: 2024-05-22-13-51-40
-.. gh-issue: 118507
-.. nonce: xkIQ3v
-.. section: Core and Builtins
-
-Fix :func:`os.path.isfile` on Windows for pipes.
-
-..
-
 .. date: 2024-05-21-11-27-14
 .. gh-issue: 119213
 .. nonce: nxjxrt
@@ -235,6 +217,15 @@ of recursive.
 
 ..
 
+.. date: 2024-05-27-15-22-41
+.. gh-issue: 118263
+.. nonce: QfcDja
+.. section: Library
+
+Speed up :func:`os.path.normpath` with a direct C call.
+
+..
+
 .. date: 2024-05-24-21-54-55
 .. gh-issue: 113892
 .. nonce: JKDFqq
@@ -246,6 +237,15 @@ well as in other loop implementations.
 
 ..
 
+.. date: 2024-05-22-13-51-40
+.. gh-issue: 118507
+.. nonce: xkIQ3v
+.. section: Library
+
+Fix :func:`os.path.isfile` on Windows for pipes.
+
+..
+
 .. date: 2024-05-19-18-49-04
 .. gh-issue: 119174
 .. nonce: 5GTv7d

___
Python-checkins mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-checkins.python.org/
Member address: [email protected]


[Python-checkins] GH-120804: Remove `get_child_watcher` and `set_child_watcher` from asyncio (#120818)

2024-06-22 Thread kumaraditya303
https://github.com/python/cpython/commit/96ead91f0f0db59a942b8b34da9cc980c05588a2
commit: 96ead91f0f0db59a942b8b34da9cc980c05588a2
branch: main
author: Kumar Aditya 
committer: kumaraditya303 
date: 2024-06-23T09:53:23+05:30
summary:

GH-120804: Remove `get_child_watcher` and `set_child_watcher` from asyncio 
(#120818)

files:
M Lib/asyncio/events.py
M Lib/asyncio/unix_events.py
M Lib/test/test_asyncio/test_events.py
M Lib/test/test_asyncio/test_subprocess.py
M Lib/test/test_asyncio/test_unix_events.py
M Lib/test/test_asyncio/utils.py

diff --git a/Lib/asyncio/events.py b/Lib/asyncio/events.py
index be495469a0558b..b63fe6aa79604b 100644
--- a/Lib/asyncio/events.py
+++ b/Lib/asyncio/events.py
@@ -10,7 +10,6 @@
 'Handle', 'TimerHandle',
 'get_event_loop_policy', 'set_event_loop_policy',
 'get_event_loop', 'set_event_loop', 'new_event_loop',
-'get_child_watcher', 'set_child_watcher',
 '_set_running_loop', 'get_running_loop',
 '_get_running_loop',
 )
@@ -652,17 +651,6 @@ def new_event_loop(self):
 the current context, set_event_loop must be called explicitly."""
 raise NotImplementedError
 
-# Child processes handling (Unix only).
-
-def get_child_watcher(self):
-"Get the watcher for child processes."
-raise NotImplementedError
-
-def set_child_watcher(self, watcher):
-"""Set the watcher for child processes."""
-raise NotImplementedError
-
-
 class BaseDefaultEventLoopPolicy(AbstractEventLoopPolicy):
 """Default policy implementation for accessing the event loop.
 
@@ -837,17 +825,6 @@ def new_event_loop():
 return get_event_loop_policy().new_event_loop()
 
 
-def get_child_watcher():
-"""Equivalent to calling get_event_loop_policy().get_child_watcher()."""
-return get_event_loop_policy().get_child_watcher()
-
-
-def set_child_watcher(watcher):
-"""Equivalent to calling
-get_event_loop_policy().set_child_watcher(watcher)."""
-return get_event_loop_policy().set_child_watcher(watcher)
-
-
 # Alias pure-Python implementations for testing purposes.
 _py__get_running_loop = _get_running_loop
 _py__set_running_loop = _set_running_loop
diff --git a/Lib/asyncio/unix_events.py b/Lib/asyncio/unix_events.py
index 9a2e300259ee8c..ff2df653e41b89 100644
--- a/Lib/asyncio/unix_events.py
+++ b/Lib/asyncio/unix_events.py
@@ -199,7 +199,7 @@ async def _make_subprocess_transport(self, protocol, args, 
shell,
  extra=None, **kwargs):
 with warnings.catch_warnings():
 warnings.simplefilter('ignore', DeprecationWarning)
-watcher = events.get_child_watcher()
+watcher = events.get_event_loop_policy()._watcher
 
 with watcher:
 if not watcher.is_active():
@@ -1009,59 +1009,6 @@ def remove_child_handler(self, pid):
 return True
 
 
-class BaseChildWatcher(AbstractChildWatcher):
-
-def __init__(self):
-self._loop = None
-self._callbacks = {}
-
-def close(self):
-self.attach_loop(None)
-
-def is_active(self):
-return self._loop is not None and self._loop.is_running()
-
-def _do_waitpid(self, expected_pid):
-raise NotImplementedError()
-
-def _do_waitpid_all(self):
-raise NotImplementedError()
-
-def attach_loop(self, loop):
-assert loop is None or isinstance(loop, events.AbstractEventLoop)
-
-if self._loop is not None and loop is None and self._callbacks:
-warnings.warn(
-'A loop is being detached '
-'from a child watcher with pending handlers',
-RuntimeWarning)
-
-if self._loop is not None:
-self._loop.remove_signal_handler(signal.SIGCHLD)
-
-self._loop = loop
-if loop is not None:
-loop.add_signal_handler(signal.SIGCHLD, self._sig_chld)
-
-# Prevent a race condition in case a child terminated
-# during the switch.
-self._do_waitpid_all()
-
-def _sig_chld(self):
-try:
-self._do_waitpid_all()
-except (SystemExit, KeyboardInterrupt):
-raise
-except BaseException as exc:
-# self._loop should always be available here
-# as '_sig_chld' is added as a signal handler
-# in 'attach_loop'
-self._loop.call_exception_handler({
-'message': 'Unknown exception in SIGCHLD handler',
-'exception': exc,
-})
-
-
 class ThreadedChildWatcher(AbstractChildWatcher):
 """Threaded child watcher implementation.
 
@@ -1161,15 +1108,10 @@ class 
_UnixDefaultEventLoopPolicy(events.BaseDefaultEventLoopPolicy):
 
 def __init__(self):
 super().__init__()
-self._watcher = None
-
-def _init_watcher(self):
-with events._lock:
-if self._watcher is None:  # pragma: no branch
-if can_use_pidfd():
-self._