Roundup Tracker - Issues

Issue 2550520

classification
pygettext.py won't work in some Python 2.6 setups
Type: compile error Severity: normal
Components: Infrastructure Versions: 1.4
process
Status: closed fixed
:
: : ber, richard, stefan, tobias-herp
Priority: : patch

Created on 2009-02-25 15:29 by tobias-herp, last changed 2011-07-01 13:43 by ber.

Files
File name Uploaded Description Edit Remove
pygettext.patch tobias-herp, 2009-02-25 15:29 insert encoding comment
Messages
msg3591 Author: [hidden] (tobias-herp) Date: 2009-02-25 15:29
pygettext.py contains umlauts (at least one), but it doesn't contain
a magical comment to specify the encoding.  My Python 2.6 installation
refused to execute it.

The new comment works for both Python ("coding") and vim ("enc",
"encoding").
msg3592 Author: [hidden] (stefan) Date: 2009-02-25 18:26
Tobias,

My Fedora 9 distribution provides a 'python-tools' package, of which a
'pygettext.py' script is part of. As it is almost identical to the one
in tools/ (only some formatting differences), but it contains the
encoding specifier that you are looking for (# -*- coding: iso-8859-1
-*-), I suggest we replace ours with that.

Also, with this script I don't think there is any need for that 'xpot'
tool that local/GNUmakefile wants.
msg3599 Author: [hidden] (tobias-herp) Date: 2009-02-26 19:32
Since lots of our source files contain vim magical comments (at the top
or bottom), I reckon vim is more common in our community than emacs (-*-
coding: ... -*- being an "emacs cookie").

Python looks for something like "coding[:=]\s*([-\w.]+)" (pep 0263, see
http://www.python.org/dev/peps/pep-0263/; 'coding', a ':' or '=',
optional whitespace, and the encoding spec.).

Vim looks for 'enc=' or 'encoding='; the latter works for Python, too.
The emacs cookie is not recognised by vim (by default).
msg3600 Author: [hidden] (stefan) Date: 2009-02-26 19:39
Tobias wrote:

> Since lots of our source files contain vim magical comments (at the top
> or bottom), I reckon vim is more common in our community than emacs (-*-
> coding: ... -*- being an "emacs cookie").

May be so, but does that really matter ? We are not going to develop 
this tool, so all that matters is whether Python itself is happy. I 
suggest we just take whatever version is in use 'out there'.
msg3601 Author: [hidden] (tobias-herp) Date: 2009-02-26 19:46
I just read your comment again (sorry for the noise).  If the fedora
version of pygettext is "nicer" than ours (containing e.g. formfeed
characters, two of them just 8 lines apart), I don't oppose using it.

However, -*- coding: .. -*- is in no way "better" or "more correct" ;-)
msg3602 Author: [hidden] (stefan) Date: 2009-02-26 19:55
Tobias wrote:

> I just read your comment again (sorry for the noise).  If the fedora
> version of pygettext is "nicer" than ours (containing e.g. formfeed
> characters, two of them just 8 lines apart), I don't oppose using it.

Good. I have no opinion about whether it's nicer. But it is 'more 
correct' in that it has an encoding declaration while ours has not.
So, fixed with rev:4172.

> However, -*- coding: .. -*- is in no way "better" or "more correct" ;-)

I never said it was, did I ? :-)

OK, the next step is to adjust the locale/GNUmakefile to use that, and 
then figure out why 'make -C locale' fails, and fix those issues.
(I intend to add a new build (sub-)command so this localization step 
gets integrated in the overall 'python setup.py ...' build process. But 
first we have to fix it.)

Thanks,
msg4317 Author: [hidden] (ber) Date: 2011-07-01 13:43
Okay, pygettext.py works now with python 2.6 since Stefan's change.
I am not sure about the other issues mentioned in msg3602, though.
This way an elder version, so maybe it needs to be reopened
when the issue is still there.
History
Date User Action Args
2011-07-01 13:43:30bersetstatus: new -> closed
nosy: + ber
resolution: fixed
messages: + msg4317
2009-02-26 19:55:50stefansetmessages: + msg3602
2009-02-26 19:46:49tobias-herpsetmessages: + msg3601
2009-02-26 19:39:53stefansetmessages: + msg3600
2009-02-26 19:32:14tobias-herpsetmessages: + msg3599
2009-02-25 18:26:17stefansetnosy: + stefan, richard
messages: + msg3592
2009-02-25 15:29:49tobias-herpcreate