Author: Armin Rigo <[email protected]>
Branch: null_byte_after_str
Changeset: r85923:714c68f9914e
Date: 2016-07-30 10:55 +0200
http://bitbucket.org/pypy/pypy/changeset/714c68f9914e/
Log: merge default
diff --git a/pypy/module/cpyext/slotdefs.py b/pypy/module/cpyext/slotdefs.py
--- a/pypy/module/cpyext/slotdefs.py
+++ b/pypy/module/cpyext/slotdefs.py
@@ -381,6 +381,7 @@
('tp_as_number.c_nb_invert', '__invert__'),
('tp_as_number.c_nb_index', '__index__'),
('tp_as_number.c_nb_hex', '__hex__'),
+ ('tp_as_number.c_nb_oct', '__oct__'),
('tp_str', '__str__'),
('tp_repr', '__repr__'),
('tp_iter', '__iter__'),
diff --git a/pypy/module/cpyext/test/test_longobject.py
b/pypy/module/cpyext/test/test_longobject.py
--- a/pypy/module/cpyext/test/test_longobject.py
+++ b/pypy/module/cpyext/test/test_longobject.py
@@ -259,8 +259,19 @@
ret = PyLong_FromLong(-1);
Py_DECREF(obj);
return ret;
+ """),
+ ("has_oct", "METH_NOARGS",
+ """
+ PyObject *ret, *obj = PyLong_FromLong(42);
+ if (obj->ob_type->tp_as_number->nb_oct)
+ ret = obj->ob_type->tp_as_number->nb_oct(obj);
+ else
+ ret = PyLong_FromLong(-1);
+ Py_DECREF(obj);
+ return ret;
""")])
assert module.has_sub() == 0
assert module.has_pow() == 0
assert module.has_hex() == '0x2aL'
+ assert module.has_oct() == '052L'
diff --git a/pypy/objspace/std/test/test_stdobjspace.py
b/pypy/objspace/std/test/test_stdobjspace.py
--- a/pypy/objspace/std/test/test_stdobjspace.py
+++ b/pypy/objspace/std/test/test_stdobjspace.py
@@ -66,17 +66,18 @@
def test_wrap_various_unsigned_types(self):
import sys
+ from rpython.rlib.rarithmetic import r_uint
from rpython.rtyper.lltypesystem import lltype, rffi
space = self.space
value = sys.maxint * 2
- x = rffi.cast(lltype.Unsigned, value)
+ x = r_uint(value)
assert space.eq_w(space.wrap(value), space.wrap(x))
- x = rffi.cast(rffi.UINTPTR_T, value)
+ x = rffi.cast(rffi.UINTPTR_T, r_uint(value))
assert x > 0
assert space.eq_w(space.wrap(value), space.wrap(x))
value = 60000
- x = rffi.cast(rffi.USHORT, value)
+ x = rffi.cast(rffi.USHORT, r_uint(value))
assert space.eq_w(space.wrap(value), space.wrap(x))
value = 200
- x = rffi.cast(rffi.UCHAR, value)
+ x = rffi.cast(rffi.UCHAR, r_uint(value))
assert space.eq_w(space.wrap(value), space.wrap(x))
diff --git a/rpython/jit/backend/x86/test/test_regloc.py
b/rpython/jit/backend/x86/test/test_regloc.py
--- a/rpython/jit/backend/x86/test/test_regloc.py
+++ b/rpython/jit/backend/x86/test/test_regloc.py
@@ -147,7 +147,7 @@
py.test.skip()
def test_reuse_scratch_register(self):
- base_addr = 0xFEDCBA9876543210
+ base_addr = intmask(0xFEDCBA9876543210)
cb = LocationCodeBuilder64()
cb.begin_reuse_scratch_register()
cb.MOV(ecx, heap(base_addr))
@@ -167,7 +167,7 @@
# ------------------------------------------------------------
def test_64bit_address_1(self):
- base_addr = 0xFEDCBA9876543210
+ base_addr = intmask(0xFEDCBA9876543210)
cb = LocationCodeBuilder64()
cb.CMP(ecx, AddressLoc(ImmedLoc(0), ImmedLoc(0), 0, base_addr))
# this case is a CMP_rj
@@ -181,7 +181,7 @@
assert cb.getvalue() == expected_instructions
def test_64bit_address_2(self):
- base_addr = 0xFEDCBA9876543210
+ base_addr = intmask(0xFEDCBA9876543210)
cb = LocationCodeBuilder64()
cb.MOV(ecx, AddressLoc(ImmedLoc(0), edx, 3, base_addr))
# this case is a CMP_ra
@@ -195,7 +195,7 @@
assert cb.getvalue() == expected_instructions
def test_64bit_address_3(self):
- base_addr = 0xFEDCBA9876543210
+ base_addr = intmask(0xFEDCBA9876543210)
cb = LocationCodeBuilder64()
cb.MOV(ecx, AddressLoc(edx, ImmedLoc(0), 0, base_addr))
# this case is a CMP_rm
@@ -211,7 +211,7 @@
assert cb.getvalue() == expected_instructions
def test_64bit_address_4(self):
- base_addr = 0xFEDCBA9876543210
+ base_addr = intmask(0xFEDCBA9876543210)
cb = LocationCodeBuilder64()
cb.begin_reuse_scratch_register()
assert cb._reuse_scratch_register is True
@@ -234,7 +234,7 @@
# ------------------------------------------------------------
def test_MOV_64bit_constant_into_r11(self):
- base_constant = 0xFEDCBA9876543210
+ base_constant = intmask(0xFEDCBA9876543210)
cb = LocationCodeBuilder64()
cb.MOV(r11, imm(base_constant))
@@ -245,7 +245,7 @@
assert cb.getvalue() == expected_instructions
def test_MOV_64bit_constant_into_rax(self):
- base_constant = 0xFEDCBA9876543210
+ base_constant = intmask(0xFEDCBA9876543210)
cb = LocationCodeBuilder64()
cb.MOV(eax, imm(base_constant))
@@ -256,7 +256,7 @@
assert cb.getvalue() == expected_instructions
def test_MOV_64bit_address_into_r11(self):
- base_addr = 0xFEDCBA9876543210
+ base_addr = intmask(0xFEDCBA9876543210)
cb = LocationCodeBuilder64()
cb.MOV(r11, heap(base_addr))
@@ -270,7 +270,7 @@
def test_MOV_immed32_into_64bit_address_1(self):
immed = -0x01234567
- base_addr = 0xFEDCBA9876543210
+ base_addr = intmask(0xFEDCBA9876543210)
cb = LocationCodeBuilder64()
cb.MOV(AddressLoc(ImmedLoc(0), ImmedLoc(0), 0, base_addr),
ImmedLoc(immed))
@@ -286,7 +286,7 @@
def test_MOV_immed32_into_64bit_address_2(self):
immed = -0x01234567
- base_addr = 0xFEDCBA9876543210
+ base_addr = intmask(0xFEDCBA9876543210)
cb = LocationCodeBuilder64()
cb.MOV(AddressLoc(ImmedLoc(0), edx, 3, base_addr),
ImmedLoc(immed))
@@ -302,7 +302,7 @@
def test_MOV_immed32_into_64bit_address_3(self):
immed = -0x01234567
- base_addr = 0xFEDCBA9876543210
+ base_addr = intmask(0xFEDCBA9876543210)
cb = LocationCodeBuilder64()
cb.MOV(AddressLoc(edx, ImmedLoc(0), 0, base_addr),
ImmedLoc(immed))
@@ -320,7 +320,7 @@
def test_MOV_immed32_into_64bit_address_4(self):
immed = -0x01234567
- base_addr = 0xFEDCBA9876543210
+ base_addr = intmask(0xFEDCBA9876543210)
cb = LocationCodeBuilder64()
cb.MOV(AddressLoc(edx, esi, 2, base_addr), ImmedLoc(immed))
# this case is a MOV_ai
@@ -339,7 +339,7 @@
def test_MOV_immed64_into_64bit_address_1(self):
immed = 0x0123456789ABCDEF
- base_addr = 0xFEDCBA9876543210
+ base_addr = intmask(0xFEDCBA9876543210)
cb = LocationCodeBuilder64()
cb.MOV(AddressLoc(ImmedLoc(0), ImmedLoc(0), 0, base_addr),
ImmedLoc(immed))
@@ -361,7 +361,7 @@
def test_MOV_immed64_into_64bit_address_2(self):
immed = 0x0123456789ABCDEF
- base_addr = 0xFEDCBA9876543210
+ base_addr = intmask(0xFEDCBA9876543210)
cb = LocationCodeBuilder64()
cb.MOV(AddressLoc(ImmedLoc(0), edx, 3, base_addr),
ImmedLoc(immed))
@@ -383,7 +383,7 @@
def test_MOV_immed64_into_64bit_address_3(self):
immed = 0x0123456789ABCDEF
- base_addr = 0xFEDCBA9876543210
+ base_addr = intmask(0xFEDCBA9876543210)
cb = LocationCodeBuilder64()
cb.MOV(AddressLoc(eax, ImmedLoc(0), 0, base_addr),
ImmedLoc(immed))
@@ -407,7 +407,7 @@
def test_MOV_immed64_into_64bit_address_4(self):
immed = 0x0123456789ABCDEF
- base_addr = 0xFEDCBA9876543210
+ base_addr = intmask(0xFEDCBA9876543210)
cb = LocationCodeBuilder64()
cb.MOV(AddressLoc(edx, eax, 2, base_addr), ImmedLoc(immed))
# this case is a MOV_ai
diff --git a/rpython/jit/metainterp/test/test_fficall.py
b/rpython/jit/metainterp/test/test_fficall.py
--- a/rpython/jit/metainterp/test/test_fficall.py
+++ b/rpython/jit/metainterp/test/test_fficall.py
@@ -11,7 +11,7 @@
from rpython.rlib.jit_libffi import (types, CIF_DESCRIPTION, FFI_TYPE_PP,
jit_ffi_call)
from rpython.rlib.unroll import unrolling_iterable
-from rpython.rlib.rarithmetic import intmask, r_longlong, r_singlefloat
+from rpython.rlib.rarithmetic import intmask, r_longlong, r_singlefloat, r_uint
from rpython.rlib.longlong2float import float2longlong
def get_description(atypes, rtype):
@@ -230,8 +230,8 @@
def test_handle_unsigned(self):
self._run([types.ulong], types.ulong,
- [rffi.cast(rffi.ULONG, sys.maxint + 91348)],
- rffi.cast(rffi.ULONG, sys.maxint + 4242))
+ [rffi.cast(rffi.ULONG, r_uint(sys.maxint + 91348))],
+ rffi.cast(rffi.ULONG, r_uint(sys.maxint + 4242)))
def test_handle_unsignedchar(self):
self._run([types.uint8], types.uint8,
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit