__unicode__() works, unicode() blows up.

2012-11-04 Thread Roy Smith
Environment: Python-2.7.3 Ubuntu Precise mongoengine 0.6.20 I have a class which includes a __unicode__() method: class User(mongoengine.Document): def __unicode__(self): return self.username If I create an instance of this class by calling the constructor directly,

Re: __unicode__() works, unicode() blows up. (Never mind!)

2012-11-04 Thread Roy Smith
In article roy-90d9a2.08321804112...@news.panix.com, Roy Smith r...@panix.com wrote: print u.__unicode__() None print unicode(u) Traceback (most recent call last): File stdin, line 1, in module TypeError: coercing to Unicode: need string or buffer, NoneType found What's going on

Re: __unicode__() works, unicode() blows up.

2012-11-04 Thread Joshua Landau
On 4 November 2012 13:32, Roy Smith r...@panix.com wrote: Environment: Python-2.7.3 Ubuntu Precise mongoengine 0.6.20 I have a class which includes a __unicode__() method: class User(mongoengine.Document): def __unicode__(self): return self.username If I create an

Re: __unicode__() works, unicode() blows up. (Never mind!)

2012-11-04 Thread Aahz
In article roy-30ba92.08410804112...@news.panix.com, Roy Smith r...@panix.com wrote: In article roy-90d9a2.08321804112...@news.panix.com, Roy Smith r...@panix.com wrote: print u.__unicode__() None print unicode(u) Traceback (most recent call last): File stdin, line 1, in module

Re: __unicode__() works, unicode() blows up. (Never mind!)

2012-11-04 Thread Terry Reedy
On 11/4/2012 8:41 AM, Roy Smith wrote: In article roy-90d9a2.08321804112...@news.panix.com, Roy Smith r...@panix.com wrote: print u.__unicode__() None print unicode(u) Traceback (most recent call last): File stdin, line 1, in module TypeError: coercing to Unicode: need string or