[pypy-commit] pypy py3.5: fix merge issues

2017-09-04 Thread rlamy
Author: Ronan Lamy 
Branch: py3.5
Changeset: r92316:2db2c4a66195
Date: 2017-09-04 14:51 +0100
http://bitbucket.org/pypy/pypy/changeset/2db2c4a66195/

Log:fix merge issues

diff --git a/lib-python/3/ctypes/test/test_byteswap.py 
b/lib-python/3/ctypes/test/test_byteswap.py
--- a/lib-python/3/ctypes/test/test_byteswap.py
+++ b/lib-python/3/ctypes/test/test_byteswap.py
@@ -2,7 +2,6 @@
 from binascii import hexlify
 
 from ctypes import *
-from ctypes.test import xfail
 
 def bin(s):
 return hexlify(memoryview(s)).decode().upper()
@@ -43,7 +42,6 @@
 with self.assertRaises(AttributeError):
 little.z = 24
 
-@xfail
 def test_endian_short(self):
 if sys.byteorder == "little":
 self.assertIs(c_short.__ctype_le__, c_short)
@@ -71,7 +69,6 @@
 self.assertEqual(bin(s), "3412")
 self.assertEqual(s.value, 0x1234)
 
-@xfail
 def test_endian_int(self):
 if sys.byteorder == "little":
 self.assertIs(c_int.__ctype_le__, c_int)
@@ -100,7 +97,6 @@
 self.assertEqual(bin(s), "78563412")
 self.assertEqual(s.value, 0x12345678)
 
-@xfail
 def test_endian_longlong(self):
 if sys.byteorder == "little":
 self.assertIs(c_longlong.__ctype_le__, c_longlong)
@@ -129,7 +125,6 @@
 self.assertEqual(bin(s), "EFCDAB9078563412")
 self.assertEqual(s.value, 0x1234567890ABCDEF)
 
-@xfail
 def test_endian_float(self):
 if sys.byteorder == "little":
 self.assertIs(c_float.__ctype_le__, c_float)
@@ -148,7 +143,6 @@
 self.assertAlmostEqual(s.value, math.pi, places=6)
 self.assertEqual(bin(struct.pack(">f", math.pi)), bin(s))
 
-@xfail
 def test_endian_double(self):
 if sys.byteorder == "little":
 self.assertIs(c_double.__ctype_le__, c_double)
@@ -176,7 +170,6 @@
 self.assertIs(c_char.__ctype_le__, c_char)
 self.assertIs(c_char.__ctype_be__, c_char)
 
-@xfail
 def test_struct_fields_1(self):
 if sys.byteorder == "little":
 base = BigEndianStructure
@@ -212,7 +205,6 @@
 pass
 self.assertRaises(TypeError, setattr, T, "_fields_", [("x", typ)])
 
-@xfail
 def test_struct_struct(self):
 # nested structures with different byteorders
 
@@ -241,7 +233,6 @@
 self.assertEqual(s.point.x, 1)
 self.assertEqual(s.point.y, 2)
 
-@xfail
 def test_struct_fields_2(self):
 # standard packing in struct uses no alignment.
 # So, we have to align using pad bytes.
@@ -265,7 +256,6 @@
 s2 = struct.pack(fmt, 0x12, 0x1234, 0x12345678, 3.14)
 self.assertEqual(bin(s1), bin(s2))
 
-@xfail
 def test_unaligned_nonnative_struct_fields(self):
 if sys.byteorder == "little":
 base = BigEndianStructure
diff --git a/lib_pypy/_ctypes/primitive.py b/lib_pypy/_ctypes/primitive.py
--- a/lib_pypy/_ctypes/primitive.py
+++ b/lib_pypy/_ctypes/primitive.py
@@ -72,13 +72,13 @@
((value >> 24) & 0xFF)
 
 def swap_8():
-return ((value & 0x00FFL) << 56) | \
-   ((value & 0xFF00L) << 40) | \
-   ((value & 0x00FFL) << 24) | \
-   ((value & 0xFF00L) << 8) | \
-   ((value & 0x00FFL) >> 8) | \
-   ((value & 0xFF00L) >> 24) | \
-   ((value & 0x00FFL) >> 40) | \
+return ((value & 0x00FF) << 56) | \
+   ((value & 0xFF00) << 40) | \
+   ((value & 0x00FF) << 24) | \
+   ((value & 0xFF00) << 8) | \
+   ((value & 0x00FF) >> 8) | \
+   ((value & 0xFF00) >> 24) | \
+   ((value & 0x00FF) >> 40) | \
((value >> 56) & 0xFF)
 
 def swap_double_float(typ):
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy py3.5: fix merge issues: before the merge, the code (not the tests) was

2017-02-19 Thread arigo
Author: Armin Rigo 
Branch: py3.5
Changeset: r90195:0f157eedb3b2
Date: 2017-02-19 12:36 +0100
http://bitbucket.org/pypy/pypy/changeset/0f157eedb3b2/

Log:fix merge issues: before the merge, the code (not the tests) was
identical in pypy2 and pypy3, so just make it identical again

diff --git a/pypy/module/cppyy/converter.py b/pypy/module/cppyy/converter.py
--- a/pypy/module/cppyy/converter.py
+++ b/pypy/module/cppyy/converter.py
@@ -771,6 +771,7 @@
 for c_type, names, c_tc in type_info:
 class BasicConverter(ffitypes.typeid(c_type), IntTypeConverterMixin, 
TypeConverter):
 _immutable_ = True
+typecode = c_tc
 def __init__(self, space, default):
 self.default = rffi.cast(self.c_type, capi.c_strtoll(space, 
default))
 class ConstRefConverter(ConstRefNumericTypeConverterMixin, 
BasicConverter):
diff --git a/pypy/module/cppyy/ffitypes.py b/pypy/module/cppyy/ffitypes.py
--- a/pypy/module/cppyy/ffitypes.py
+++ b/pypy/module/cppyy/ffitypes.py
@@ -2,6 +2,7 @@
 
 from rpython.rtyper.lltypesystem import rffi
 from rpython.rlib.rarithmetic import r_singlefloat, r_longfloat
+from rpython.rlib.rbigint import rbigint
 
 from pypy.module._cffi_backend import newtype
 
@@ -41,7 +42,6 @@
 self.c_size_t= nt.new_primitive_type(space, 'size_t')
 self.c_ptrdiff_t = nt.new_primitive_type(space, 'ptrdiff_t')
 
-
 class BoolTypeMixin(object):
 _mixin_ = True
 _immutable_fields_ = ['c_type', 'c_ptrtype']
@@ -49,6 +49,9 @@
 c_type  = rffi.UCHAR
 c_ptrtype   = rffi.UCHARP
 
+def _wrap_object(self, space, obj):
+return space.newbool(bool(ord(rffi.cast(rffi.CHAR, obj
+
 def _unwrap_object(self, space, w_obj):
 arg = space.c_int_w(w_obj)
 if arg != False and arg != True:
@@ -56,9 +59,6 @@
 "boolean value should be bool, or integer 1 or 0")
 return arg
 
-def _wrap_object(self, space, obj):
-return space.newbool(bool(ord(rffi.cast(rffi.CHAR, obj
-
 def cffi_type(self, space):
 state = space.fromcache(State)
 return state.c_bool
@@ -93,44 +93,44 @@
 state = space.fromcache(State)
 return state.c_char
 
-class ShortTypeMixin(object):
+class BaseIntTypeMixin(object):
+_mixin_ = True
+
+def _wrap_object(self, space, obj):
+return space.newint(rffi.cast(rffi.INT, obj))
+
+def _unwrap_object(self, space, w_obj):
+return rffi.cast(self.c_type, space.c_int_w(w_obj))
+
+class ShortTypeMixin(BaseIntTypeMixin):
 _mixin_ = True
 _immutable_fields_ = ['c_type', 'c_ptrtype']
 
 c_type  = rffi.SHORT
 c_ptrtype   = rffi.SHORTP
 
-def _unwrap_object(self, space, w_obj):
-return rffi.cast(rffi.SHORT, space.int_w(w_obj))
-
+class UShortTypeMixin(BaseIntTypeMixin):
 def cffi_type(self, space):
 state = space.fromcache(State)
 return state.c_short
 
-class UShortTypeMixin(object):
 _mixin_ = True
 _immutable_fields_ = ['c_type', 'c_ptrtype']
 
 c_type  = rffi.USHORT
 c_ptrtype   = rffi.USHORTP
 
-def _unwrap_object(self, space, w_obj):
-return rffi.cast(self.c_type, space.int_w(w_obj))
-
+class IntTypeMixin(BaseIntTypeMixin):
 def cffi_type(self, space):
 state = space.fromcache(State)
 return state.c_ushort
 
-class IntTypeMixin(object):
 _mixin_ = True
 _immutable_fields_ = ['c_type', 'c_ptrtype']
 
 c_type  = rffi.INT
 c_ptrtype   = rffi.INTP
 
-def _unwrap_object(self, space, w_obj):
-return rffi.cast(self.c_type, space.c_int_w(w_obj))
-
 def cffi_type(self, space):
 state = space.fromcache(State)
 return state.c_int
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit