Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Negative index on PaginatedList causes unexpected results #305

Closed
UniversalSuperBox opened this issue Oct 3, 2019 · 0 comments · Fixed by #306 · May be fixed by #656
Closed

Negative index on PaginatedList causes unexpected results #305

UniversalSuperBox opened this issue Oct 3, 2019 · 0 comments · Fixed by #306 · May be fixed by #656
Assignees
Labels

Comments

@UniversalSuperBox
Copy link
Contributor

Describe the bug

It is expected that you cannot negative-index the PaginatedList due to its inability to know its length until it is full. However, it is still possible to use the negative index if at least one page of results has been loaded. When this happens, the list returns the last value it has loaded (which is not necessarily the last value it can load).

To Reproduce

Steps to reproduce the behavior:

users = canvas.get_course(1).get_users()
users[1]
users[-1]

Expected behavior

I am not allowed to use negative indexing (wishlist, I can use negative indexing :D)

Environment information (please complete the following information)

  • Python 3.7.0
  • CanvasAPI 0.14.0

Additional context

I'll try my hand at fixing this.

@Thetwam Thetwam added this to the CanvasAPI v0.15.0 milestone Oct 3, 2019
UniversalSuperBox added a commit to UniversalSuperBox/canvasapi that referenced this issue Oct 3, 2019
Fix ucfopen#305 by throwing
IndexError whenever a negative index is requested.

As a bonus, do the same when a slice is requested rather than when it's
used.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment