[Eric] TypeError in DebugClientBase.py

detlev detlev at die-offenbachs.de
Sun Nov 22 11:33:56 GMT 2009


On Samstag, 21. November 2009, Seth Hill wrote:
> Hello all,
> 
> I'm new to the mailing list and Eric, so please bear with me.
> 
> I have discovered a possible bug in the DebugClientBase.py which
> comes with Eric4 4.3.9 (r3513) on Windows XP. I've put a workaround
> in place for the issue (see below). My question is not so much about
> the bug (if it is a bug), but rather, where's the appropriate place
> to submit bug reports? 

The ideal way to report bugs is via the included reporting function (s. Help 
menu). However, it is fine to report them here as well.

> If the right place is here, then continue
> reading (and my apologies if not!).
> 
> 
> I'm working with a django 1.1 project, trying to get debugging going.
> I'm working with a form in a view function. I set a breakpoint in the
> view function, and get a TypeError in DebugClientBase.py:1608. It
> looks like the debugger is going through the locals and calling
> unicode() on all of them. Some of the locals in this case don't
> support the unicode method. When the debugger calls the unicode()
> method, it triggers an exception inside the running wsgi server. I
> get an error message on the web page, and the debug session stops
> working.
> 
> My code looks like:
> 
> forms.py:
> class NewCustomerForm(forms.Form):
>      name = forms.CharField()
>      # etc
> 
> views.py:
> def create_customer(request):
>      if request.method == "POST":  # breakpoint here
>          form = NewCustomerForm(request.POST)
>          if form.is_valid():       # exception occurs when stepping
> to here
> 
> 
> The line in DebugClientBase.py looks like:
>      valtypestr = unicode(type(value))[1:-1]

I don't understand, why type(value) does not support the unicode() method.

> 
> I've "fixed" the error by wrapping the line in a try:
> 
> try:
>      valtypestr = unicode(type(value))[1:-1]
> except TypeError:
>      valtypestr = repr(type(value))[1:-1]
> 
> You can duplicate the TypeError with something like:
>  >>> class Foo:
> 
> ...        def __unicode__(self):
> ...            return u'Foo instance'
> ...
> 
>  >>> unicode(Foo)
> 
> Traceback (most recent call last):
>    File "<console>", line 1, in <module>
> TypeError: unbound method __unicode__() must be called with Foo
> instance as first argument (got nothing instead)
> 

However, unicode(type(Foo)) works fine, and that is what the "faulty" line 
does. Could you please give another example or stripped down script that 
causes your problem.

> 
> Regards,
> 
> Seth Hill
> 
> _______________________________________________
> Eric mailing list
> Eric at riverbankcomputing.com
> http://www.riverbankcomputing.com/mailman/listinfo/eric
> 

Regards,
Detlev
-- 
Detlev Offenbach
detlev at die-offenbachs.de


More information about the Eric mailing list