Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit ae62a35

Browse files
committed
MNT : better error handling on determining gs version
If we fail to parse the version string return (0, 0) to let the code for dealing with out-of-date versions of gs handle the case of not installed.
1 parent 010a485 commit ae62a35

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

lib/matplotlib/backends/backend_ps.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ def _fn_name(): return sys._getframe(1).f_code.co_name
5656

5757
debugPS = 0
5858

59+
5960
class PsBackendHelper(object):
6061

6162
def __init__(self):
@@ -78,7 +79,6 @@ def gs_exe(self):
7879
self._cached["gs_exe"] = gs_exe
7980
return gs_exe
8081

81-
8282
@property
8383
def gs_version(self):
8484
"""
@@ -97,8 +97,11 @@ def gs_version(self):
9797
ver = pipe.decode('ascii')
9898
else:
9999
ver = pipe
100-
gs_version = tuple(map(int, ver.strip().split(".")))
101-
100+
try:
101+
gs_version = tuple(map(int, ver.strip().split(".")))
102+
except ValueError:
103+
# if something went wrong parsing return null version number
104+
gs_version = (0, 0)
102105
self._cached["gs_version"] = gs_version
103106
return gs_version
104107

0 commit comments

Comments
 (0)