From 2923e3532f0542574d6ca2fbaa643b10c446926a Mon Sep 17 00:00:00 2001 From: Dan Blanchard Date: Mon, 16 Sep 2013 14:32:36 -0400 Subject: [PATCH] Python 3 compatability fix In Python 3 string literals are str, and not bytes, so `DictAttribute.__set___` would pass the wrong type of argument to the C functino `drmaa_set_vector_attribute`. This simple change encodes strings to bytes with the system default encoding. Since you can called `.encode()` on byte strings in Python 2.x without side-effect, this simple change should work with both. --- drmaa/helpers.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drmaa/helpers.py b/drmaa/helpers.py index 2f68496..8a3f2a8 100644 --- a/drmaa/helpers.py +++ b/drmaa/helpers.py @@ -133,7 +133,7 @@ class DictAttribute(object): def __init__(self, name): self.name = name def __set__(self, instance, value): - v = [ "%s=%s" % (k, v) for (k, v) in value.items() ] + v = [ "%s=%s".encode() % (k, v) for (k, v) in value.items() ] c(drmaa_set_vector_attribute, instance, self.name, string_vector(v)) def __get__(self, instance, _): x = [ i.split('=', 1) for i in list(vector_attribute_iterator(