Opened 13 years ago

Closed 9 years ago

#1159 closed defect (duplicate)

[reported upstream] Bug in python range

Reported by: robertwb Owned by: was
Priority: major Milestone: sage-duplicate/invalid/wontfix
Component: packages: standard Keywords:
Cc: Merged in:
Authors: Reviewers: Jason Grout
Report Upstream: Fixed upstream, in a later stable release. Work issues:
Branch: Commit:
Dependencies: Stopgaps:

Status badges

Description (last modified by jdemeyer)

%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))

Fixed by #9958.

Change History (15)

comment:1 Changed 13 years ago 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))

comment:2 Changed 13 years ago by mabshoff

  • Milestone set to sage-2.8.13

comment:3 Changed 13 years ago by mabshoff

  • Description modified (diff)

comment:4 Changed 13 years ago by mabshoff

  • Description modified (diff)

comment:5 Changed 13 years ago by mhansen

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

comment:6 Changed 13 years ago 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

comment:7 Changed 13 years ago by robertwb

  • Milestone changed from sage-2.8.15 to sage-2.9

comment:8 Changed 13 years ago by mabshoff

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

comment:9 Changed 12 years ago by jason

  • Status changed from new to needs_info_new

comment:10 Changed 11 years ago by mhansen

  • Report Upstream set to Reported upstream. Little or no feedback.

comment:11 Changed 10 years ago by Koen

  • Status changed from needs_info to needs_work

Fixed in upstream Python 2.6.6 / Python 2.7 (see issue 1533 linked to above) and fix will also be in Python 3 releases. This needs an upgrade of the Sage Python from 2.6.4 to 2.6.6.

comment:12 Changed 10 years ago by Koen

Alternative fix to upgrade to Python 2.6.6 would be the upgrade to Python 2.7 from ticket http://trac.sagemath.org/sage_trac/ticket/9958

comment:13 Changed 9 years ago by jason

Fixed by #9958, when it gets merged (upgrade to python 2.7)

comment:14 Changed 9 years ago by jdemeyer

  • Milestone changed from sage-4.8 to sage-duplicate/invalid/wontfix
  • Report Upstream changed from Reported upstream. Little or no feedback. to Fixed upstream, in a later stable release.
  • Reviewers set to Jason Grout
  • Status changed from needs_work to positive_review

comment:15 Changed 9 years ago by jdemeyer

  • Description modified (diff)
  • Resolution set to duplicate
  • Status changed from positive_review to closed
Note: See TracTickets for help on using tickets.