Mercurial > public > mercurial-scm > hg
comparison tests/testlib/sigpipe-remote.py @ 47636:b2ed9480b34a
sigpipe-remote: check for python version earlier in the script
The should abort early, using the wrong python is a pretty bad sign.
Differential Revision: https://phab.mercurial-scm.org/D11078
author | Pierre-Yves David <pierre-yves.david@octobus.net> |
---|---|
date | Sun, 11 Jul 2021 15:40:06 +0200 |
parents | 27ff81547d35 |
children | d0c0d7b98014 |
comparison
equal
deleted
inserted
replaced
47635:752109dc2fb7 | 47636:b2ed9480b34a |
---|---|
5 import os | 5 import os |
6 import subprocess | 6 import subprocess |
7 import sys | 7 import sys |
8 import time | 8 import time |
9 | 9 |
10 # we cannot use mercurial.testing as long as python2 is not dropped as the test will only install the mercurial module for python2 in python2 run | 10 # we cannot use mercurial.testing as long as python2 is not dropped as the test |
11 # will only install the mercurial module for python2 in python2 run | |
12 if sys.version_info[0] < 3: | |
13 print('SIGPIPE-HELPER: script should run with Python 3', file=sys.stderr) | |
14 sys.exit(255) | |
11 | 15 |
12 if isinstance(sys.stdout.buffer, io.BufferedWriter): | 16 if isinstance(sys.stdout.buffer, io.BufferedWriter): |
13 print('SIGPIPE-HELPER: script need unbuffered output', file=sys.stderr) | 17 print('SIGPIPE-HELPER: script need unbuffered output', file=sys.stderr) |
14 sys.exit(255) | 18 sys.exit(255) |
15 | 19 |
51 with open(path, 'wb') as f: | 55 with open(path, 'wb') as f: |
52 f.write(content) | 56 f.write(content) |
53 | 57 |
54 | 58 |
55 # end of mercurial.testing content | 59 # end of mercurial.testing content |
56 | |
57 if sys.version_info[0] < 3: | |
58 print('SIGPIPE-HELPER: script should run with Python 3', file=sys.stderr) | |
59 sys.exit(255) | |
60 | 60 |
61 | 61 |
62 def sysbytes(s): | 62 def sysbytes(s): |
63 return s.encode('utf-8') | 63 return s.encode('utf-8') |
64 | 64 |