From 7b10da991820caae04a2387683946dde3e71bb2c Mon Sep 17 00:00:00 2001 From: MortenSHUTE <42337534+MortenSHUTE@users.noreply.github.com> Date: Mon, 13 Aug 2018 10:14:04 +0200 Subject: [PATCH 1/3] Country specific characters in Windows user folder name MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change to utf-8 format, due to return result.decode('ascii') returning an UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 17: ordinal not in range(128), when æ,ø or å appears in the path to the .tfm-file. --- lib/matplotlib/dviread.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/matplotlib/dviread.py b/lib/matplotlib/dviread.py index f738fb591d3e..b7538be19443 100644 --- a/lib/matplotlib/dviread.py +++ b/lib/matplotlib/dviread.py @@ -1021,7 +1021,7 @@ def find_tex_file(filename, format=None): pipe = subprocess.Popen(cmd, stdout=subprocess.PIPE) result = pipe.communicate()[0].rstrip() _log.debug('find_tex_file result: %s', result) - return result.decode('ascii') + return result.decode('utf-8') @lru_cache() From d893d3c09884ba4d041e6b76413422d3804ed5d9 Mon Sep 17 00:00:00 2001 From: MortenSHUTE <42337534+MortenSHUTE@users.noreply.github.com> Date: Tue, 14 Aug 2018 13:33:53 +0200 Subject: [PATCH 2/3] Updated with try and except error catch --- lib/matplotlib/dviread.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/lib/matplotlib/dviread.py b/lib/matplotlib/dviread.py index b7538be19443..a7ccf4afd022 100644 --- a/lib/matplotlib/dviread.py +++ b/lib/matplotlib/dviread.py @@ -1021,7 +1021,14 @@ def find_tex_file(filename, format=None): pipe = subprocess.Popen(cmd, stdout=subprocess.PIPE) result = pipe.communicate()[0].rstrip() _log.debug('find_tex_file result: %s', result) - return result.decode('utf-8') + + # workaround for when a tex file has a country + # specfic character in its path name + try: + res = result.decode('ascii') + except UnicodeDecodeError: + res = result.decode('utf-8') + return res @lru_cache() From 9ebf878bc8c26eee4b4c1c0c69c26c8f73c9545f Mon Sep 17 00:00:00 2001 From: MortenSHUTE <42337534+MortenSHUTE@users.noreply.github.com> Date: Wed, 15 Aug 2018 13:08:27 +0200 Subject: [PATCH 3/3] Removed whitespaces from line 1024 --- lib/matplotlib/dviread.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/matplotlib/dviread.py b/lib/matplotlib/dviread.py index a7ccf4afd022..f8c353e179a8 100644 --- a/lib/matplotlib/dviread.py +++ b/lib/matplotlib/dviread.py @@ -1021,7 +1021,7 @@ def find_tex_file(filename, format=None): pipe = subprocess.Popen(cmd, stdout=subprocess.PIPE) result = pipe.communicate()[0].rstrip() _log.debug('find_tex_file result: %s', result) - + # workaround for when a tex file has a country # specfic character in its path name try: