diff --git a/Lib/tkinter/test/test_ttk/test_functions.py b/Lib/tkinter/test/test_ttk/test_functions.py index f8e69a9f4165d6..535bcadec7266f 100644 --- a/Lib/tkinter/test/test_ttk/test_functions.py +++ b/Lib/tkinter/test/test_ttk/test_functions.py @@ -348,6 +348,9 @@ def test_it(sspec, value, res_value, states): test_it(('a', 'b', 'c'), MockTclObj('val'), 'val', ('a', 'b', 'c')) + spec = (MockStateSpec('a'), '#fff', MockStateSpec(''), '#ccc') + self.assertEqual(ttk._list_from_statespec(spec), + [('a', '#fff'), ('', '#ccc')]) def test_list_from_layouttuple(self): tk = MockTkApp() diff --git a/Lib/tkinter/ttk.py b/Lib/tkinter/ttk.py index c7c71cd5a559cf..9445e1614fed73 100644 --- a/Lib/tkinter/ttk.py +++ b/Lib/tkinter/ttk.py @@ -251,7 +251,7 @@ def _list_from_statespec(stuple): else: # this is a Tcl object val = str(val) if typename == 'StateSpec': - val = val.split() + val = val.split() if val else '' nval.append(val) it = iter(nval) diff --git a/Misc/NEWS.d/next/Library/2020-11-12-01-08-18.bpo-42328.xs9QXy.rst b/Misc/NEWS.d/next/Library/2020-11-12-01-08-18.bpo-42328.xs9QXy.rst new file mode 100644 index 00000000000000..313b53ee8c4fbf --- /dev/null +++ b/Misc/NEWS.d/next/Library/2020-11-12-01-08-18.bpo-42328.xs9QXy.rst @@ -0,0 +1,2 @@ +Ammend the ttk._list_from_statespec function to correctly return the state +specification for the ttk map when a default state is given.