#12256: TypeError when calling unicode(type(Form()))
--------------------+-------------------------------------------------------
Reporter: sethrh | Owner: nobody
Status: new | Milestone:
Component: Forms | Version: 1.1
Keywords: | Stage: Unreviewed
Has_patch: 0 |
--------------------+-------------------------------------------------------
Hello all,
I've discovered a bug (I think) relating to the Form metaclass. I noticed
it while running Eric4's debugger through a view which handled a form.
My code is doing this:
{{{
def view_function(request):
if request.method == "POST":
form = MyForm(request.POST)
if form.is_valid():
...
}}}
As soon as I create the form instance, I get a TypeError returned on the
web page. This is happens when the debugger calls unicode() on all of the
local variables to display their types and values. After the server gets
the TypeError, the debug session hangs.
{{{
>>> type(Form)
<class 'django.forms.forms.DeclarativeFieldsMetaclass'>
>>> f = Form()
>>> type(f)
<class 'django.forms.forms.Form'>
>>> unicode(type(f))
Traceback (most recent call last):
File "<console>", line 1, in <module>
TypeError: unbound method __unicode__() must be called with Form instance
as first argument (got nothing instead)
>>> import inspect
>>> inspect.getsource(type(f).__unicode__)
' def __unicode__(self):\n return self.as_table()\n'
}}}
It appears that the metaclass is somehow sticking {{{Form.__unicode__}}}
into {{{type(Form).__unicode__}}}.
I'm running Django 1.1 SVN-11366 under Python 2.5.1 on Windows XP pro sp2.
--
Ticket URL: <http://code.djangoproject.com/ticket/12256>
Django <http://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 post to this group, send email to [email protected].
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=.