Repair errors surfaced by the new tests
This commit is contained in:
parent
a14b2d49b7
commit
c30073c3f9
|
@ -282,6 +282,14 @@ class Parser(TextCodec):
|
|||
return tuple(vs)
|
||||
vs.append(self.next())
|
||||
|
||||
def read_set(self):
|
||||
items = self.upto('}')
|
||||
s = set()
|
||||
for i in items:
|
||||
if i in s: raise DecodeError('Duplicate value in set: ' + repr(i))
|
||||
s.add(i)
|
||||
return frozenset(s)
|
||||
|
||||
def read_dictionary(self):
|
||||
acc = []
|
||||
while True:
|
||||
|
@ -344,7 +352,7 @@ class Parser(TextCodec):
|
|||
c = self.nextchar()
|
||||
if c == 'f': return self.wrap(False)
|
||||
if c == 't': return self.wrap(True)
|
||||
if c == '{': return self.wrap(frozenset(self.upto('}')))
|
||||
if c == '{': return self.wrap(self.read_set())
|
||||
if c == '"': return self.wrap(self.read_literal_binary())
|
||||
if c == 'x':
|
||||
c = self.nextchar()
|
||||
|
|
|
@ -509,6 +509,8 @@ class ImmutableDict(dict):
|
|||
v = next(i)
|
||||
except StopIteration:
|
||||
raise DecodeError("Missing dictionary value")
|
||||
if k in result:
|
||||
raise DecodeError("Duplicate key: " + repr(k))
|
||||
result_proxy.__setitem__(k, v)
|
||||
except StopIteration:
|
||||
pass
|
||||
|
|
Loading…
Reference in New Issue