Skip to content

Commit

Permalink
Fix issue where string_vector dies when given an int (#57)
Browse files Browse the repository at this point in the history
  • Loading branch information
dan-blanchard authored Jul 3, 2017
1 parent 86d68aa commit 92f0cc8
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
8 changes: 6 additions & 2 deletions drmaa/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ def adapt_rusage(rusage):
"""
rv = dict()
for attr in attributes_iterator(rusage.contents):

k, v = attr.split('=',1)
rv[k] = v
return rv
Expand Down Expand Up @@ -307,7 +307,11 @@ def string_vector(v):
vlen = len(v)
values = (STRING * (vlen + 1))()
for i, el in enumerate(v):
values[i] = STRING(el.encode(ENCODING) if isinstance(el, str) else el)
if isinstance(el, str):
el = el.encode(ENCODING)
elif not isinstance(el, bytes):
el = str(el).encode(ENCODING)
values[i] = STRING(el)
values[vlen] = STRING()
return values

Expand Down
4 changes: 2 additions & 2 deletions test/testwrap.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,9 +152,9 @@ def xtest_tmp(self):

def test_vector_attributes(self):
"""vector attributes work"""
args = ['10', 'de', 'arglebargle']
args = [10, 'de', 'arglebargle']
self.jt.args = args
eq_(self.jt.args, args)
eq_(self.jt.args, ['10', 'de', 'arglebargle'])
em = ['[email protected]', '[email protected]']
self.jt.email = em
eq_(self.jt.email, em)
Expand Down

0 comments on commit 92f0cc8

Please sign in to comment.