Re: [pyxser-users] Pyxser generates strange 'name' attribute values
Brought to you by:
damowe
From: Max S. <ms...@gm...> - 2010-05-05 05:20:33
|
Hi, Daniel. I've tested version from svn trunk. It segfaults now when working with unicode dictionaries keys. This is a console session to reproduce an error: >>> import pyxser >>> import inspect >>> selector = lambda o: dict(filter(lambda (name,value): not (name.startswith('_') or callable(value)), inspect.getmembers(o))) # not unicode key and value >>> class T: ... def __init__(self, d): ... self.d = d ... >>> t = T({'hehe':'lala'}) >>> t.d {'hehe': 'lala'} >>> s = pyxser.serialize(obj=t,enc='utf-8',selector=selector) >>> print s <?xml version="1.0" encoding="utf-8"?> <pyxs:obj xmlns:pyxs="http://projects.coder.cl/pyxser/model/" version="1.0" type="T" module="pylons-admin" objid="id-33308472"> <pyxs:col type="dict" name="d"> <pyxs:prop type="str" name="hehe">lala</pyxs:prop> </pyxs:col> </pyxs:obj> Seems ok. Now with unicode string as a key: >>> t = T({u'хехе': 'hehe'}) # Russian cyrillic in the dict key >>> t.d {u'\xd1\x85\xd0\xb5\xd1\x85\xd0\xb5': 'hehe'} >>> s = pyxser.serialize(obj=t,enc='utf-8',selector=selector) Segmentation Fault Oops. But it works fine with non-unicode based dictionary keys and values: >>> t = T({'хехе': 'ололо!'}) # Russian cyrillic in the key and value >>> t.d {'\xd1\x85\xd0\xb5\xd1\x85\xd0\xb5': '\xd0\xbe\xd0\xbb\xd0\xbe\xd0\xbb\xd0\xbe!'} >>> s = pyxser.serialize(obj=t,enc='utf-8',selector=selector) >>> print s <?xml version="1.0" encoding="utf-8"?> <pyxs:obj xmlns:pyxs="http://projects.coder.cl/pyxser/model/" version="1.0" type="T" module="pylons-admin" objid="id-33308400"> <pyxs:col type="dict" name="d"> <pyxs:prop type="str" name="хехе">ололо!</pyxs:prop> </pyxs:col> </pyxs:obj> It works with unicode-based dictionary values too. The problem is only with unicode keys. Best regards, Max Sinelnikov. |