Skip to content

py3: need to fix sequence of ranges #24543

@embray

Description

@embray

On Python 2 something like this works:

Sequence([range(10)])

naturally, since range(10) just returns a list. On Python 3 however, since range is a type:

sage: Sequence([range(10)])
Traceback
...
TypeError: 'range' object cannot be interpreted as an integer
...
TypeError: unable to convert range(0, 10) to an element of <class 'range'>

This is because the Sequence constructor determines the "universe" of the sequence to be range, and later tries to pass range objects to range like: universe(x[i]) where x[i] is the range(10) instance.

It assumes that whatever universe is can construct an instance of itself by being passed a single argument. One could argue that Python's range() built-in should support this as a special case. But regardless this should be fixed in Sage. I'm just not sure the best way yet.

Component: python3

Issue created by migration from https://trac.sagemath.org/ticket/24543

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions