Bug#495272: deb822 cannot handle unicode fields
John Wright
jsw at debian.org
Tue Sep 16 21:08:38 UTC 2008
repoen 495272
retitle 495272 Deb822.dump() fails when fields contain unicode objects with non-ascii characters
thanks
On Sat, Aug 16, 2008 at 12:45:43AM +0100, Adeodato Simó wrote:
> Maybe I'm mistaken but:
>
> * I can't reproduce the bug with the unpatched version, using my name
> in the Maintainer field of the .dsc file
I have run into this when I have values in Deb822 objects that are
actually unicode objects (not utf-8 encoded strings). I'm hitting it a
lot recently, since I'm interfacing with psycopg2, which returns unicode
objects when pulling strings out of the database.
> * the proposed fix is a no-op (and should hence be reverted), because
> the line "# vim: fileencoding=utf-8" already does what the proposed
> "# -*- coding: utf-8 -*-" does (see PEP 263)
>
> * moreover, the "coding: utf-8" line does not change the default
> encoding of python! Just the encoding on which non-ascii string
> literals should be interpreted within that file
Yes, indeed this didn't actually change anything...
> So, could you provide a file with I could reproduce.
I've attached a script to demonstrate the issue, as well as a proposed
patch. It adds an "encoding" argument to the Deb822Dict.dump() method.
I'm not sure if this is the right answer -- perhaps there is a better
way to write unicode objects to files, or maybe Deb822Dict should only
support already-encoded byte-strings? For what it's worth, I'd prefer
to let it contain unicode objects as values.
--
John Wright <jsw at debian.org>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: test-bug495272.py
Type: text/x-python
Size: 652 bytes
Desc: not available
Url : http://lists.alioth.debian.org/pipermail/pkg-python-debian-maint/attachments/20080916/870f2766/attachment.py
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-Add-an-optional-encoding-arument-to-Deb822Dict.dump.patch
Type: text/x-diff
Size: 0 bytes
Desc: not available
Url : http://lists.alioth.debian.org/pipermail/pkg-python-debian-maint/attachments/20080916/870f2766/attachment.patch
More information about the pkg-python-debian-maint
mailing list