From d2eff1832a13a3207b0f4f1bf23b1c74d90d4176 Mon Sep 17 00:00:00 2001 From: John Reese Date: Wed, 27 Jun 2018 13:37:50 -0700 Subject: [PATCH] bpo-33983: Make lib2to3.pytree.Base.children a list The type difference between Base/Leaf (a tuple) and Node (a list) makes it difficult to type check functions that take both, because lists can be used in ways that tuples can't. --- Lib/lib2to3/pytree.py | 2 +- .../next/Library/2018-06-27-13-55-05.bpo-33983.MRbonR.rst | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) create mode 100644 Misc/NEWS.d/next/Library/2018-06-27-13-55-05.bpo-33983.MRbonR.rst diff --git a/Lib/lib2to3/pytree.py b/Lib/lib2to3/pytree.py index 2a6ef2ef5240a2..5a74f8e219c208 100644 --- a/Lib/lib2to3/pytree.py +++ b/Lib/lib2to3/pytree.py @@ -42,7 +42,7 @@ class Base(object): # Default values for instance variables type = None # int: token number (< 256) or symbol number (>= 256) parent = None # Parent node pointer, or None - children = () # Tuple of subnodes + children = [] # List of subnodes was_changed = False was_checked = False diff --git a/Misc/NEWS.d/next/Library/2018-06-27-13-55-05.bpo-33983.MRbonR.rst b/Misc/NEWS.d/next/Library/2018-06-27-13-55-05.bpo-33983.MRbonR.rst new file mode 100644 index 00000000000000..61ce89732f6aab --- /dev/null +++ b/Misc/NEWS.d/next/Library/2018-06-27-13-55-05.bpo-33983.MRbonR.rst @@ -0,0 +1,2 @@ +:class:`lib2to3.pytree.Base` sets the `children` attribute to an empty +list to be more consistent with :class:`lib2to3.pytree.Node`.