[rfc] bencode unicode strings
Aaron Bentley
aaron at aaronbentley.com
Tue Jun 16 16:15:26 BST 2009
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Alexander Belchenko wrote:
> Thanks for the hints.
>
> Aaron Bentley пишет:
> No, Configobj can work in bytestring or unicode modes.
>
>> AFAICT it's not quite true re writing non-ascii data to file.
>> According to ConfigObj documentation:
>
>> "When using the write method, ConfigObj uses the encoding attribute to
>> encode the Unicode strings.
But when the encoding attribute is None, it does not encode strings.
>> So I'm doubt one can write any byte stream to config file (because
>> configobj will try to decode these bytes to unicode under the hood).
> If you're storing them in config files, you should generally store
> human-readable values. ConfigObj supports dict of (dicts of) unicode
> strings-- isn't that sufficient?
>
>> Do you mean standard ConfigObj interface as dict-like object?
>> Yep, it will work, just require to use ConfigObj directly and bypassing
>> internal config classes from bzrlib.
I think you can actually use the standard API (though this wasn't
intended behaviour)
$ python
Python 2.6.2 (release26-maint, Apr 19 2009, 01:56:41)
[GCC 4.3.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import bzrlib.config
>>> bzrlib.config.GlobalConfig().set_user_option('foo', {'me':'you'})
>>> bzrlib.config.GlobalConfig().get_user_option('foo')
{u'me': u'you'}
Aaron
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
iEYEARECAAYFAko3twsACgkQ0F+nu1YWqI2wlwCfZqTbecvyzEfIwSkCSAgsXEN2
3lcAnjZ63jg+8WW6WrLWOVkIgF9E7Tww
=HQ31
-----END PGP SIGNATURE-----
More information about the bazaar
mailing list