[Django] #21883: Use of xrange in custom lookups code not valid in Python 3; "__in list too long" case not tested

7 views
Skip to first unread message

Django

unread,
Jan 27, 2014, 5:29:14 PM1/27/14
to django-...@googlegroups.com
#21883: Use of xrange in custom lookups code not valid in Python 3; "__in list too
long" case not tested
-------------------------------------+-------------------------------------
Reporter: carljm | Owner: nobody
Type: Bug | Status: new
Component: Database | Version: master
layer (models, ORM) | Keywords:
Severity: Normal | Has patch: 0
Triage Stage: Accepted | Needs tests: 0
Needs documentation: 0 | Easy pickings: 0
Patch needs improvement: 0 |
UI/UX: 0 |
-------------------------------------+-------------------------------------
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.

--
Ticket URL: <https://code.djangoproject.com/ticket/21883>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Jan 28, 2014, 2:14:00 PM1/28/14
to django-...@googlegroups.com
#21883: Use of xrange in custom lookups code not valid in Python 3; "__in list too
long" case not tested
-------------------------------------+-------------------------------------
Reporter: carljm | Owner: nobody
Type: Bug | Status: closed
Component: Database layer | Version: master
(models, ORM) | Resolution: fixed
Severity: Normal | Triage Stage: Accepted
Keywords: | Needs documentation: 0
Has patch: 0 | Patch needs improvement: 0
Needs tests: 0 | UI/UX: 0
Easy pickings: 0 |
-------------------------------------+-------------------------------------
Changes (by akaariai):

* status: new => closed
* resolution: => fixed


Comment:

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.

}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/21883#comment:1>

Django

unread,
Jan 29, 2014, 12:47:35 PM1/29/14
to django-...@googlegroups.com
#21883: Use of xrange in custom lookups code not valid in Python 3; "__in list too
long" case not tested
-------------------------------------+-------------------------------------
Reporter: carljm | Owner: nobody
Type: Bug | Status: closed
Component: Database layer | Version: master
(models, ORM) | Resolution: fixed
Severity: Normal | Triage Stage: Accepted
Keywords: | Needs documentation: 0
Has patch: 0 | Patch needs improvement: 0
Needs tests: 0 | UI/UX: 0
Easy pickings: 0 |
-------------------------------------+-------------------------------------

Comment (by shai):

Replying to [comment:1 akaariai]:


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

Python3 + Oracle segfaults. #20725.

--
Ticket URL: <https://code.djangoproject.com/ticket/21883#comment:2>

Reply all
Reply to author
Forward
0 new messages