#32134: Upgrading 2.2>3.0 causes named tuples used as arguments to __range to
error.
------------------------------------------+------------------------
Reporter: Gordon Wrigley | Owner: nobody
Type: Uncategorized | Status: new
Component: Uncategorized | Version: 3.0
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
------------------------------------------+------------------------
I noticed this while upgrading a project from 2.2 to 3.0.
This project passes named 2-tuples as arguments to __range queryset
filters. This works fine on 2.2. On 3.0 it causes the following error:
`TypeError: __new__() missing 1 required positional argument: 'far'`.
This happens because django.db.models.sql.query.Query.resolve_lookup_value
goes into the tuple elements to resolve lookups and then attempts to
reconstitute the tuple with the resolved elements.
When it attempts to construct the new tuple it preserves the type (the
named tuple) but it passes a iterator to it's constructor.
NamedTuples don't have the code path for copying an iterator, and so it
errors on insufficient arguments.
The fix is to * expand the contents of the iterator into the constructor.
--
Ticket URL: <https://code.djangoproject.com/ticket/32134>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/050.372633bf1dc7f67b92a2a59debef7fbe%40djangoproject.com.