diff options
author | Lars Haulin <lars.haulin@gmail.com> | 2022-07-08 17:48:40 +0200 |
---|---|---|
committer | Damien George <damien@micropython.org> | 2022-07-13 16:25:35 +1000 |
commit | 5bf3765631e645412dbd62a616cfdadeca5ea0c3 (patch) | |
tree | c8da4965e5391990e111162603dbfedc288c6a58 /tests/basics/namedtuple1.py | |
parent | 2076f2efccfd86977f63de15958c142365c31f3b (diff) |
py/objnamedtuple: Fix segfault with empty namedtuple.
The empty tuple is usually a constant object, but named tuples must be
allocated to allow modification. Added explicit allocation to fix this.
Also added a regression test to verify creating an empty named tuple works.
Fixes issue #7870.
Signed-off-by: Lars Haulin <lars.haulin@gmail.com>
Diffstat (limited to 'tests/basics/namedtuple1.py')
-rw-r--r-- | tests/basics/namedtuple1.py | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/tests/basics/namedtuple1.py b/tests/basics/namedtuple1.py index 47c0360eb..e8247e4d6 100644 --- a/tests/basics/namedtuple1.py +++ b/tests/basics/namedtuple1.py @@ -85,3 +85,8 @@ print(t.foo, t.bar) # Not implemented so far #T2 = namedtuple("TupComma", "foo,bar") #t = T2(1, 2) + +# Creating an empty namedtuple should not segfault +T5 = namedtuple("TupEmpty", []) +t = T5() +print(t) |