From 2b654eb3cac05826a8af6e781fd0281b7a49aeab Mon Sep 17 00:00:00 2001
From: Andreas Kloeckner <inform@tiker.net>
Date: Thu, 28 Apr 2011 12:15:24 -0400
Subject: [PATCH] Warn about, but don't error out on unicode source.

---
 pyopencl/__init__.py | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/pyopencl/__init__.py b/pyopencl/__init__.py
index 8e508bcb..5064b18e 100644
--- a/pyopencl/__init__.py
+++ b/pyopencl/__init__.py
@@ -371,10 +371,21 @@ _add_functionality()
 class Program(object):
     def __init__(self, context, arg1, arg2=None):
         if arg2 is None:
+            source = arg1
+
+            import sys
+            if isinstance(source, unicode) and sys.version_info < (3,):
+                from warnings import warn
+                warn("Received OpenCL source code in Unicode, "
+                        "should be ASCII string. Attempting conversion.", 
+                        stacklevel=2)
+                source = str(source)
+
             self._context = context
-            self._source = arg1
+            self._source = source
             self._prg = None
         else:
+            # 3-argument form: context, devices, binaries
             self._prg = _cl.Program(context, arg1, arg2)
 
     def _get_prg(self):
-- 
GitLab