Opened 10 years ago

Closed 10 years ago

Last modified 10 years ago

#21883 closed Bug (fixed)

Use of xrange in custom lookups code not valid in Python 3; "__in list too long" case not tested

Reported by: Carl Meyer Owned by: nobody
Component: Database layer (models, ORM) Version: dev
Severity: Normal Keywords:
Cc: Triage Stage: Accepted
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

There is a use of 'xrange' in the In lookup class in django/db/models/lookups.py, within the "list too long for db backend" case. "xrange" is not present on Python 3, so this code will fail there.

The fact that tests are passing on both Python 2 and 3 suggests that this code branch is untested, and I confirmed by inserting a pdb.set_trace() at that point and running the full test suite. That's a sizable code branch; it should be tested.

Change History (2)

comment:1 by Anssi Kääriäinen, 10 years ago

Resolution: fixed
Status: newclosed

The branch is tested, but only on Oracle. I don't think Python 3 + Oracle is actively tested, so for that reason the error wasn't spotted until now.

Seems like Trac didn't pick up my commit, so fixed in 0ca647357ecb0e3fe507d90a9518198751b2d408:

    Fixed #21883 -- Added six.moves.xrange import
    
    When moving code around from sql.where to lookups six.moves.xrange
    import was forgotten. The xrange import is needed on Python 3.

in reply to:  1 comment:2 by Shai Berger, 10 years ago

Replying to akaariai:

I don't think Python 3 + Oracle is actively tested

Python3 + Oracle segfaults. #20725.

Note: See TracTickets for help on using tickets.
Back to Top