|
21 | 21 | from .result_set import ResultSet |
22 | 22 |
|
23 | 23 | systemVersion = sys.version[0] |
24 | | - |
| 24 | +REMOVE_FORMAT = 0 |
25 | 25 | class EncodedSession(Session): |
26 | 26 | """Class for representing an encoded session with the database. |
27 | 27 | |
@@ -394,10 +394,10 @@ def putScaledInt(self, value): |
394 | 394 | @type value decimal.Decimal |
395 | 395 | """ |
396 | 396 | #Convert the decimal's notation into decimal |
397 | | - value += 0 |
| 397 | + value += REMOVE_FORMAT |
398 | 398 | scale = abs(value.as_tuple()[2]) |
399 | 399 | valueStr = toSignedByteString(int(value * decimal.Decimal(10**scale))) |
400 | | - |
| 400 | + |
401 | 401 | #If our length is more than 9 bytes we will need to send the data using ScaledCount2 |
402 | 402 | if len(valueStr) > 9: |
403 | 403 | return self.putScaledCount2(value) |
@@ -640,8 +640,9 @@ def getDouble(self): |
640 | 640 | if typeCode < protocol.DOUBLELEN8: |
641 | 641 | for i in range(0, protocol.DOUBLELEN8 - typeCode): |
642 | 642 | 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 |
645 | 646 | return struct.unpack('!d', test)[0] |
646 | 647 |
|
647 | 648 | raise DataError('Not a double') |
|
0 commit comments