Author: Armin Rigo <[email protected]>
Branch:
Changeset: r91871:20f7723ff895
Date: 2017-07-15 10:49 +0200
http://bitbucket.org/pypy/pypy/changeset/20f7723ff895/
Log: (ronan, arigo)
Issue #2604: skip this test (fails on some Linux because pypy uses
the new getrandom() syscall)
diff --git a/lib-python/2.7/test/test_os.py b/lib-python/2.7/test/test_os.py
--- a/lib-python/2.7/test/test_os.py
+++ b/lib-python/2.7/test/test_os.py
@@ -580,6 +580,7 @@
"getentropy() does not use a file descriptor")
class URandomFDTests(unittest.TestCase):
@unittest.skipUnless(resource, "test requires the resource module")
+ @test_support.impl_detail(pypy=False) # on Linux, may use getrandom()
def test_urandom_failure(self):
# Check urandom() failing when it is not able to open /dev/random.
# We spawn a new process to make the test more robust (if getrlimit()
diff --git a/pypy/objspace/std/listobject.py b/pypy/objspace/std/listobject.py
--- a/pypy/objspace/std/listobject.py
+++ b/pypy/objspace/std/listobject.py
@@ -34,6 +34,7 @@
from pypy.objspace.std.tupleobject import W_AbstractTupleObject
from pypy.objspace.std.unicodeobject import W_UnicodeObject
from pypy.objspace.std.util import get_positive_index, negate
+from pypy.objspace.std.noneobject import W_NoneObject
__all__ = ['W_ListObject', 'make_range_list', 'make_empty_list_with_size']
@@ -121,6 +122,8 @@
elif type(w_obj) is W_FloatObject:
if longlong2float.can_encode_float(space.float_w(w_obj)):
continue # ok
+ elif type(w_obj) is W_NoneObject:
+ continue # ok
break
else:
return space.fromcache(IntOrFloatListStrategy)
@@ -1728,7 +1731,8 @@
return True
def switch_to_next_strategy(self, w_list, w_sample_item):
- if type(w_sample_item) is W_FloatObject:
+ if (type(w_sample_item) is W_FloatObject or
+ type(w_sample_item) is W_NoneObject):
if self.switch_to_int_or_float_strategy(w_list):
# yes, we can switch to IntOrFloatListStrategy
# (ignore here the extremely unlikely case where
@@ -1838,12 +1842,16 @@
return True
def switch_to_next_strategy(self, w_list, w_sample_item):
+ try_switch = False
if type(w_sample_item) is W_IntObject:
sample_intval = self.space.int_w(w_sample_item)
if longlong2float.can_encode_int32(sample_intval):
- if self.switch_to_int_or_float_strategy(w_list):
- # yes, we can switch to IntOrFloatListStrategy
- return
+ try_switch = True
+ elif type(w_sample_item) is W_NoneObject:
+ try_switch = True
+ if try_switch and self.switch_to_int_or_float_strategy(w_list):
+ # yes, we can switch to IntOrFloatListStrategy
+ return
# no, fall back to ObjectListStrategy
w_list.switch_to_object_strategy()
@@ -1854,6 +1862,8 @@
_none_value = longlong2float.float2longlong(0.0)
def wrap(self, llval):
+ if llval == longlong2float.nan_encoded_none:
+ return self.space.w_None
if longlong2float.is_int32_from_longlong_nan(llval):
intval = longlong2float.decode_int32_from_longlong_nan(llval)
return self.space.newint(intval)
@@ -1865,6 +1875,8 @@
if type(w_int_or_float) is W_IntObject:
intval = self.space.int_w(w_int_or_float)
return longlong2float.encode_int32_into_longlong_nan(intval)
+ elif type(w_int_or_float) is W_NoneObject:
+ return longlong2float.nan_encoded_none
else:
floatval = self.space.float_w(w_int_or_float)
return longlong2float.float2longlong(floatval)
@@ -1880,6 +1892,8 @@
elif type(w_obj) is W_FloatObject:
floatval = self.space.float_w(w_obj)
return longlong2float.can_encode_float(floatval)
+ elif type(w_obj) is W_NoneObject:
+ return True
else:
return False
diff --git a/rpython/rlib/longlong2float.py b/rpython/rlib/longlong2float.py
--- a/rpython/rlib/longlong2float.py
+++ b/rpython/rlib/longlong2float.py
@@ -104,10 +104,12 @@
# ____________________________________________________________
-# For encoding integers inside nonstandard NaN bit patterns.
+# For encoding integers or none inside nonstandard NaN bit patterns.
# ff ff ff fe xx xx xx xx (signed 32-bit int)
+# ff ff ff ff ff ff ff ac (none)
nan_high_word_int32 = -2 # -2 == (int)0xfffffffe
nan_encoded_zero = r_int64(nan_high_word_int32 << 32)
+nan_encoded_none = r_int64(-84)
def encode_int32_into_longlong_nan(value):
return (nan_encoded_zero +
@@ -127,7 +129,9 @@
return value == rffi.cast(lltype.Signed, rffi.cast(rffi.INT, value))
def can_encode_float(value):
- return intmask(float2longlong(value) >> 32) != nan_high_word_int32
+ return intmask(float2longlong(value) >> 33) != -1
+assert (nan_high_word_int32 >> 1) == -1
+assert (nan_encoded_none >> 33) == -1
def maybe_decode_longlong_as_float(value):
# Decode a longlong value. If a float, just return it as a float.
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit