collective / i18ndude

i18ndude performs various tasks related to ZPT's, Python Scripts and i18n.
https://pypi.org/project/i18ndude
4 stars 9 forks source link

Update pygettext to avoid test warnings on python 3.6 #61

Closed mauritsvanrees closed 2 years ago

mauritsvanrees commented 6 years ago

On Python 3.6 I get a warning when running the tests:

$ bin/test 
/Users/maurits/tools/src/i18ndude/src/i18ndude/pygettext.py:159: 
DeprecationWarning: the imp module is deprecated in favour of importlib; 
see the module's documentation for alternative uses
  import imp
/Users/maurits/tools/src/i18ndude/lib/python3.6/importlib/_bootstrap.py:219: 
ImportWarning: can't resolve package from __spec__ or __package__, 
falling back on __name__ and __path__
  return f(*args, **kwds)
...

This is only during tests, not during normal handling. Our pygettext.py is an old copy from a file that is now in the core Python source code. When I copy that version, we need two small fixes in our extract.py to call normalize with an extra encoding argument utf-8. Then the tests almost pass on Python 3. There is one failure:

File "/Users/maurits/tools/src/i18ndude/src/i18ndude/extract.py", line 139, 
in i18ndude.extract.POTEntry
Failed example:
    entry.write(FakeFile())
Expected:
    #. Default: "送信"
    msgid "send"
    msgstr ""
    <BLANKLINE>
Got:
    #. Default: "\351\200\201\344\277\241"
    msgid "send"
    msgstr ""
    <BLANKLINE>

So this fails with a message with a non-ascii default, which should not happen in English normally. So for most cases we could live with this.

But on Python2 it is broken. A few print statements are fixable, but we get an ImportError for import importlib.machinery. I haven't dived in, but I expect that on Python 2 you would have to use the imp module instead, which is what Python 3.6 was warning about all along.

So that seems something to pick up somewhere in 2020. :-)

gforcada commented 2 years ago

I guess this is long fixed since, or? re-open otherwise 😄