Skip to content

Commit

Permalink
Python 3 compatability fix
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
dan-blanchard committed Sep 16, 2013
1 parent cc5f020 commit 2923e35
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion drmaa/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down

0 comments on commit 2923e35

Please sign in to comment.