Skip to content

Commit 565cf7e

Browse files
committed
address feedback
1 parent 7f35162 commit 565cf7e

File tree

3 files changed

+13
-7
lines changed

3 files changed

+13
-7
lines changed

Lib/test/test_tcl.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -544,13 +544,19 @@ def test_set_object_concurrent_mutation_in_sequence_conversion(self):
544544
# Prevent SIGSEV when the object to convert is concurrently mutated.
545545
# See: https://github.com/python/cpython/issues/143310.
546546

547+
string = "value"
548+
547549
class Value:
548550
def __str__(self):
549551
values.clear()
550-
return "value"
552+
return string
553+
554+
class List(list):
555+
pass
551556

552-
self.passValue(values := [Value(), "pad"])
553-
self.passValue(values := collections.UserList([Value(), "pad"]))
557+
expect = (string, "pad") if self.wantobjects else f"{string} pad"
558+
self.assertEqual(self.passValue(values := [Value(), "pad"]), expect)
559+
self.assertEqual(self.passValue(values := List([Value(), "pad"])), expect)
554560

555561
def test_user_command(self):
556562
result = None
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
:mod:`tkinter`: fix a crash when a Python object is mutated during the
2-
conversion to a Tcl object (e.g., when setting a Tcl variable). Patch by
3-
Bénédikt Tran.
1+
:mod:`tkinter`: fix a crash when a Python :class:`list` is mutated during
2+
the conversion to a Tcl object (e.g., when setting a Tcl variable).
3+
Patch by Bénédikt Tran.

Modules/_tkinter.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1032,7 +1032,7 @@ AsObj(PyObject *value)
10321032
}
10331033

10341034
if (PyList_Check(value)) {
1035-
PyObject *value_as_tuple = PySequence_Tuple(value);
1035+
PyObject *value_as_tuple = PyList_AsTuple(value);
10361036
if (value_as_tuple == NULL) {
10371037
return NULL;
10381038
}

0 commit comments

Comments
 (0)