Skip to content

Commit 4c28217

Browse files
Sungmin-Joocorona10
authored andcommitted
Fix bug in "items" function (#115)
* Fix bug in "items" function Fixes #101 * Update dict.py
1 parent efe8d6a commit 4c28217

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

py/dict.go

+4
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,10 @@ var (
2929

3030
func init() {
3131
StringDictType.Dict["items"] = MustNewMethod("items", func(self Object, args Tuple) (Object, error) {
32+
err := UnpackTuple(args, nil, "items", 0, 0)
33+
if err != nil {
34+
return nil, err
35+
}
3236
sMap := self.(StringDict)
3337
o := make([]Object, 0, len(sMap))
3438
for k, v := range sMap {

py/tests/dict.py

+2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# Copyright 2018 The go-python Authors. All rights reserved.
22
# Use of this source code is governed by a BSD-style
33
# license that can be found in the LICENSE file.
4+
from libtest import assertRaises
45

56
doc="str"
67
assert str({}) == "{}"
@@ -35,6 +36,7 @@
3536
assert v == "b"
3637
if k == "c":
3738
assert v == 5.5
39+
assertRaises(TypeError, a.items, 'a')
3840

3941
doc="__contain__"
4042
a = {'hello': 'world'}

0 commit comments

Comments
 (0)