From f64b79f461e49adbb8dda91d10cb5d8060b65e9e Mon Sep 17 00:00:00 2001 From: Sungmin-Joo Date: Sun, 6 Oct 2019 16:52:13 +0900 Subject: [PATCH 1/2] Fix bug in "items" function Fixes #101 --- py/dict.go | 4 ++++ py/tests/dict.py | 2 ++ 2 files changed, 6 insertions(+) diff --git a/py/dict.go b/py/dict.go index 61b6e5cd..41b958f6 100644 --- a/py/dict.go +++ b/py/dict.go @@ -29,6 +29,10 @@ var ( func init() { StringDictType.Dict["items"] = MustNewMethod("items", func(self Object, args Tuple) (Object, error) { + err := UnpackTuple(args, nil, "items", 0, 0) + if err != nil { + return nil, err + } sMap := self.(StringDict) o := make([]Object, 0, len(sMap)) for k, v := range sMap { diff --git a/py/tests/dict.py b/py/tests/dict.py index 1fa317c3..462d77bb 100644 --- a/py/tests/dict.py +++ b/py/tests/dict.py @@ -1,6 +1,7 @@ # Copyright 2018 The go-python Authors. All rights reserved. # Use of this source code is governed by a BSD-style # license that can be found in the LICENSE file. +from libtest import assertRaises doc="str" assert str({}) == "{}" @@ -35,6 +36,7 @@ assert v == "b" if k == "c": assert v == 5.5 +assertRaises(TypeError,a.items,'a') doc="__contain__" a = {'hello': 'world'} From af0b47315993a7f1eec2c25a86c31a1d823bba3a Mon Sep 17 00:00:00 2001 From: Sung-Min Joo Date: Wed, 9 Oct 2019 09:39:30 +0900 Subject: [PATCH 2/2] Update dict.py --- py/tests/dict.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/py/tests/dict.py b/py/tests/dict.py index 462d77bb..5f1d0a64 100644 --- a/py/tests/dict.py +++ b/py/tests/dict.py @@ -36,7 +36,7 @@ assert v == "b" if k == "c": assert v == 5.5 -assertRaises(TypeError,a.items,'a') +assertRaises(TypeError, a.items, 'a') doc="__contain__" a = {'hello': 'world'}