From 9ec2a8b45a7ed669bbaa57b1700b2dbb1cf528cb Mon Sep 17 00:00:00 2001 From: Alex Rothberg Date: Fri, 6 Jun 2014 20:00:19 -0400 Subject: [PATCH] Correctly convert unicode to string --- pyopencl/__init__.py | 2 +- pyopencl/ipython_ext.py | 7 ++----- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/pyopencl/__init__.py b/pyopencl/__init__.py index 8007e100..8c1dd2a1 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 da5e512d..9fed378b 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 -- GitLab