Changeset 1146
- Timestamp:
- 03/25/08 02:32:07 (2 years ago)
- Location:
- pyamf/trunk/pyamf
- Files:
-
- 4 modified
-
amf0.py (modified) (1 diff)
-
tests/test_amf0.py (modified) (1 diff)
-
tests/test_util.py (modified) (2 diffs)
-
util.py (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
pyamf/trunk/pyamf/amf0.py
r1101 r1146 221 221 @rtype: C{int} or C{float} 222 222 """ 223 x = self.stream.read_double() 224 225 return _check_for_int(x) 223 return _check_for_int(self.stream.read_double()) 226 224 227 225 def readBoolean(self): -
pyamf/trunk/pyamf/tests/test_amf0.py
r1101 r1146 499 499 self.buf.seek(0) 500 500 x = self.decoder.readElement() 501 502 501 self.assertTrue(fpconst.isNaN(x)) 503 502 -
pyamf/trunk/pyamf/tests/test_util.py
r1145 r1146 273 273 util.StringIOProxy._wrapped_class = StringIO 274 274 275 class ByteStream(util.StringIOProxy, util. NetworkIOMixIn):275 class ByteStream(util.StringIOProxy, util.DataTypeMixIn): 276 276 pass 277 277 … … 415 415 x = ByteStream() 416 416 417 self._write_endian(x, x.write_utf8_string, (u'ᚠᛇᚻ',), ( 418 '\xe1\x9a\xa0\xe1\x9b\x87\xe1\x9a\xbb', '\xe1\x9a\xa0\xe1\x9b\x87\xe1\x9a\xbb')) 417 self._write_endian(x, x.write_utf8_string, (u'ᚠᛇᚻ',), ['\xe1\x9a\xa0\xe1\x9b\x87\xe1\x9a\xbb'] * 2) 419 418 420 419 def test_read_utf8_string(self): -
pyamf/trunk/pyamf/util.py
r1145 r1146 532 532 import fpconst 533 533 534 fp = struct.unpack("!d", '\xff\xf8\x00\x00\x00\x00\x00\x00')[0] 535 536 if not fpconst.isNaN(fp): 537 def read_float_workaround(self): 534 if not fpconst.isNaN(struct.unpack("!d", '\xff\xf8\x00\x00\x00\x00\x00\x00')[0]): 535 def read_double_workaround(self): 538 536 bytes = self._read(8) 539 537 … … 547 545 return fpconst.PosInf 548 546 549 return struct.unpack(" !d", bytes)[0]550 551 NetworkIOMixIn.read_double = read_float_workaround552 553 def write_ float_workaround(self, d):547 return struct.unpack("%sd" % self.endian, bytes)[0] 548 549 DataTypeMixIn.read_double = read_double_workaround 550 551 def write_double_workaround(self, d): 554 552 if fpconst.isNaN(d): 555 553 self.write('\xff\xf8\x00\x00\x00\x00\x00\x00') … … 559 557 self.write('\x7f\xf0\x00\x00\x00\x00\x00\x00') 560 558 else: 561 write_float_workaround.old_func(self, d) 562 563 x = NetworkIOMixIn.write_double 564 NetworkIOMixIn.write_double = write_float_workaround 565 write_float_workaround.old_func = x 566 567 del fp 559 write_double_workaround.old_func(self, d) 560 561 x = DataTypeMixIn.write_double 562 DataTypeMixIn.write_double = write_double_workaround 563 write_double_workaround.old_func = x
