From 4e3acdcbdc86cc8d63a3646d6ba93e91bfaac75d Mon Sep 17 00:00:00 2001 From: Adam Date: Tue, 5 Jun 2012 13:22:29 +0200 Subject: [PATCH] Unicode error fix in manpage completion with python3 --- share/tools/create_manpage_completions.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/share/tools/create_manpage_completions.py b/share/tools/create_manpage_completions.py index aca892491..c27b6cf8a 100755 --- a/share/tools/create_manpage_completions.py +++ b/share/tools/create_manpage_completions.py @@ -661,11 +661,14 @@ def parse_manpage_at_path(manpage_path, output_directory): fd = gzip.open(manpage_path, 'r') else: fd = open(manpage_path, 'r') - try: + + try: #Utf-8 python3 + manpage = fd.read() + except: #Latin-1 python3 + fd = open(manpage_path, 'r', encoding='latin-1') manpage = fd.read() - except UnicodeDecodeError: - return fd.close() + manpage = str(manpage) # Get the "base" command, e.g. gcc.1.gz -> gcc