Distinguish byte (python2 str type) and unicode strings (python 3 str type)
Python 3 strings are python 2 unicode strings. Therefore consistently mark strings that are sent via pipes or written/read to file as byte strings.
This commit is contained in:
parent
0d8d19437e
commit
e239820afd
4 changed files with 7 additions and 7 deletions
|
|
@ -246,7 +246,7 @@ if len(sys.argv) != 3:
|
||||||
|
|
||||||
infile = sys.argv[1]
|
infile = sys.argv[1]
|
||||||
htmlfile = sys.argv[2]
|
htmlfile = sys.argv[2]
|
||||||
lines += open(infile).read().decode('utf8').split('\n')
|
lines += open(infile, 'rb').read().decode('utf8').split('\n')
|
||||||
|
|
||||||
# parse pandoc-style document headers (not part of markdown)
|
# parse pandoc-style document headers (not part of markdown)
|
||||||
g = re.match(r'^%\s+(.*?)\((.*?)\)\s+(.*)$', lines[0])
|
g = re.match(r'^%\s+(.*?)\((.*?)\)\s+(.*)$', lines[0])
|
||||||
|
|
|
||||||
|
|
@ -62,7 +62,7 @@ def start_stdin_log_reader(status, details, pretty, color,
|
||||||
# subprocess died without sending us anything: that's bad.
|
# subprocess died without sending us anything: that's bad.
|
||||||
err('failed to start redo-log subprocess; cannot continue.\n')
|
err('failed to start redo-log subprocess; cannot continue.\n')
|
||||||
os._exit(99)
|
os._exit(99)
|
||||||
assert b == 'REDO-OK\n'
|
assert b == b'REDO-OK\n'
|
||||||
# now we know the subproc is running and will report our errors
|
# now we know the subproc is running and will report our errors
|
||||||
# to stderr, so it's okay to lose our own stderr.
|
# to stderr, so it's okay to lose our own stderr.
|
||||||
os.close(ar)
|
os.close(ar)
|
||||||
|
|
@ -218,7 +218,7 @@ class _BuildJob(object):
|
||||||
ffd, fname = tempfile.mkstemp(prefix='redo.', suffix='.tmp')
|
ffd, fname = tempfile.mkstemp(prefix='redo.', suffix='.tmp')
|
||||||
helpers.close_on_exec(ffd, True)
|
helpers.close_on_exec(ffd, True)
|
||||||
os.unlink(fname)
|
os.unlink(fname)
|
||||||
self.outfile = os.fdopen(ffd, 'w+')
|
self.outfile = os.fdopen(ffd, 'w+b')
|
||||||
# this will run in the dofile's directory, so use only basenames here
|
# this will run in the dofile's directory, so use only basenames here
|
||||||
arg1 = basename + ext # target name (including extension)
|
arg1 = basename + ext # target name (including extension)
|
||||||
arg2 = basename # target name (without extension)
|
arg2 = basename # target name (without extension)
|
||||||
|
|
@ -404,7 +404,7 @@ class _BuildJob(object):
|
||||||
# script wrote to stdout. Copy its contents to the tmpfile.
|
# script wrote to stdout. Copy its contents to the tmpfile.
|
||||||
helpers.unlink(self.tmpname)
|
helpers.unlink(self.tmpname)
|
||||||
try:
|
try:
|
||||||
newf = open(self.tmpname, 'w')
|
newf = open(self.tmpname, 'wb')
|
||||||
except IOError as e:
|
except IOError as e:
|
||||||
dnt = os.path.dirname(os.path.abspath(t))
|
dnt = os.path.dirname(os.path.abspath(t))
|
||||||
if not os.path.exists(dnt):
|
if not os.path.exists(dnt):
|
||||||
|
|
|
||||||
|
|
@ -264,7 +264,7 @@ def main():
|
||||||
# their old stderr.
|
# their old stderr.
|
||||||
ack_fd = int(opt.ack_fd)
|
ack_fd = int(opt.ack_fd)
|
||||||
assert ack_fd > 2
|
assert ack_fd > 2
|
||||||
if os.write(ack_fd, 'REDO-OK\n') != 8:
|
if os.write(ack_fd, b'REDO-OK\n') != 8:
|
||||||
raise Exception('write to ack_fd returned wrong length')
|
raise Exception('write to ack_fd returned wrong length')
|
||||||
os.close(ack_fd)
|
os.close(ack_fd)
|
||||||
queue += targets
|
queue += targets
|
||||||
|
|
|
||||||
|
|
@ -128,7 +128,7 @@ def _release(n):
|
||||||
assert _cheats >= 0
|
assert _cheats >= 0
|
||||||
if n_to_share:
|
if n_to_share:
|
||||||
_debug('PUT tokenfds %d\n' % n_to_share)
|
_debug('PUT tokenfds %d\n' % n_to_share)
|
||||||
os.write(_tokenfds[1], 't' * n_to_share)
|
os.write(_tokenfds[1], b't' * n_to_share)
|
||||||
|
|
||||||
|
|
||||||
def _release_except_mine():
|
def _release_except_mine():
|
||||||
|
|
@ -189,7 +189,7 @@ def _try_read(fd, n):
|
||||||
|
|
||||||
|
|
||||||
def _try_read_all(fd, n):
|
def _try_read_all(fd, n):
|
||||||
bb = ''
|
bb = b''
|
||||||
while 1:
|
while 1:
|
||||||
b = _try_read(fd, n)
|
b = _try_read(fd, n)
|
||||||
if not b:
|
if not b:
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue