[Checkins] [zopefoundation/zope.configuration] 10c1b8: Cope with unicode __all__ in Python 2 packages

GitHub noreply at github.com
Thu May 3 15:21:03 CEST 2018


  Branch: refs/heads/master
  Home:   https://github.com/zopefoundation/zope.configuration
  Commit: 10c1b82508eff4d96e5203702b975623a9a9b36d
      https://github.com/zopefoundation/zope.configuration/commit/10c1b82508eff4d96e5203702b975623a9a9b36d
  Author: Colin Watson <cjwatson at debian.org>
  Date:   2018-02-02 (Fri, 02 Feb 2018)

  Changed paths:
    M CHANGES.rst
    M src/zope/configuration/config.py
    M src/zope/configuration/tests/test_config.py
    A src/zope/configuration/tests/unicode_all/__init__.py

  Log Message:
  -----------
  Cope with unicode __all__ in Python 2 packages

When porting a package from Python 2 to 3, one natural path involves
adding `from __future__ import unicode_literals` everywhere to prepare
for the `bytes`/`unicode` change.  This can cause `__all__` to contain
`unicode` elements, which mostly works but breaks star imports as
follows (depending on the exact Python version - see
https://bugs.python.org/issue21720):

    TypeError: Item in ``from list'' not a string

    TypeError: Item in ``from list'' must be str, not unicode

Star imports can usually be avoided, but it's hard to avoid this
behaviour of zope.configuration if you're using ZCML, so it seems worth
adjusting `ConfigurationContext.resolve` slightly to avoid the problem.
The `sys.modules` logic is borrowed from 2.7's
`importlib.import_module`.  (Using `importlib` directly here is tricky
because of the care we take with tracebacks, but for the time being we
can still get by with `__import__`.)


  Commit: 0546515d5967339ad584f15b2a1af763bdb85126
      https://github.com/zopefoundation/zope.configuration/commit/0546515d5967339ad584f15b2a1af763bdb85126
  Author: Colin Watson <cjwatson at debian.org>
  Date:   2018-05-03 (Thu, 03 May 2018)

  Changed paths:
    M src/zope/configuration/config.py

  Log Message:
  -----------
  Add rationale comment


  Commit: 4a4c1a045f409c35ad9407ecb3aa7e53c42197ca
      https://github.com/zopefoundation/zope.configuration/commit/4a4c1a045f409c35ad9407ecb3aa7e53c42197ca
  Author: Colin Watson <cjwatson at ubuntu.com>
  Date:   2018-05-03 (Thu, 03 May 2018)

  Changed paths:
    M CHANGES.rst
    M src/zope/configuration/config.py
    M src/zope/configuration/tests/test_config.py
    A src/zope/configuration/tests/unicode_all/__init__.py

  Log Message:
  -----------
  Merge pull request #19 from cjwatson/unicode-all

Cope with unicode __all__ in Python 2 packages


Compare: https://github.com/zopefoundation/zope.configuration/compare/24d5808a53c5...4a4c1a045f40
      **NOTE:** This service been marked for deprecation: https://developer.github.com/changes/2018-04-25-github-services-deprecation/

      Functionality will be removed from GitHub.com on January 31st, 2019.


More information about the checkins mailing list