Mercurial > public > mercurial-scm > hg
annotate tests/test-check-py3-commands.t @ 31361:8a17c541177f
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
62939e0148f1 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)
author | FUJIWARA Katsunori <foozy@lares.dti.ne.jp> |
---|---|
date | Mon, 13 Mar 2017 04:06:36 +0900 |
parents | 62939e0148f1 |
children | 3690c75f4d1e |
rev | line source |
---|---|
30129
d69d86e7d6c8
py3: test to check which commands run
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff
changeset
|
1 #require py3exe |
d69d86e7d6c8
py3: test to check which commands run
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff
changeset
|
2 |
d69d86e7d6c8
py3: test to check which commands run
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff
changeset
|
3 This test helps in keeping a track on which commands we can run on |
d69d86e7d6c8
py3: test to check which commands run
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff
changeset
|
4 Python 3 and see what kind of errors are coming up. |
d69d86e7d6c8
py3: test to check which commands run
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff
changeset
|
5 The full traceback is hidden to have a stable output. |
d69d86e7d6c8
py3: test to check which commands run
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff
changeset
|
6 |
d69d86e7d6c8
py3: test to check which commands run
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff
changeset
|
7 $ for cmd in version debuginstall ; do |
d69d86e7d6c8
py3: test to check which commands run
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff
changeset
|
8 > echo $cmd |
d69d86e7d6c8
py3: test to check which commands run
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff
changeset
|
9 > $PYTHON3 `which hg` $cmd 2>&1 2>&1 | tail -1 |
d69d86e7d6c8
py3: test to check which commands run
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff
changeset
|
10 > done |
d69d86e7d6c8
py3: test to check which commands run
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff
changeset
|
11 version |
30586
2d555d753f0e
py3: make keys of keyword arguments strings
Pulkit Goyal <7895pulkit@gmail.com>
parents:
30569
diff
changeset
|
12 warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
30129
d69d86e7d6c8
py3: test to check which commands run
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff
changeset
|
13 debuginstall |
31308
62939e0148f1
policy: try and always have a bytes for module policy
Augie Fackler <raf@durin42.com>
parents:
31304
diff
changeset
|
14 no problems detected |
31304
dab92f3dbd98
py3: add a test that proves %include and missing-extension code works
Augie Fackler <raf@durin42.com>
parents:
30586
diff
changeset
|
15 |
dab92f3dbd98
py3: add a test that proves %include and missing-extension code works
Augie Fackler <raf@durin42.com>
parents:
30586
diff
changeset
|
16 $ cat > included-hgrc <<EOF |
dab92f3dbd98
py3: add a test that proves %include and missing-extension code works
Augie Fackler <raf@durin42.com>
parents:
30586
diff
changeset
|
17 > [extensions] |
dab92f3dbd98
py3: add a test that proves %include and missing-extension code works
Augie Fackler <raf@durin42.com>
parents:
30586
diff
changeset
|
18 > babar = imaginary_elephant |
dab92f3dbd98
py3: add a test that proves %include and missing-extension code works
Augie Fackler <raf@durin42.com>
parents:
30586
diff
changeset
|
19 > EOF |
dab92f3dbd98
py3: add a test that proves %include and missing-extension code works
Augie Fackler <raf@durin42.com>
parents:
30586
diff
changeset
|
20 $ cat >> $HGRCPATH <<EOF |
dab92f3dbd98
py3: add a test that proves %include and missing-extension code works
Augie Fackler <raf@durin42.com>
parents:
30586
diff
changeset
|
21 > %include $TESTTMP/included-hgrc |
dab92f3dbd98
py3: add a test that proves %include and missing-extension code works
Augie Fackler <raf@durin42.com>
parents:
30586
diff
changeset
|
22 > EOF |
dab92f3dbd98
py3: add a test that proves %include and missing-extension code works
Augie Fackler <raf@durin42.com>
parents:
30586
diff
changeset
|
23 $ $PYTHON3 `which hg` version | tail -1 |
dab92f3dbd98
py3: add a test that proves %include and missing-extension code works
Augie Fackler <raf@durin42.com>
parents:
30586
diff
changeset
|
24 *** failed to import extension babar from imaginary_elephant: *: 'imaginary_elephant' (glob) |
dab92f3dbd98
py3: add a test that proves %include and missing-extension code works
Augie Fackler <raf@durin42.com>
parents:
30586
diff
changeset
|
25 warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
31361
8a17c541177f
py3: add "b" prefix to string literals related to module policy
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
31308
diff
changeset
|
26 |
8a17c541177f
py3: add "b" prefix to string literals related to module policy
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
31308
diff
changeset
|
27 Test bytes-ness of policy.policy with HGMODULEPOLICY |
8a17c541177f
py3: add "b" prefix to string literals related to module policy
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
31308
diff
changeset
|
28 |
8a17c541177f
py3: add "b" prefix to string literals related to module policy
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
31308
diff
changeset
|
29 $ HGMODULEPOLICY=py |
8a17c541177f
py3: add "b" prefix to string literals related to module policy
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
31308
diff
changeset
|
30 $ export HGMODULEPOLICY |
8a17c541177f
py3: add "b" prefix to string literals related to module policy
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
31308
diff
changeset
|
31 $ $PYTHON3 `which hg` debuginstall 2>&1 2>&1 | tail -1 |
8a17c541177f
py3: add "b" prefix to string literals related to module policy
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
31308
diff
changeset
|
32 no problems detected |