#2348: [patch] Unbound local error when performing invalid query
------------------------------+---------------------------------------------
Reporter: [EMAIL PROTECTED] | Owner: adrian
Type: defect | Status: new
Priority: normal | Milestone:
Component: Database wrapper | Version: SVN
Severity: minor | Resolution:
Keywords: |
------------------------------+---------------------------------------------
Changes (by Karen Tracey <[EMAIL PROTECTED]>):
* cc: [EMAIL PROTECTED] (added)
* summary: Unbound local error when performing invalid query => [patch]
Unbound local error when performing invalid
query
Comment:
I ran into this also today. I was surprised to get:
UnboundLocalError: local variable 'new_opts' referenced before assignment
from File "/usr/lib/python2.4/site-packages/django/db/models/query.py",
line 859,
in lookup_inner
when I mistyped a filter specification as Date__ear instead of Date__year.
Granted, it's a user error, but for most other filter typos I get
something more along the lines of:
TypeError: Cannot resolve keyword 'xDate' into field
which clearly points me to where my typo is. UnboundLocalError looks
likes a bug in the Django code itself.
I looked at the code in query.py and it's a simple fix to catch cases like
this and raise the TypeError instead of continuing on and using variables
that haven't been set. Is the refactoring mentioned above completed? I
see query.py has been checked in quite recently so I am hoping the
attached suggested patch could be useful in resolving this (and 2287,
which looks to be the exact same problem).
--
Ticket URL: <http://code.djangoproject.com/ticket/2348#comment:>
Django <http://code.djangoproject.org/>
The web framework for perfectionists with deadlines.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Django
updates" group.
To post to this group, send email to django-updates@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/django-updates?hl=en
-~----------~----~----~----~------~----~------~--~---