Opened 12 years ago

Last modified 5 weeks ago

#10365 needs_info defect

timedelta doesn't recognize Sage integers

Reported by: jason Owned by: AlexGhitza
Priority: major Milestone:
Component: basic arithmetic Keywords:
Cc: robertwb Merged in:
Authors: Reviewers:
Report Upstream: N/A Work issues:
Branch: Commit:
Dependencies: Stopgaps:

Status badges


This gives an error:

sage: version()
'Sage Version 4.6, Release Date: 2010-10-30'
sage: import datetime
sage: datetime.timedelta(hours=6)
TypeError                                 Traceback (most recent call last)

/Users/grout/<ipython console> in <module>()

TypeError: unsupported type for timedelta hours component: sage.rings.integer.Integer

but this does not

sage: datetime.timedelta(hours=int(6))
datetime.timedelta(0, 21600)

Is this possible to fix without patching Python?

Change History (12)

comment:1 Changed 10 years ago by mhansen

There's no way to do this without patching Python. The timedelta function has explicit PyInt_Check, PyLong_Check, and PyFloat_Check. So, unless we make integer a subclass of int/long, this won't work without an upstream change.

comment:3 Changed 9 years ago by jdemeyer

Milestone: sage-5.11sage-5.12

comment:4 Changed 9 years ago by vbraun_spam

Milestone: sage-6.1sage-6.2

comment:5 Changed 9 years ago by vbraun_spam

Milestone: sage-6.2sage-6.3

comment:6 Changed 8 years ago by vbraun_spam

Milestone: sage-6.3sage-6.4

comment:7 Changed 5 years ago by chapoton

Milestone: sage-6.4sage-duplicate/invalid/wontfix
Status: newneeds_review

Let us close this one.

comment:8 Changed 5 years ago by vdelecroix

Why should we close this?

comment:9 Changed 5 years ago by jdemeyer

Milestone: sage-duplicate/invalid/wontfixsage-8.3
Status: needs_reviewneeds_info

comment:10 Changed 5 years ago by chapoton

Well, anybody needing that can just wrap with int(). No need for anything sophisticated.. And after 5 years of nobody doing nothing, should we wait for another 5 years ?

comment:11 Changed 4 years ago by vdelecroix

Milestone: sage-8.3sage-8.4

milestone update 8.3 -> 8.4

comment:12 Changed 5 weeks ago by mkoeppe

Milestone: sage-8.4
Note: See TracTickets for help on using tickets.