Author: Antonio Cuni <[email protected]>
Branch: faster-rstruct-2
Changeset: r91235:db941580b490
Date: 2017-05-11 00:58 +0200
http://bitbucket.org/pypy/pypy/changeset/db941580b490/

Log:    rpython fixes

diff --git a/rpython/rlib/rstruct/ieee.py b/rpython/rlib/rstruct/ieee.py
--- a/rpython/rlib/rstruct/ieee.py
+++ b/rpython/rlib/rstruct/ieee.py
@@ -267,18 +267,19 @@
 
 def pack_float(result, pos, x, size, be):
     unsigned = float_pack(x, size)
-    pack_float_to_buffer(result, pos, unsigned, size, be)
+    value = rarithmetic.longlongmask(unsigned)
+    pack_float_to_buffer(result, pos, value, size, be)
 
 @jit.unroll_safe
-def pack_float_to_buffer(result, pos, unsigned, size, be):
+def pack_float_to_buffer(result, pos, value, size, be):
     if be:
         # write in reversed order
         for i in range(size):
-            c = chr((unsigned >> (i * 8)) & 0xFF)
+            c = chr((value >> (i * 8)) & 0xFF)
             result.setitem(pos + size - i - 1, c)
     else:
         for i in range(size):
-            c = chr((unsigned >> (i * 8)) & 0xFF)
+            c = chr((value >> (i * 8)) & 0xFF)
             result.setitem(pos+i, c)
 
 @jit.unroll_safe
diff --git a/rpython/rlib/rstruct/standardfmttable.py 
b/rpython/rlib/rstruct/standardfmttable.py
--- a/rpython/rlib/rstruct/standardfmttable.py
+++ b/rpython/rlib/rstruct/standardfmttable.py
@@ -49,6 +49,7 @@
             for i in range(count - len(string)):
                 fmtiter.result.setitem(pos+i, '\x00')
     else:
+        assert count >= 0
         fmtiter.result.setslice(pos, string[:count])
     fmtiter.advance(count)
 
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to