Mercurial > hg
annotate tests/seq.py @ 47315:825d5a5907b4
exewrapper: avoid directly linking against python3X.dll
Subsequent code calls `LoadLibrary()` to attempt to load the DLL, but because of
this symbol reference, there is an attempt to load the DLL used during the build
prior to `_main()` running. This causes the whole process to fail if the DLL
isn't in the standard search path. That also means it will never load the DLL
for HackableMercurial. (Maybe we should get rid of that for py3, since you can
install python for a user without admin rights?)
This could also be resolved by calling `GetProcAddress()` on the symbol and
dereferencing it, but using the environment variable is consistent with the
*.bat file since fc8a5c9ecee0. (The environment variable persists after the
interpreter is initialized.)
Far more concerning is somehow I've gotten my system into a state where setting
the flag causes any output to the pager to be lost (as if it wasn't set at all)
in MSYS, cmd.exe, WSL, and PowerShell using py3.9.0, but the environment
variable works properly. I'm sure this flag worked on some versions of py3, so
I'm not sure what's going on here. This is might be related to init config
related changes in 3.8[1], since it works with 3.7.8, but fails with 3.8.1.
Somebody who understands encoding issues better than I do should give some
thought to if we need to make some changes to our encoding strategy on Windows
with py3.
With or without the flag/envvar, there is proper output if the command is
directly paged by piping to `more.com` (in any environment) or `less` (in MSYS
and WSL), or if paging is disabled with `--pager=no`. Legacy mode is required
though when Mercurial decides to spin up a pager.
[1] https://bugs.python.org/issue41941
Differential Revision: https://phab.mercurial-scm.org/D10756
author | Matt Harbison <matt_harbison@yahoo.com> |
---|---|
date | Tue, 11 May 2021 01:05:38 -0400 |
parents | c102b704edb5 |
children | 6000f5b25c9b |
rev | line source |
---|---|
45830
c102b704edb5
global: use python3 in shebangs
Gregory Szorc <gregory.szorc@gmail.com>
parents:
43076
diff
changeset
|
1 #!/usr/bin/env python3 |
24360
f554f89a2038
tests: introduce 'seq.py' as a portable replacement for 'seq'
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
2 # |
f554f89a2038
tests: introduce 'seq.py' as a portable replacement for 'seq'
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
3 # A portable replacement for 'seq' |
f554f89a2038
tests: introduce 'seq.py' as a portable replacement for 'seq'
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
4 # |
f554f89a2038
tests: introduce 'seq.py' as a portable replacement for 'seq'
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
5 # Usage: |
f554f89a2038
tests: introduce 'seq.py' as a portable replacement for 'seq'
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
6 # seq STOP [1, STOP] stepping by 1 |
f554f89a2038
tests: introduce 'seq.py' as a portable replacement for 'seq'
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
7 # seq START STOP [START, STOP] stepping by 1 |
f554f89a2038
tests: introduce 'seq.py' as a portable replacement for 'seq'
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
8 # seq START STEP STOP [START, STOP] stepping by STEP |
f554f89a2038
tests: introduce 'seq.py' as a portable replacement for 'seq'
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
9 |
28722
2cd8c3b0bd11
py3: use print_function in seq.py
Robert Stanca <robert.stanca7@gmail.com>
parents:
28721
diff
changeset
|
10 from __future__ import absolute_import, print_function |
40773
0605726179a0
tests: apply binary mode to output in seq.py
Matt Harbison <matt_harbison@yahoo.com>
parents:
35150
diff
changeset
|
11 import os |
24360
f554f89a2038
tests: introduce 'seq.py' as a portable replacement for 'seq'
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
12 import sys |
f554f89a2038
tests: introduce 'seq.py' as a portable replacement for 'seq'
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
13 |
40773
0605726179a0
tests: apply binary mode to output in seq.py
Matt Harbison <matt_harbison@yahoo.com>
parents:
35150
diff
changeset
|
14 try: |
0605726179a0
tests: apply binary mode to output in seq.py
Matt Harbison <matt_harbison@yahoo.com>
parents:
35150
diff
changeset
|
15 import msvcrt |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
40773
diff
changeset
|
16 |
40773
0605726179a0
tests: apply binary mode to output in seq.py
Matt Harbison <matt_harbison@yahoo.com>
parents:
35150
diff
changeset
|
17 msvcrt.setmode(sys.stdin.fileno(), os.O_BINARY) |
0605726179a0
tests: apply binary mode to output in seq.py
Matt Harbison <matt_harbison@yahoo.com>
parents:
35150
diff
changeset
|
18 msvcrt.setmode(sys.stdout.fileno(), os.O_BINARY) |
0605726179a0
tests: apply binary mode to output in seq.py
Matt Harbison <matt_harbison@yahoo.com>
parents:
35150
diff
changeset
|
19 msvcrt.setmode(sys.stderr.fileno(), os.O_BINARY) |
0605726179a0
tests: apply binary mode to output in seq.py
Matt Harbison <matt_harbison@yahoo.com>
parents:
35150
diff
changeset
|
20 except ImportError: |
0605726179a0
tests: apply binary mode to output in seq.py
Matt Harbison <matt_harbison@yahoo.com>
parents:
35150
diff
changeset
|
21 pass |
0605726179a0
tests: apply binary mode to output in seq.py
Matt Harbison <matt_harbison@yahoo.com>
parents:
35150
diff
changeset
|
22 |
35150
08b8b56bd2e8
py3: alias xrange to range in tests/seq.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
28722
diff
changeset
|
23 if sys.version_info[0] >= 3: |
08b8b56bd2e8
py3: alias xrange to range in tests/seq.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
28722
diff
changeset
|
24 xrange = range |
08b8b56bd2e8
py3: alias xrange to range in tests/seq.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
28722
diff
changeset
|
25 |
24360
f554f89a2038
tests: introduce 'seq.py' as a portable replacement for 'seq'
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
26 start = 1 |
f554f89a2038
tests: introduce 'seq.py' as a portable replacement for 'seq'
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
27 if len(sys.argv) > 2: |
f554f89a2038
tests: introduce 'seq.py' as a portable replacement for 'seq'
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
28 start = int(sys.argv[1]) |
f554f89a2038
tests: introduce 'seq.py' as a portable replacement for 'seq'
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
29 |
f554f89a2038
tests: introduce 'seq.py' as a portable replacement for 'seq'
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
30 step = 1 |
f554f89a2038
tests: introduce 'seq.py' as a portable replacement for 'seq'
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
31 if len(sys.argv) > 3: |
f554f89a2038
tests: introduce 'seq.py' as a portable replacement for 'seq'
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
32 step = int(sys.argv[2]) |
f554f89a2038
tests: introduce 'seq.py' as a portable replacement for 'seq'
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
33 |
f554f89a2038
tests: introduce 'seq.py' as a portable replacement for 'seq'
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
34 stop = int(sys.argv[-1]) + 1 |
f554f89a2038
tests: introduce 'seq.py' as a portable replacement for 'seq'
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
35 |
f554f89a2038
tests: introduce 'seq.py' as a portable replacement for 'seq'
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff
changeset
|
36 for i in xrange(start, stop, step): |
28722
2cd8c3b0bd11
py3: use print_function in seq.py
Robert Stanca <robert.stanca7@gmail.com>
parents:
28721
diff
changeset
|
37 print(i) |