@@ -702,7 +702,7 @@ def allot(
702
702
>>> allot(1.23)
703
703
Traceback (most recent call last):
704
704
...
705
- TypeError: integer, boolean, string, list, or dictionary expected
705
+ TypeError: integer, boolean, string, list, dictionary, or None expected
706
706
>>> allot({'id': 0, 'age': {'$allot': [1, 2, 3], 'extra': [1, 2, 3]}})
707
707
Traceback (most recent call last):
708
708
...
@@ -716,8 +716,8 @@ def allot(
716
716
...
717
717
ValueError: number of shares in subdocument is not consistent
718
718
"""
719
- # Return a single share for integer and string values .
720
- if isinstance (document , (int , bool , str )):
719
+ # Values and ``None`` are base cases; return a single share .
720
+ if isinstance (document , (int , bool , str )) or document is None :
721
721
return [document ]
722
722
723
723
if isinstance (document , list ):
@@ -791,7 +791,7 @@ def allot(
791
791
return shares
792
792
793
793
raise TypeError (
794
- 'integer, boolean, string, list, or dictionary expected'
794
+ 'integer, boolean, string, list, dictionary, or None expected'
795
795
)
796
796
797
797
def unify (
@@ -830,11 +830,13 @@ def unify(
830
830
>>> data = {
831
831
... 'a': [1, [2, 3]],
832
832
... 'b': [4, 5, 6],
833
+ ... 'c': None
833
834
... }
834
835
>>> sk = SecretKey.generate({'nodes': [{}, {}, {}]}, {'store': True})
835
836
>>> encrypted = {
836
837
... 'a': {'$allot': [encrypt(sk, 1), [encrypt(sk, 2), encrypt(sk, 3)]]},
837
- ... 'b': {'$allot': [encrypt(sk, 4), encrypt(sk, 5), encrypt(sk, 6)]}
838
+ ... 'b': {'$allot': [encrypt(sk, 4), encrypt(sk, 5), encrypt(sk, 6)]},
839
+ ... 'c': None
838
840
... }
839
841
>>> shares = allot(encrypted)
840
842
>>> decrypted = unify(sk, shares)
0 commit comments