[Django] #30487: Using more than 245 functions in CombinedExpressions causes RecursionError

5 views
Skip to first unread message

Django

unread,
May 17, 2019, 3:52:23 AM5/17/19
to django-...@googlegroups.com
#30487: Using more than 245 functions in CombinedExpressions causes RecursionError
-------------------------------------+-------------------------------------
Reporter: M1ha Shvn | Owner: nobody
Type: Bug | Status: new
Component: Database | Version: 2.1
layer (models, ORM) | Keywords: recursion function
Severity: Normal | Func
Triage Stage: | Has patch: 0
Unreviewed |
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
-------------------------------------+-------------------------------------
Hi.
When I try to concatenate more than 245 values into
django.db.models.expressions.CombinedExpression I get RecursionError
"RecursionError: maximum recursion depth exceeded".

A simple example to reproduce:

{{{
from django.db.models import F
item = F('test')
for i in range(300):
item += F('test')
print(item)
}}}
returns

{{{
Traceback (most recent call last):
File "/usr/lib/python3.7/code.py", line 90, in runcode
exec(code, self.locals)
File "<input>", line 5, in <module>
File "/home/vagrant/venv/lib/python3.7/site-
packages/django/db/models/expressions.py", line 404, in __str__
return "{} {} {}".format(self.lhs, self.connector, self.rhs)
File "/home/vagrant/venv/lib/python3.7/site-
packages/django/db/models/expressions.py", line 404, in __str__
return "{} {} {}".format(self.lhs, self.connector, self.rhs)
File "/home/vagrant/venv/lib/python3.7/site-
packages/django/db/models/expressions.py", line 404, in __str__
return "{} {} {}".format(self.lhs, self.connector, self.rhs)
[Previous line repeated 244 more times]
RecursionError: maximum recursion depth exceeded
}}}

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

Django

unread,
May 17, 2019, 5:08:45 AM5/17/19
to django-...@googlegroups.com
#30487: Using more than 245 functions in CombinedExpressions causes RecursionError.

-------------------------------------+-------------------------------------
Reporter: M1ha Shvn | Owner: nobody
Type: Bug | Status: closed
Component: Database layer | Version: master
(models, ORM) |
Severity: Normal | Resolution: wontfix
Keywords: recursion function | Triage Stage:
Func | Unreviewed
Has patch: 0 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by felixxm):

* status: new => closed
* version: 2.1 => master
* resolution: => wontfix


Comment:

Thanks for the report, however `CombinedExpression` has a recursive
"nature" from the very beginning. IMO we will not be able to fix this with
current implementation. You can increase a Python's recursion limit
locally, e.g.
{{{
>>> import sys
>>> sys.setrecursionlimit(2000)
}}}

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

Reply all
Reply to author
Forward
0 new messages