[ python-Bugs-1022813 ] test_xrange fails on osf1 v5.1b
SourceForge.net
noreply at sourceforge.net
Fri Oct 15 07:03:00 CEST 2004
Bugs item #1022813, was opened at 2004-09-05 20:10
Message generated for change (Comment added) made by nnorwitz
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1022813&group_id=5470
Category: Python Interpreter Core
Group: Python 2.4
Status: Open
Resolution: None
Priority: 6
Submitted By: roadkill (dharma_roadkill)
>Assigned to: Neal Norwitz (nnorwitz)
Summary: test_xrange fails on osf1 v5.1b
Initial Comment:
On a build of Python 2.4a3:
uname -a: OSF1 xxx.tnzi.com V5.1 2650 alpha alpha
> ./python ./Lib/test/test_xrange.py
test_xrange (__main__.XrangeTest) ... ERROR
==========================================
============================
ERROR: test_xrange (__main__.XrangeTest)
------------------------------------------------------
----------------
Traceback (most recent call last):
File "./Lib/test/test_xrange.py", line 56, in test_xrange
self.assertEqual(len(xrange(-sys.maxint, sys.maxint,
2)),
ValueError: xrange object size cannot be reported
------------------------------------------------------
----------------
Ran 1 test in 0.001s
FAILED (errors=1)
Traceback (most recent call last):
File "./Lib/test/test_xrange.py", line 64, in ?
test_main()
File "./Lib/test/test_xrange.py", line 61, in test_main
test.test_support.run_unittest(XrangeTest)
File "/u03/home/doug/python/Python-
2.4a3/Lib/test/test_support.py", line 290,
in run_unittest
run_suite(suite, testclass)
File "/u03/home/doug/python/Python-
2.4a3/Lib/test/test_support.py", line 275,
in run_suite
raise TestFailed(err)
test.test_support.TestFailed: Traceback (most recent
call last):
File "./Lib/test/test_xrange.py", line 56, in test_xrange
self.assertEqual(len(xrange(-sys.maxint, sys.maxint,
2)),
ValueError: xrange object size cannot be reported
Everything else seems to work.
----------------------------------------------------------------------
>Comment By: Neal Norwitz (nnorwitz)
Date: 2004-10-15 01:03
Message:
Logged In: YES
user_id=33168
roadkill, can you verify the test passes with the latest CVS
or 2.4b1 that should come out today/tomorrow? I believe
this was fixed last night.
----------------------------------------------------------------------
Comment By: Neal Norwitz (nnorwitz)
Date: 2004-09-06 22:52
Message:
Logged In: YES
user_id=33168
I haven't thought too much about this, but ISTM that the
code is correct and the test needs to be updated.
Unfortunately, I don't think there's anyway to test for
LONG_MAX != INT_MAX. I think the best we could do is
disable this test if sys.maxint > 0x7fffffff. Hmmm, you
could probably use the struct module and find out the size
of ints and longs. (struct.calcsize('i') and
struct.calcsize('l')).
But I'm tired, so all this could be non-sense.
----------------------------------------------------------------------
Comment By: Raymond Hettinger (rhettinger)
Date: 2004-09-05 20:36
Message:
Logged In: YES
user_id=80475
I haven't looked into a solution yet but want to record what
I've found so far. In checkin 2.44 on 9/11/2002, guido noted,
""" Untested code for 64-bit platforms. range_length() is
declared as int but returns r->len which is a long. This
doesn't even cause a warning on 32-bit platforms, but can
return bogus values on 64-bit platforms (and should cause a
compiler warning). Fix this by inserting a range check when
LONG_MAX != INT_MAX, and adding an explicit cast to (int)
when the test passes. When r->len is out of range,
PySequence_Size()
and hence len() will report an error (but an iterator will still
work).
"""
The code for the check is:
static int
range_length(rangeobject *r)
{
#if LONG_MAX != INT_MAX
if (r->len > INT_MAX) {
PyErr_SetString(PyExc_ValueError,
"xrange object size cannot be reported");
return -1;
}
#endif
return (int)(r->len);
}
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1022813&group_id=5470
More information about the Python-bugs-list
mailing list