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 705028 - addressbook/libebook/gen-western-table.py is not compatible with python3
addressbook/libebook/gen-western-table.py is not compatible with python3
Status: RESOLVED FIXED
Product: evolution-data-server
Classification: Platform
Component: general
3.8.x (obsolete)
Other Linux
: Normal normal
: ---
Assigned To: Evolution Shell Maintainers Team
Evolution QA team
Depends on:
Blocks: python3
 
 
Reported: 2013-07-28 15:16 UTC by Pacho Ramos
Modified: 2014-02-25 15:05 UTC
See Also:
GNOME target: 3.12
GNOME version: ---


Attachments
gen-western-table.py.patch (1.31 KB, patch)
2013-08-02 17:39 UTC, Arfrever Frehtes Taifersar Arahesis
needs-work Details | Review
gen-western-table.py.patch (1.45 KB, patch)
2013-08-11 07:28 UTC, Arfrever Frehtes Taifersar Arahesis
committed Details | Review

Description Pacho Ramos 2013-07-28 15:16:29 UTC
Even if configure states python3 should be supported:
$ python3 gen-western-table.py 
  • File "gen-western-table.py", line 26
    print "static const gchar %s_table[] = {" % var
SyntaxError: invalid syntax

Comment 1 Matthew Barnes 2013-07-29 11:35:04 UTC
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.
Comment 2 Alexandre Rostovtsev 2013-07-29 13:08:19 UTC
(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.
Comment 3 Matthew Barnes 2013-07-29 13:49:23 UTC
In that case I recommend invoking configure like so for Gentoo:

   PYTHON=/usr/bin/python2 ./configure ...
Comment 4 Arfrever Frehtes Taifersar Arahesis 2013-08-01 20:05:51 UTC
Just port this script to Python 3:
2to3 -f print -nw addressbook/libebook-contacts/gen-western-table.py
Comment 5 Alexandre Rostovtsev 2013-08-02 13:33:55 UTC
(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.
Comment 6 Arfrever Frehtes Taifersar Arahesis 2013-08-02 17:39:57 UTC
Created attachment 250731 [details] [review]
gen-western-table.py.patch

Please test this patch.
Comment 7 Matthew Barnes 2013-08-02 17:44:29 UTC
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.
Comment 8 Arfrever Frehtes Taifersar Arahesis 2013-08-02 17:58:58 UTC
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.
Comment 9 Matthew Barnes 2013-08-02 19:18:36 UTC
Okay, I didn't realize it was still Python 2 compatible.

I'll take a closer look then.
Comment 10 Matthew Barnes 2013-08-11 05:12:23 UTC
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.
Comment 11 Arfrever Frehtes Taifersar Arahesis 2013-08-11 07:28:58 UTC
Created attachment 251293 [details] [review]
 gen-western-table.py.patch

Please try new patch.
Comment 12 Milan Crha 2014-02-25 15:04:52 UTC
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