diff --git a/python/grass/ctypes/ctypesgen/libraryloader.py b/python/grass/ctypes/ctypesgen/libraryloader.py index 4d9201181e0..841572dad34 100644 --- a/python/grass/ctypes/ctypesgen/libraryloader.py +++ b/python/grass/ctypes/ctypesgen/libraryloader.py @@ -168,6 +168,7 @@ def getdirs(self, libname): dyld_fallback_library_path = _environ_path("DYLD_FALLBACK_LIBRARY_PATH") if not dyld_fallback_library_path: dyld_fallback_library_path = [os.path.expanduser("~/lib"), "/usr/local/lib", "/usr/lib"] + dyld_fallback_library_path.extend(_environ_path('LD_RUN_PATH')) dirs = [] diff --git a/python/grass/ctypes/ctypesgen/parser/preprocessor.py b/python/grass/ctypes/ctypesgen/parser/preprocessor.py index 6f542e7759c..a2a4e12d784 100755 --- a/python/grass/ctypes/ctypesgen/parser/preprocessor.py +++ b/python/grass/ctypes/ctypesgen/parser/preprocessor.py @@ -159,10 +159,29 @@ def parse(self, filename): self.cparser.handle_status(cmd) - pp = subprocess.Popen( - cmd, shell=True, universal_newlines=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE - ) - ppout, pperr = pp.communicate() + pp = subprocess.Popen(cmd, + shell=True, + universal_newlines=True, + stdout=subprocess.PIPE, + stderr=subprocess.PIPE) + try: + ppout, pperr = pp.communicate() + except UnicodeError: + # Fix for https://trac.osgeo.org/grass/ticket/3883, + # handling file(s) encoded with mac_roman + if sys.platform == 'darwin': + pp = subprocess.Popen(cmd, + shell=True, + universal_newlines=False, # read as binary + stdout=subprocess.PIPE, + stderr=subprocess.PIPE) + ppout, pperr = pp.communicate() + + data = ppout.decode('utf8', errors='replace') + ppout = data.replace('\r\n', '\n').replace('\r', '\n') + pperr = pperr.decode('utf8', errors='replace') + else: + raise UnicodeError for line in pperr.split("\n"): if line: