diff --git a/pyopencl/__init__.py b/pyopencl/__init__.py index 8007e100813f0f7bed340ea536a6f37a5ef4a28d..8c1dd2a112c810ccd662f4f60169d81e08484cac 100644 --- a/pyopencl/__init__.py +++ b/pyopencl/__init__.py @@ -175,7 +175,7 @@ class Program(object): def build(self, options=[], devices=None, cache_dir=None): if isinstance(options, basestring): - options = [str(options)] + options = [options.encode("utf8")] options = (options + _DEFAULT_BUILD_OPTIONS diff --git a/pyopencl/ipython_ext.py b/pyopencl/ipython_ext.py index da5e512d278318039560f6d99a1788e292412188..9fed378b113a7ef37e7b2fc3d5c964523617a990 100644 --- a/pyopencl/ipython_ext.py +++ b/pyopencl/ipython_ext.py @@ -23,14 +23,11 @@ class PyOpenCLMagics(Magics): except KeyError: ctx = None - if not isinstance(ctx, cl.Context): - ctx = None - - if ctx is None: + if ctx is None or not isinstance(ctx, cl.Context): raise RuntimeError("unable to locate cl context, which must be " "present in namespace as 'cl_ctx' or 'ctx'") - prg = cl.Program(ctx, cell.encode("utf8")).build(options=line) + prg = cl.Program(ctx, cell.encode("utf8")).build(options=line.encode("utf8")) for knl in prg.all_kernels(): self.shell.user_ns[knl.function_name] = knl