From 2ca1bc433f4a8e5c922f2b0e5658fda7f738e746 Mon Sep 17 00:00:00 2001 From: David Adam Date: Fri, 12 Apr 2019 23:07:41 +0800 Subject: [PATCH] fish_indent_lexer: explicitly encode/decode bytes over pipe Universal newlines behaves differently between Python 2.7 and 3.x, leading to problems when running Sphinx with Python 2.7. fish_indent always uses \n, so there's no need to use universal newline detection. This also allows full UTF-8 in documentation sources. Closes #5808. --- sphinx_doc_src/fish_indent_lexer.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/sphinx_doc_src/fish_indent_lexer.py b/sphinx_doc_src/fish_indent_lexer.py index c3414f2c2..f704e5691 100644 --- a/sphinx_doc_src/fish_indent_lexer.py +++ b/sphinx_doc_src/fish_indent_lexer.py @@ -89,11 +89,11 @@ def tokenize_fish_command(code, offset): ["fish_indent", "--pygments"], stdin=subprocess.PIPE, stdout=subprocess.PIPE, - universal_newlines=True, + universal_newlines=False, ) - stdout, _ = proc.communicate(code) + stdout, _ = proc.communicate(code.encode('utf-8')) result = [] - for line in stdout.splitlines(): + for line in stdout.decode('utf-8').splitlines(): start, end, role = line.split(",") start, end = int(start), int(end) value = code[start:end]