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

    XMLWordPrintable

    Details

    • Type: Improvement
    • Status: Closed
    • Priority: Minor - P4
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: None
    • Labels:
      None
    • Backwards Compatibility:
      Minor Change

      Description

      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.

        Attachments

          Activity

            People

            • Votes:
              1 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: