Uploaded image for project: 'Python Driver'
  1. Python Driver
  2. PYTHON-85

Cursor slicing with equal start and stop numbers shouldn't raise an IndexError

    • Type: Icon: Improvement Improvement
    • Resolution: Done
    • Priority: Icon: Minor - P4 Minor - P4
    • None
    • Affects Version/s: None
    • Component/s: None
    • Labels:
      None
    • Minor Change

      At the moment, slicing a cursor with two equal values results in an exception being raised - I think it would be more in line with standard Python slicing behaviour if it limited the query to 0 results. Providing slicing support is just adding a bit of Pythonic syntactic-sugar, it might be more intuitive for people who are used to using slicing on lists and Django QuerySets to match the standard behaviour - just in the same way that when overriding _getattr, AttributeErrors are generally raised, and when overriding __getitem_, IndexErrors are usually raised - following the convention helps to avoid unexpected behaviour and means that the code will work with more existing code without modifying the existing code.

            Assignee:
            mike Michael Dirolf
            Reporter:
            hmarr Harry Marr
            Votes:
            1 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: