Hello,

I've noticed that a change made several months ago to the string error
handling isn't compatible with versions of python earlier than 2.7.

The following fails on python versions < 2.7.

s = "test string"
s.decode("UTF8", error='replace')

as keywords were not supported at the time. I've attached a simple patch
that makes these positional arguments.

as in

s.decode("UTF8", "replace")

Thanks,

Alex Nitz
From 18c698b2f5b1a8aac4c4679e123a52abf17c714e Mon Sep 17 00:00:00 2001
From: Alexander Harvey Nitz <[email protected]>
Date: Mon, 16 Dec 2013 04:05:02 -0500
Subject: [PATCH] use positional argument for string handling scheme, (keyword
 not supported in python<=2.6)

---
 pycuda/compiler.py |   14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/pycuda/compiler.py b/pycuda/compiler.py
index 9d8cf01..ace4860 100644
--- a/pycuda/compiler.py
+++ b/pycuda/compiler.py
@@ -17,7 +17,7 @@ def get_nvcc_version(nvcc):
         warn("NVCC version could not be determined.")
         stdout = "nvcc unknown version"
 
-    return stdout.decode("utf-8", errors="replace")
+    return stdout.decode("utf-8", "replace")
 
 
 def _new_md5():
@@ -56,11 +56,11 @@ def preprocess_source(source, options, nvcc):
         from pycuda.driver import CompileError
         raise CompileError("nvcc preprocessing of %s failed with ridiculously "
                 "small code output - likely unsupported compiler." % source_path,
-                cmdline, stderr=stderr.decode("utf-8", errors="replace"))
+                cmdline, stderr=stderr.decode("utf-8", "replace"))
 
     unlink(source_path)
 
-    return stdout.decode("utf-8", errors="replace")
+    return stdout.decode("utf-8", "replace")
 
 
 def compile_plain(source, options, keep, nvcc, cache_dir):
@@ -128,18 +128,18 @@ def compile_plain(source, options, keep, nvcc, cache_dir):
                     "encountered an error")
         from pycuda.driver import CompileError
         raise CompileError("nvcc compilation of %s failed" % cu_file_path,
-                cmdline, stdout=stdout.decode("utf-8", errors="replace"),
-                stderr=stderr.decode("utf-8", errors="replace"))
+                cmdline, stdout=stdout.decode("utf-8", "replace"),
+                stderr=stderr.decode("utf-8", "replace"))
 
     if stdout or stderr:
-        lcase_err_text = (stdout+stderr).decode("utf-8", errors="replace").lower()
+        lcase_err_text = (stdout+stderr).decode("utf-8", "replace").lower()
         from warnings import warn
         if "demoted" in lcase_err_text or "demoting" in lcase_err_text:
             warn("nvcc said it demoted types in source code it "
                 "compiled--this is likely not what you want.",
                 stacklevel=4)
         warn("The CUDA compiler succeeded, but said the following:\n"
-                + (stdout+stderr).decode("utf-8", errors="replace"), stacklevel=4)
+                + (stdout+stderr).decode("utf-8", "replace"), stacklevel=4)
 
     cubin = cubin_f.read()
     cubin_f.close()
-- 
1.7.10.rc4.209.g0677f

_______________________________________________
PyCUDA mailing list
[email protected]
http://lists.tiker.net/listinfo/pycuda

Reply via email to