Skip to content

Commit c33598b

Browse files
author
James William Pye
committed
Don't try to be cute.
1 parent d6eba42 commit c33598b

1 file changed

Lines changed: 6 additions & 9 deletions

File tree

postgresql/test/test_optimized.py

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,23 +7,20 @@
77
from ..port import optimized
88
from ..python.itertools import interlace
99

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-
1610
def pack_tuple(*data,
1711
packH = struct.Struct("!H").pack,
1812
packL = struct.Struct("!L").pack
1913
):
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+
))
2118

2219
tuplemessages = (
2320
(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')),
2522
(b'N', b'fee'),
26-
(b'D', pack_tuple(b'foo', SerializeNULL, b'bar')),
23+
(b'D', pack_tuple(b'foo', None, b'bar')),
2724
(b'D', pack_tuple(b'foo', b'bar')),
2825
)
2926

0 commit comments

Comments
 (0)