This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: test_xrange fails on osf1 v5.1b
Type: Stage:
Components: Interpreter Core Versions: Python 2.4
process
Status: closed Resolution:
Dependencies: Superseder:
Assigned To: nnorwitz Nosy List: dharma_roadkill, nnorwitz, rhettinger
Priority: high Keywords:

Created on 2004-09-06 00:10 by dharma_roadkill, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Messages (5)
msg22358 - (view) Author: roadkill (dharma_roadkill) Date: 2004-09-06 00:10
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.

msg22359 - (view) Author: Raymond Hettinger (rhettinger) * (Python committer) Date: 2004-09-06 00:36
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);
}
msg22360 - (view) Author: Neal Norwitz (nnorwitz) * (Python committer) Date: 2004-09-07 02:52
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.
msg22361 - (view) Author: Neal Norwitz (nnorwitz) * (Python committer) Date: 2004-10-15 05:03
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.
msg22362 - (view) Author: roadkill (dharma_roadkill) Date: 2004-11-10 02:32
Logged In: YES 
user_id=1083183


Now no error in 2.4 beta 2.
Thanks,
The Reverend Dharma Roadkill
History
Date User Action Args
2022-04-11 14:56:06adminsetgithub: 40871
2004-09-06 00:10:24dharma_roadkillcreate