Key can not "contain" the string, but key can be the string.
if isinstance(v, dict):
raws = [_byte(TagMap)]
if not all(isinstance(k, str) for k in v.keys()):
- raise ValueError("map keys can contain only strings")
+ raise ValueError("map keys can be only strings")
for k in sorted(v.keys(), key=LenFirstSort):
if len(k) == 0:
raise ValueError("map keys can not be empty")
def test_throws_when_encoding_non_string_key(self):
with self.assertRaises(ValueError) as err:
dumps({1: "a"})
- self.assertEqual(str(err.exception), "map keys can contain only strings")
+ self.assertEqual(str(err.exception), "map keys can be only strings")
def test_throws_when_decoding_non_string_key(self):
encoded = b"\x09\x0c\x80\xc6value2\x00"