Commit Graph

4 Commits

Author SHA1 Message Date
FUJIWARA Katsunori
9d450170ba py3: add "b" prefix to string literals related to module policy
String literals without explicit prefix in __init__.py and policy.py
are treated as unicode object on Python3, because these modules are
loaded before setup of our specific code transformation (the later
module is imported at the beginning of __init__.py).

BTW, "modulepolicy" in __init__.py is initialized by "policy.policy".

This causes issues below;

  - checking "policy" value in other modules causes unintentional result

    For example, "b'py' not in (u'c', u'py')" returns True
    unintentionally on Python3.

  - writing "policy" out fails at conversion from unicode to bytes

    db1ebf457295 fixed this issue for default code path, but "policy"
    can be overridden by HGMODULEPOLICY environment variable (it should
    be rare case for developer using Python3, though).

This patch does:

  - add "b" prefix to all string literals, which are related to module
    policy, in modules above.

  - check existence of HGMODULEPOLICY, and overwrite "policy" only if
    it exists

    For simplicity, this patch omits checking "supports_bytes_environ",
    switching os.environ/os.environb, and so on (Yuya agreed this in
    personal talking)
2017-03-13 04:06:36 +09:00
Augie Fackler
f3d54c952b policy: try and always have a bytes for module policy
debuginstall now runs cleanly in Python 3.
2017-03-08 18:11:41 -05:00
Maciej Fijalkowski
7f30335cfb policy: add cffi policy for PyPy
This adds cffi policy in the case where we don't want to use C modules,
but instead we're happy to rely on cffi (bundled with pypy)
2016-06-07 15:35:58 +02:00
timeless
0dcdb26a9d debuginstall: expose modulepolicy
With this, you can check for pure easily:
$ HGMODULEPOLICY=py ./hg debuginstall -T "{hgmodulepolicy}"
py
2016-03-09 19:55:45 +00:00