Author: Alex Gaynor <[email protected]>
Branch: numpy-dtype-refactor
Changeset: r49478:98e8d0b934b3
Date: 2011-11-16 11:53 -0500
http://bitbucket.org/pypy/pypy/changeset/98e8d0b934b3/
Log: merged default
diff --git a/pypy/module/cpyext/include/modsupport.h
b/pypy/module/cpyext/include/modsupport.h
--- a/pypy/module/cpyext/include/modsupport.h
+++ b/pypy/module/cpyext/include/modsupport.h
@@ -48,7 +48,11 @@
/*
* This is from pyport.h. Perhaps it belongs elsewhere.
*/
+#ifdef __cplusplus
+#define PyMODINIT_FUNC extern "C" void
+#else
#define PyMODINIT_FUNC void
+#endif
#ifdef __cplusplus
diff --git a/pypy/module/cpyext/presetup.py b/pypy/module/cpyext/presetup.py
--- a/pypy/module/cpyext/presetup.py
+++ b/pypy/module/cpyext/presetup.py
@@ -42,4 +42,4 @@
patch_distutils()
del sys.argv[0]
-execfile(sys.argv[0], {'__file__': sys.argv[0]})
+execfile(sys.argv[0], {'__file__': sys.argv[0], '__name__': '__main__'})
diff --git a/pypy/module/math/test/test_translated.py
b/pypy/module/math/test/test_translated.py
new file mode 100644
--- /dev/null
+++ b/pypy/module/math/test/test_translated.py
@@ -0,0 +1,10 @@
+import py
+from pypy.translator.c.test.test_genc import compile
+from pypy.module.math.interp_math import _gamma
+
+
+def test_gamma_overflow():
+ f = compile(_gamma, [float])
+ assert f(10.0) == 362880.0
+ py.test.raises(OverflowError, f, 1720.0)
+ py.test.raises(OverflowError, f, 172.0)
diff --git a/pypy/rpython/lltypesystem/module/ll_math.py
b/pypy/rpython/lltypesystem/module/ll_math.py
--- a/pypy/rpython/lltypesystem/module/ll_math.py
+++ b/pypy/rpython/lltypesystem/module/ll_math.py
@@ -127,9 +127,12 @@
return y != y
def ll_math_isinf(y):
- if use_library_isinf_isnan and not jit.we_are_jitted():
+ if jit.we_are_jitted():
+ return (y + VERY_LARGE_FLOAT) == y
+ elif use_library_isinf_isnan:
return not _lib_finite(y) and not _lib_isnan(y)
- return (y + VERY_LARGE_FLOAT) == y
+ else:
+ return y == INFINITY or y == -INFINITY
def ll_math_isfinite(y):
# Use a custom hack that is reasonably well-suited to the JIT.
diff --git a/pypy/rpython/lltypesystem/rffi.py
b/pypy/rpython/lltypesystem/rffi.py
--- a/pypy/rpython/lltypesystem/rffi.py
+++ b/pypy/rpython/lltypesystem/rffi.py
@@ -862,12 +862,14 @@
try:
unsigned = not tp._type.SIGNED
except AttributeError:
- if (not isinstance(tp, lltype.Primitive) or
- tp in (FLOAT, DOUBLE) or
- cast(lltype.SignedLongLong, cast(tp, -1)) < 0):
+ if not isinstance(tp, lltype.Primitive):
unsigned = False
+ elif tp in (lltype.Signed, FLOAT, DOUBLE):
+ unsigned = False
+ elif tp in (lltype.Char, lltype.UniChar, lltype.Bool):
+ unsigned = True
else:
- unsigned = True
+ raise AssertionError("size_and_sign(%r)" % (tp,))
return size, unsigned
def sizeof(tp):
diff --git a/pypy/rpython/lltypesystem/test/test_rffi.py
b/pypy/rpython/lltypesystem/test/test_rffi.py
--- a/pypy/rpython/lltypesystem/test/test_rffi.py
+++ b/pypy/rpython/lltypesystem/test/test_rffi.py
@@ -743,8 +743,9 @@
assert sizeof(lltype.Typedef(ll, 'test')) == sizeof(ll)
assert not size_and_sign(lltype.Signed)[1]
assert size_and_sign(lltype.Char) == (1, True)
- assert not size_and_sign(lltype.UniChar)[1]
+ assert size_and_sign(lltype.UniChar)[1]
assert size_and_sign(UINT)[1]
+ assert not size_and_sign(INT)[1]
def test_rffi_offsetof(self):
import struct
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit