comparison setup.py @ 44742:380959c6f75e stable

setup: use sysstr() on process output Otherwise we get a str-bytes mismatch on Python 3 if an error occurs. Differential Revision: https://phab.mercurial-scm.org/D8469
author Gregory Szorc <gregory.szorc@gmail.com>
date Sun, 19 Apr 2020 17:26:52 -0700
parents 26ce8e751503
children 91e509a12dbc 47787a48f469
comparison
equal deleted inserted replaced
44741:1b80e684813b 44742:380959c6f75e
888 res, out, err = runcmd( 888 res, out, err = runcmd(
889 [sys.executable, 'gendoc.py', root], os.environ, cwd='doc' 889 [sys.executable, 'gendoc.py', root], os.environ, cwd='doc'
890 ) 890 )
891 if res: 891 if res:
892 raise SystemExit( 892 raise SystemExit(
893 'error running gendoc.py: %s' % '\n'.join([out, err]) 893 'error running gendoc.py: %s'
894 % '\n'.join([sysstr(out), sysstr(err)])
894 ) 895 )
895 896
896 with open(txt, 'wb') as fh: 897 with open(txt, 'wb') as fh:
897 fh.write(out) 898 fh.write(out)
898 899
905 os.environ, 906 os.environ,
906 cwd='doc', 907 cwd='doc',
907 ) 908 )
908 if res: 909 if res:
909 raise SystemExit( 910 raise SystemExit(
910 'error running gendoc: %s' % '\n'.join([out, err]) 911 'error running gendoc: %s'
912 % '\n'.join([sysstr(out), sysstr(err)])
911 ) 913 )
912 914
913 with open(gendoc, 'wb') as fh: 915 with open(gendoc, 'wb') as fh:
914 fh.write(out) 916 fh.write(out)
915 917
930 os.environ, 932 os.environ,
931 cwd='doc', 933 cwd='doc',
932 ) 934 )
933 if res: 935 if res:
934 raise SystemExit( 936 raise SystemExit(
935 'error running runrst: %s' % '\n'.join([out, err]) 937 'error running runrst: %s'
938 % '\n'.join([sysstr(out), sysstr(err)])
936 ) 939 )
937 940
938 normalizecrlf('doc/%s' % root) 941 normalizecrlf('doc/%s' % root)
939 942
940 def genhtml(root): 943 def genhtml(root):
955 os.environ, 958 os.environ,
956 cwd='doc', 959 cwd='doc',
957 ) 960 )
958 if res: 961 if res:
959 raise SystemExit( 962 raise SystemExit(
960 'error running runrst: %s' % '\n'.join([out, err]) 963 'error running runrst: %s'
964 % '\n'.join([sysstr(out), sysstr(err)])
961 ) 965 )
962 966
963 normalizecrlf('doc/%s.html' % root) 967 normalizecrlf('doc/%s.html' % root)
964 968
965 # This logic is duplicated in doc/Makefile. 969 # This logic is duplicated in doc/Makefile.