Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MessageID broken for Python 3; produces byte domains which can't find utilities #17

Closed
jamadden opened this issue Apr 25, 2017 · 1 comment

Comments

@jamadden
Copy link
Member

As discovered in zope.app.form, when reading a MessageID field out of a ZCML file, the domain will be a byte string under Python 3 (e.g., b'zope'). But zope.i18n registers ITranslationDomain utilities with normal str names. Since no byte string can ever equal a str on Python 3, the utilities will never be found and translation will not happen.

It seems to me that either MessageID should ensure that the domain is a str (decoding from...utf-8?) or the context itself could ensure that its i18n_domain is a str. I think I like the latter better.

@jamadden
Copy link
Member Author

It looks like the IZopeConfigure schema defines i18n_domain as a BytesLine because it's meant to deal with the filesystem. That's probably not really correct on Python 3, when paths changed to be decoded strs (though bytes are often still accepted by the path APIs).

So it seems the simplest change will be to handle this in MessageID, and use sys.getfilesystemencoding to handle the decoding.

jamadden added a commit that referenced this issue Apr 25, 2017
Fixes #17.

Also use zope.testrunner to handle the namespace package issues.

Fixes #16.

Since we were in .travis.yml, enable coverage reporting and pip
caching.
jamadden added a commit that referenced this issue Apr 25, 2017
Fixes #17.

Also use zope.testrunner to handle the namespace package issues.

Fixes #16.

Since we were in .travis.yml, enable coverage reporting and pip
caching.
jamadden added a commit to zopefoundation/zope.app.form that referenced this issue Apr 26, 2017
clrpackages pushed a commit to clearlinux-pkgs/zope.configuration that referenced this issue Dec 12, 2017
…o version 4.1.0

Adam Groszer (1):
      update bootstrap.py

Felix Yan (2):
      Note explicit support for Python 3.5
      Use shields.io for PyPI badge

Jan-Jaap Driessen (4):
      Python3 support for printing ConfigurationExecutionError
      Add swp file to ignore list.
      Test for py3 support in ConfigurationConflictError.
      Merge pull request #14 from zopefoundation/resurrection-python3

Jason Madden (5):
      Make MessageID decode a bytes domain.
      whitespace [skip ci]
      Merge pull request #18 from zopefoundation/issue17
      Wheels are universal
      Preparing release 4.1.0

Marius Gedminas (8):
      Update to latest bootstrap.py
      Merge pull request #1 from bunyk/patch-1
      Make sure MANIFEST.in is complete
      Switch basepython to 2.7 for docs and coverage
      Merge pull request #11 from felixonmars/master
      Mention 3.5 in the changelog
      Merge pull request #12 from felixonmars/master
      Claim support for Python 3.6

Michael Howitz (3):
      Point to the repos.
      Point to the canonical URL
      Use the new TLD of RTD.

Taras (1):
      Fix docstring for processxmlfile

Tres Seaver (22):
      svb
      Speed up Travis start via 'sudo: false'.
      Update to latest bootstrap.
      Add Travis badge, garden ReST.
      Bow to our new PEP 440 overlords.
      Update hacking docs to point to Github.
      Remove no-longer true mention of building docs in buildout.
      Edit myself out in favor of J. Random Hacker.
      Remove SVN fossil
      Silence Sphinx warning.
      Add RTD dependency.
      Add PyPI and RTD badges.
      Silence setuptools faux warnings.
      Tox cleanups:
      Add explicit support for Python 3.4 on Travis.
      Drop support for Python 2.6 and 3.2.
      Merge pull request #13 from zopefoundation/drop-py26-py32-support
      Remove commented-out mention of py32 environment.
      Use stdlib's 'assertRaises'.
      'assertTrue(foo in bar)'->'assertIn(foo, bar)'.
      'assertTrue(isinstance(foo, Bar)'->'assertIsInstance(foo, Bar)'.
      Merge pull request #15 from zopefoundation/use-stdlib-assertRaises

4.1.0 (2017-04-26)
------------------

- Drop support for Python 2.6 and 3.2.

- Add support for Python 3.5 and 3.6.

- Fix the ``domain`` of MessageID fields to be a native string.
  Previously on Python 3 they were bytes, which meant that they
  couldn't be used to find translation utilities registered by
  zope.i18n. See `issue 17 <https://github.com/zopefoundation/zope.configuration/issues/17>`_.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant