GNOME Bugzilla – Bug 705028
addressbook/libebook/gen-western-table.py is not compatible with python3
Last modified: 2014-02-25 15:05:06 UTC
Even if configure states python3 should be supported: $ python3 gen-western-table.py
+ Trace 232307
print "static const gchar %s_table[] = {" % var
The first line of the script explicitly indicates this is Python 2 code: #! /usr/bin/env python But AM_PATH_PYTHON isn't helpful about explicitly requiring Python 2, not 3. (I would have expected a new, incompatible version of Python to call for a separate AM_PATH_PYTHON3 macro, but what do I know.) Suggestions welcome.
(In reply to comment #1) > The first line of the script explicitly indicates this is Python 2 code: > > #! /usr/bin/env python Whether or not that's explicit depends on the distro :) In Gentoo, Python 2 is /usr/bin/env python2; Python 3 is /usr/bin/env python3. But /usr/bin/env python can be Python 2 or 3 - whichever was locally configured to be the default.
In that case I recommend invoking configure like so for Gentoo: PYTHON=/usr/bin/python2 ./configure ...
Just port this script to Python 3: 2to3 -f print -nw addressbook/libebook-contacts/gen-western-table.py
(In reply to comment #4) > Just port this script to Python 3: > 2to3 -f print -nw addressbook/libebook-contacts/gen-western-table.py Unfortunately, it's not so easy. The script needs to count bytes in a newline-delimeted utf8 stream. If you simply convert gen-western-table.py with 2to3, it will *silently produce the wrong output* when run under python3.
Created attachment 250731 [details] [review] gen-western-table.py.patch Please test this patch.
I still think you would be better off explicitly specifying the Python binary path as part of the configure command, especially if "/usr/bin/python" can be different versions for different people. See comment 3. That the script is written in Python 2 instead of 3 is not a valid bug.
My patch is supposed to make this script work with any Python >=2.6. Many users want to uninstall Python 2 and keep only Python 3.
Okay, I didn't realize it was still Python 2 compatible. I'll take a closer look then.
Review of attachment 250731 [details] [review]: I gave the patch a try. Seems to work fine with Python 2, but with Python 3 the output lines are all printed as "bytes" literals: e.g. b'static const gchar western_pfx_table[] = {' I don't know why the script is using "bytes" literals, which is intended for binary data, when the generated C file is supposed to be ASCII.
Created attachment 251293 [details] [review] gen-western-table.py.patch Please try new patch.
The patches script produces exactly the same file for both python2 and python3, thus I'm committing it to master. Created commit 86a6596 in eds master (3.11.91+) [1] [1] https://git.gnome.org/browse/evolution-data-server/commit/?id=86a6596