From e372db985fd18c712271a7c68f611c61193a95f3 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Fri, 1 May 2020 22:05:54 +0530 Subject: [PATCH] Port sphinx diffing code to py3 --- manual/custom.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/manual/custom.py b/manual/custom.py index 26af36a67b..f768988c15 100644 --- a/manual/custom.py +++ b/manual/custom.py @@ -198,10 +198,10 @@ def generate_ebook_convert_help(preamble, app): def update_cli_doc(name, raw, app): - if isinstance(raw, type(u'')): - raw = raw.encode('utf-8') + if isinstance(raw, bytes): + raw = raw.decode('utf-8') path = 'generated/%s/%s.rst' % (app.config.language, name) - old_raw = open(path, 'rb').read() if os.path.exists(path) else '' + old_raw = open(path, encoding='utf-8').read() if os.path.exists(path) else '' if not os.path.exists(path) or old_raw != raw: import difflib print(path, 'has changed') @@ -214,7 +214,7 @@ def update_cli_doc(name, raw, app): p = os.path.dirname(path) if p and not os.path.exists(p): os.makedirs(p) - open(path, 'wb').write(raw) + open(path, 'wb').write(raw.encode('utf-8')) def render_options(cmd, groups, options_header=True, add_program=True, header_level='~'):