Skip to content

Commit

Permalink
starlark: dict(None) and dict.update(None) are errors (google#129)
Browse files Browse the repository at this point in the history
  • Loading branch information
adonovan authored Jan 30, 2019
1 parent 2f3bb7c commit 367b72a
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 0 additions & 2 deletions starlark/library.go
Original file line number Diff line number Diff line change
Expand Up @@ -2178,8 +2178,6 @@ func string_find_impl(fnname string, s string, args Tuple, kwargs []Tuple, allow
func updateDict(dict *Dict, updates Tuple, kwargs []Tuple) error {
if len(updates) == 1 {
switch updates := updates[0].(type) {
case NoneType:
// no-op
case IterableMapping:
// Iterate over dict's key/value pairs, not just keys.
for _, item := range updates.Items() {
Expand Down
4 changes: 4 additions & 0 deletions starlark/testdata/dict.star
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,10 @@ def test_delete():

test_delete()

# Regression test for github.com/google/starlark-go/issues/128.
assert.fails(lambda: dict(None), 'got NoneType, want iterable')
assert.fails(lambda: {}.update(None), 'got NoneType, want iterable')

---
# Verify position of an "unhashable key" error in a dict literal.

Expand Down

0 comments on commit 367b72a

Please sign in to comment.