After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 696633 - gdbus-codegen trips over unicode chars when using python 3.x
gdbus-codegen trips over unicode chars when using python 3.x
Status: RESOLVED FIXED
Product: glib
Classification: Platform
Component: gdbus
2.35.x
Other Linux
: Normal normal
: ---
Assigned To: David Zeuthen (not reading bugmail)
gtkdev
Depends on:
Blocks:
 
 
Reported: 2013-03-26 12:28 UTC by Jan de Groot
Modified: 2013-08-17 04:44 UTC
See Also:
GNOME target: 3.10
GNOME version: ---


Attachments
codegen: Treat input file as binary (1.00 KB, patch)
2013-08-16 15:58 UTC, Daiki Ueno
committed Details | Review

Description Jan de Groot 2013-03-26 12:28:37 UTC
An example of this is gnome-terminal which contains the copyright symbol in one of the XML files. This has never been any issue when gdbus-codegen was called from python 2.x, but with 3.x it throws an exception:

  GEN    terminal-gdbus-generated.c
Traceback (most recent call last):
  • File "/usr/bin/gdbus-codegen", line 41 in <module>
    sys.exit(codegen_main.codegen_main())
  • File "/usr/share/glib-2.0/codegen/codegen_main.py", line 170 in codegen_main
    xml_data = f.read()
  • File "/usr/lib/python3.3/encodings/ascii.py", line 26 in decode
    return codecs.ascii_decode(input, self.errors)[0]
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc2 in position 212: ordinal not in range(128)

Comment 1 Daiki Ueno 2013-08-16 15:58:40 UTC
Created attachment 251905 [details] [review]
codegen: Treat input file as binary

Under C locale, open() in Python 3 sets the file encoding to ASCII.
As expat looks at encoding="..." in XML declaration, gdbus-codegen can
simply open the input file as binary and let expat decode the content.
--
Tested with both Python 2 and 3, seems to work.
Comment 2 Matthias Clasen 2013-08-17 03:53:04 UTC
Review of attachment 251905 [details] [review]:

thanks
Comment 3 Daiki Ueno 2013-08-17 04:44:21 UTC
Attachment 251905 [details] pushed as a7f2765 - codegen: Treat input file as binary