There was an error while loading. Please reload this page.
1 parent b7ac6e3 commit 5b155baCopy full SHA for 5b155ba
1 file changed
postgresql/encodings/bytea.py
@@ -4,6 +4,7 @@
4
'PostgreSQL bytea encoding and decoding functions'
5
import codecs
6
import struct
7
+import sys
8
9
ord_to_seq = {
10
i : \
@@ -12,8 +13,14 @@
12
13
if i == 92 else chr(i)
14
for i in range(256)
15
}
-def decode(data):
16
- return ''.join(map(ord_to_seq.__getitem__, (data[x][0] for x in range(len(data)))))
+
17
+if sys.version_info[:2] >= (3, 3):
18
+ # Subscripting memory in 3.3 returns byte as an integer, not as a bytestring
19
+ def decode(data):
20
+ return ''.join(map(ord_to_seq.__getitem__, (data[x] for x in range(len(data)))))
21
+else:
22
23
+ return ''.join(map(ord_to_seq.__getitem__, (data[x][0] for x in range(len(data)))))
24
25
def encode(data):
26
diter = ((data[i] for i in range(len(data))))
0 commit comments