[Python-Dev] alpha problems -- need input
Neal Norwitz
nnorwitz at gmail.com
Thu Mar 30 07:37:21 CEST 2006
These issues are on HEAD. There might be some others I missed.
With cc there are at least 2 issues:
* test_file causes interpreter exit due to sys.stdin.seek(-1)
* test_pty fails apparently due to whitespace differences
http://www.python.org/dev/buildbot/all/alpha%20Tru64%205.1%20trunk/builds/18/step-test/0
Should we skip the test for an invalid seek on stdin on osf1?
I haven't investigated the test_pty failure further.
With gcc, there are also several issues:
* test_float and test_struct fail due to NaN handling
* test_long fails
* test_ctypes
The question is how to fix these. test_float and test_struct fail due
to a Floating Point Exception signal (SIGFPE). test_long fails due to
float(shuge) raising a ValueError. There is a comment:
# XXX Perhaps float(shuge) can raise OverflowError on some box?
# The comparison should not.
Note: it raises value error, not OverflowError.
Should I just wrap the float(shuge) in a try/except and skip the test
if an exception is raised?
The patches below fix the float and struct problems. I'm not sure if
we should ignore SIGFPE in test_float. I'm also not sure if the
change to floatobject.c should be made. It's possible there is a
compiler flag that would help. I tried -mieee and a few others, but
none seemed to make a difference for gcc.
test_ctypes fails because _findLib() doesn't seem to work properly on
OSF1. Note: libc.so => /usr/shlib/libc.so
ERROR: test_find (ctypes.test.test_loading.LoaderTest)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/net/ringneck/scratch1/nnorwitz/python/trunk/Lib/ctypes/test/test_loading.py",
line 40, in test_find
cdll.find(name)
File "/net/ringneck/scratch1/nnorwitz/python/trunk/Lib/ctypes/_loader.py",
line 205, in find
raise OSError("Library %r not found" % name)
OSError: Library 'c' not found
======================================================================
ERROR: test_load (ctypes.test.test_loading.LoaderTest)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/net/ringneck/scratch1/nnorwitz/python/trunk/Lib/ctypes/test/test_loading.py",
line 25, in test_load
cdll.load(name)
File "/net/ringneck/scratch1/nnorwitz/python/trunk/Lib/ctypes/_loader.py",
line 112, in load
return self._load(libname, mode)
File "/net/ringneck/scratch1/nnorwitz/python/trunk/Lib/ctypes/_loader.py",
line 124, in load_library
return self._dlltype(libname, mode)
File "/net/ringneck/scratch1/nnorwitz/python/trunk/Lib/ctypes/__init__.py",
line 292, in __init__
self._handle = _dlopen(self._name, mode)
OSError: dlopen: Cannot map library libc.so.6
======================================================================
Below are the patches.
Index: Objects/floatobject.c
===================================================================
--- Objects/floatobject.c (revision 43416)
+++ Objects/floatobject.c (working copy)
@@ -1430,10 +1430,19 @@
return -1;
}
else {
- float y = (float)x;
+ float y;
const char *s = (char*)&y;
int i, incr = 1;
+ /* The conversion of x to a float causes a floating exception
+ on some platforms (at least OSF1 v5.1 gcc-4.0.1)
+ */
+#ifndef MAXFLOAT
+#define MAXFLOAT ((float)3.40282346638528860e+38)
+#endif
+ if (x > MAXFLOAT || x < -MAXFLOAT)
+ goto Overflow;
+ y = (float)x;
if ((float_format == ieee_little_endian_format && !le)
|| (float_format == ieee_big_endian_format && le)) {
p += 3;
Index: Lib/test/test_float.py
===================================================================
--- Lib/test/test_float.py (revision 43416)
+++ Lib/test/test_float.py (working copy)
@@ -1,4 +1,5 @@
+import signal
import unittest, struct
from test import test_support
@@ -83,6 +84,12 @@
# is accident (today).
class IEEEFormatTestCase(unittest.TestCase):
+ def setUp(self):
+ signal.signal(signal.SIGFPE, signal.SIG_IGN)
+
+ def tearDown(self):
+ signal.signal(signal.SIGFPE, signal.SIG_DFL)
+
if float.__getformat__("double").startswith("IEEE"):
def test_double_specials_do_unpack(self):
for fmt, data in [('>d', BE_DOUBLE_INF),
Index: Lib/test/test_file.py
===================================================================
--- Lib/test/test_file.py (revision 43416)
+++ Lib/test/test_file.py (working copy)
@@ -100,12 +100,14 @@
print "writelines accepted sequence of non-string objects"
f.close()
-try:
- sys.stdin.seek(-1)
-except IOError:
- pass
-else:
- print "should not be able to seek on sys.stdin"
+# This causes the interpreter to exit on OSF1 v5.1.
+if sys.platform != 'osf1V5':
+ try:
+ sys.stdin.seek(-1)
+ except IOError:
+ pass
+ else:
+ print "should not be able to seek on sys.stdin"
try:
sys.stdin.truncate()
Index: Lib/test/test_long.py
===================================================================
--- Lib/test/test_long.py (revision 43416)
+++ Lib/test/test_long.py (working copy)
@@ -372,10 +372,15 @@
self.assertRaises(OverflowError, eval, test, namespace)
- # XXX Perhaps float(shuge) can raise OverflowError on some box?
- # The comparison should not.
- self.assertNotEqual(float(shuge), int(shuge),
- "float(shuge) should not equal int(shuge)")
+ # float(shuge) can raise OverflowError on an Alpha built with gcc.
+ try:
+ fshuge = float(shuge)
+ except ValueError:
+ pass
+ else:
+ # The comparison should not.
+ self.assertNotEqual(fshuge, int(shuge),
+ "float(shuge) should not equal int(shuge)")
def test_logs(self):
import math
Index: Lib/test/test_struct.py
===================================================================
--- Lib/test/test_struct.py (revision 43416)
+++ Lib/test/test_struct.py (working copy)
@@ -429,11 +429,12 @@
# The same, but tack on a 1 bit so it rounds up to infinity.
big = (1 << 25) - 1
big = math.ldexp(big, 127 - 24)
- try:
- packed = struct.pack(">f", big)
- except OverflowError:
- pass
- else:
- TestFailed("expected OverflowError")
+ for value in (big, -big):
+ try:
+ packed = struct.pack(">f", value)
+ except OverflowError:
+ pass
+ else:
+ TestFailed("expected OverflowError")
test_705836()
More information about the Python-Dev
mailing list