I have this very baffling error that I'm dealing with at the moment.
I'm maintaining someone else's code and I'm getting this error for
some queries with a try, except block in a view.  It seems that the
queries that lead to the error are ones where there is, in fact, a
KeyError.  I've actually manged to narrow it down to a pretty simple
test case though.  Within the view, I can do this (first few lines):

def gene_view(request, slug=None, gene=None, org=None, template=None):
   print(KeyError)

and I get this exception with django 1.4 (if it matters):
UnboundLocalError at /predictions/gene/
local variable 'KeyError' referenced before assignment
<etc>


In ./manage.py shell though, I can do:
./manage.py shell
Python 2.7.2+ (default, Oct  4 2011, 20:06:09)
[GCC 4.6.1] on linux2
Type "help", "copyright", "credits" or "license" for more information.
(InteractiveConsole)
>>> print(KeyError)
<type 'exceptions.KeyError'>
>>> import urls
>>> print(KeyError)
<type 'exceptions.KeyError'>
>>> import predictions.views
>>> print(KeyError)
<type 'exceptions.KeyError'>
>>> import predictions.urls
>>> print(KeyError)
<type 'exceptions.KeyError'>

I was expecting that if there was some redefinition of KeyError that
one of those would also give the exception.  I've also tried this,
just for kicks:

>>> from urls import *
>>> print(KeyError)
<type 'exceptions.KeyError'>
>>> from predictions.views import *
>>> print(KeyError)
<type 'exceptions.KeyError'>
>>> from predictions.urls import *
>>> print(KeyError)
<type 'exceptions.KeyError'>
>>>

I'm not really sure where to start tracking this down.  I'm under the
impression that KeyError is one of the built in python exceptions, and
so it should really never be unbound.

Thanks for your help!
Casey

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.

Reply via email to