Ticket #1159 (new defect)

Opened 1 year ago

Last modified 1 year ago

[reported upstream] Bug in python range

Reported by: robertwb Assigned to: was
Priority: major Milestone: sage-3.4
Component: packages Keywords:
Cc:

Description (Last modified by mabshoff)

%python
class MyInt:
    def __init__(self, n):
        self.n = int(n)
    def __int__(self):
        return self.n

print range(MyInt(2**3), MyInt(2**3+10))
print "here"
print range(MyInt(2**34), MyInt(2**34+10))

Change History

11/12/2007 02:13:10 PM changed by robertwb

%python
class MyInt:
    def __init__(self, n):
        self.n = int(n)
    def __int__(self):
        return self.n

print range(MyInt(2**3), MyInt(2**3+10))
print "here"
print range(MyInt(2**34), MyInt(2**34+10))

11/13/2007 03:51:46 PM changed by mabshoff

  • milestone set to sage-2.8.13.

11/17/2007 10:27:43 PM changed by mabshoff

  • description changed.

11/17/2007 10:28:03 PM changed by mabshoff

  • description changed.

11/19/2007 04:16:19 PM changed by mhansen

I can't find any issue with this. It works correctly for me in both the Python and Sage environments.

11/30/2007 04:30:14 PM changed by robertwb

I get

Traceback (most recent call last):    print range(MyInt(2**34), MyInt(2**34+10))
  File "/Users/robert/sage/current/local/lib/python2.5/site-packages/sage/server/support.py", line 260, in syseval
    return system.eval(cmd)
  File "/Users/robert/sage/current/local/lib/python2.5/site-packages/sage/misc/python.py", line 21, in eval
    eval(z, globals, locals)
  File "/Users/robert/sage/sage-2.8.11/data/extcode/sage/", line 1, in <module>
    
TypeError: range() integer start argument expected, got instance.

On a 64-bit machine, try

print range(2**64, 2**64+10)
print range(MyInt(2**64), MyInt(2**64+10))

I believe this is a bug in Python, and have reported it here: http://bugs.python.org/issue1533

11/30/2007 04:31:32 PM changed by robertwb

  • milestone changed from sage-2.8.15 to sage-2.9.

01/24/2008 01:45:49 PM changed by mabshoff

  • summary changed from Bug in python range to [reported upstream] Bug in python range.