Skip to content

Commit 924a054

Browse files
committed
Merge pull request #106 from tvincentNuoDB/master
Full python 3 support
2 parents 3e5cb0f + 84fe1d7 commit 924a054

File tree

2 files changed

+7
-13
lines changed

2 files changed

+7
-13
lines changed

pynuodb/encodedsession.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -672,14 +672,18 @@ def getTime(self):
672672

673673
def getOpaque(self):
674674
"""Read the next Opaque value off the session."""
675+
675676
typeCode = self._getTypeCode()
676677

677678
if typeCode in range(protocol.OPAQUELEN0, protocol.OPAQUELEN39 + 1):
678-
return datatype.Binary(self._takeBytes(typeCode - 149))
679-
679+
value = self._takeBytes(typeCode - 149)
680+
return datatype.Binary(value)
680681
if typeCode in range(protocol.OPAQUECOUNT1, protocol.OPAQUECOUNT4 + 1):
681682
strLength = fromByteString(self._takeBytes(typeCode - 72))
682-
return datatype.Binary(self._takeBytes(strLength))
683+
value = self._takeBytes(strLength)
684+
if systemVersion is '3':
685+
value = value.encode('latin-1')
686+
return datatype.Binary(value)
683687

684688
raise DataError('Not an opaque value')
685689

tests/nuodb_blob_test.py

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,6 @@ def test_blob_prepared(self):
1616

1717
binary_data = pack('hhl', 1, 2, 3)
1818

19-
cursor.execute("SELECT ? FROM DUAL", [binary_data])
20-
row = cursor.fetchone()
21-
22-
currentRow = row[0]
23-
if systemVersion is '3':
24-
currentRow = bytes(currentRow, 'latin-1')
25-
array1 = unpack('hhl', currentRow)
26-
self.assertEquals(len(array1), 3)
27-
self.assertEquals(array1[2], 3)
28-
2919
cursor.execute("SELECT ? FROM DUAL", [pynuodb.Binary(binary_data)])
3020
row = cursor.fetchone()
3121

0 commit comments

Comments
 (0)