diff --git a/refl1d/garefl.py b/refl1d/garefl.py index ef73749c..e584981e 100644 --- a/refl1d/garefl.py +++ b/refl1d/garefl.py @@ -32,6 +32,7 @@ """ __all__ = ["load"] +import sys import os from os import getpid from ctypes import CDLL, c_int, c_double, c_void_p, c_char_p, byref @@ -49,6 +50,13 @@ from .profile import Microslabs from .material import SLD, Vacuum +if sys.version_info[0] >= 3: + def tostr(s): + return s.decode('ascii') +else: + def tostr(s): + return s + def trace(fn): """simple function trace function""" return fn # Comment this to turn on tracing @@ -240,7 +248,7 @@ def _getdata(self, k, xs): if n == 0: return None data = empty((n, 4), 'd') - filename = self.dll.ex_get_data(self.models, k, xs, data.ctypes) + filename = tostr(self.dll.ex_get_data(self.models, k, xs, data.ctypes)) Q, dQ, R, dR = data.T probe = QProbe(Q, dQ, data=(R, dR), name=filename) return probe @@ -276,7 +284,7 @@ def output_model(self): @trace def par_names(self): - return [self.dll.ex_par_name(self.models, i) + return [tostr(self.dll.ex_par_name(self.models, i)) for i in range(self.num_pars)] @trace