#11932: smart_unicode does not always return a unicode
---------------------------+------------------------------------------------
 Reporter:  rwillmer       |       Owner:  nobody    
   Status:  new            |   Milestone:            
Component:  Uncategorized  |     Version:  1.0       
 Keywords:                 |       Stage:  Unreviewed
Has_patch:  0              |  
---------------------------+------------------------------------------------
 Django 1.0.2, python 2.6

 I'm using !BeautifulSoup to parse some XML which I then use as filter into
 the django database.

 If I extract a field from the XML, I get an object of class
 !BeautifulSoup.!NavigableString.

 If I then call smart_unicode(obj), I still have an object of class
 !BeautifulSoup.!NavigableString rather than the unicode I was expecting.

 If I then use this as a filter into django, .e.g product =
 Product.objects.get(obj=obj), I get this error:
 {{{
   File "/var/lib/python-support/python2.6/django/db/models/manager.py",
 line 93, in get
     return self.get_query_set().get(*args, **kwargs)
   File "/var/lib/python-support/python2.6/django/db/models/query.py", line
 304, in get
     num = len(clone)
   File "/var/lib/python-support/python2.6/django/db/models/query.py", line
 160, in __len__
     self._result_cache = list(self.iterator())
   File "/var/lib/python-support/python2.6/django/db/models/query.py", line
 275, in iterator
     for row in self.query.results_iter():
   File "/var/lib/python-support/python2.6/django/db/models/sql/query.py",
 line 206, in results_iter
     for rows in self.execute_sql(MULTI):
   File "/var/lib/python-support/python2.6/django/db/models/sql/query.py",
 line 1734, in execute_sql
     cursor.execute(sql, params)
   File "/var/lib/python-
 support/python2.6/django/db/backends/postgresql/base.py", line 52, in
 execute
     return self.cursor.execute(smart_str(sql, self.charset),
 self.format_params(params))
   File "/var/lib/python-
 support/python2.6/django/db/backends/postgresql/base.py", line 49, in
 format_params
     return tuple([smart_str(p, self.charset, True) for p in params])
   File "/var/lib/python-support/python2.6/django/utils/encoding.py", line
 95, in smart_str
     return s.encode(encoding, errors)
 TypeError: encode() takes at most 2 arguments (3 given)
 }}}

-- 
Ticket URL: <http://code.djangoproject.com/ticket/11932>
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 django-updates@googlegroups.com
To unsubscribe from this group, send email to 
django-updates+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to