Skip to content

Commit 8b50611

Browse files
committed
Fixed python 3 return values in getDouble
1 parent 1bbd332 commit 8b50611

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

pynuodb/encodedsession.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
from .result_set import ResultSet
2222

2323
systemVersion = sys.version[0]
24-
24+
REMOVE_FORMAT = 0
2525
class EncodedSession(Session):
2626
"""Class for representing an encoded session with the database.
2727
@@ -394,10 +394,10 @@ def putScaledInt(self, value):
394394
@type value decimal.Decimal
395395
"""
396396
#Convert the decimal's notation into decimal
397-
value += 0
397+
value += REMOVE_FORMAT
398398
scale = abs(value.as_tuple()[2])
399399
valueStr = toSignedByteString(int(value * decimal.Decimal(10**scale)))
400-
400+
401401
#If our length is more than 9 bytes we will need to send the data using ScaledCount2
402402
if len(valueStr) > 9:
403403
return self.putScaledCount2(value)
@@ -640,8 +640,9 @@ def getDouble(self):
640640
if typeCode < protocol.DOUBLELEN8:
641641
for i in range(0, protocol.DOUBLELEN8 - typeCode):
642642
test = test + chr(0)
643-
if systemVersion is '3':
644-
return struct.unpack('!d', bytes(test, 'latin-1'))
643+
if systemVersion is '3':
644+
#Python 3 returns an array, we want the 0th element and remove form
645+
return struct.unpack('!d', bytes(test, 'latin-1'))[0] + REMOVE_FORMAT
645646
return struct.unpack('!d', test)[0]
646647

647648
raise DataError('Not a double')

0 commit comments

Comments
 (0)