|
7 | 7 | from ..port import optimized |
8 | 8 | from ..python.itertools import interlace |
9 | 9 |
|
10 | | -# Curious... Seems too dangerous for real use.. |
11 | | -class SerializeNULL_Type(bytes): |
12 | | - def __len__(self): |
13 | | - return 0xFFFFFFFF |
14 | | -SerializeNULL = SerializeNULL_Type(b'') |
15 | | - |
16 | 10 | def pack_tuple(*data, |
17 | 11 | packH = struct.Struct("!H").pack, |
18 | 12 | packL = struct.Struct("!L").pack |
19 | 13 | ): |
20 | | - return packH(len(data)) + b''.join(interlace(map(packL, map(len, data)), data)) |
| 14 | + return packH(len(data)) + b''.join(( |
| 15 | + packL(len(x)) + x if x is not None else b'\xff\xff\xff\xff' |
| 16 | + for x in data |
| 17 | + )) |
21 | 18 |
|
22 | 19 | tuplemessages = ( |
23 | 20 | (b'D', pack_tuple(b'foo', b'bar')), |
24 | | - (b'D', pack_tuple(b'foo', SerializeNULL, b'bar')), |
| 21 | + (b'D', pack_tuple(b'foo', None, b'bar')), |
25 | 22 | (b'N', b'fee'), |
26 | | - (b'D', pack_tuple(b'foo', SerializeNULL, b'bar')), |
| 23 | + (b'D', pack_tuple(b'foo', None, b'bar')), |
27 | 24 | (b'D', pack_tuple(b'foo', b'bar')), |
28 | 25 | ) |
29 | 26 |
|
|
0 commit comments