Skip to content

Commit 92f0cc8

Browse files
Fix issue where string_vector dies when given an int (#57)
1 parent 86d68aa commit 92f0cc8

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

drmaa/helpers.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,7 @@ def adapt_rusage(rusage):
238238
"""
239239
rv = dict()
240240
for attr in attributes_iterator(rusage.contents):
241-
241+
242242
k, v = attr.split('=',1)
243243
rv[k] = v
244244
return rv
@@ -307,7 +307,11 @@ def string_vector(v):
307307
vlen = len(v)
308308
values = (STRING * (vlen + 1))()
309309
for i, el in enumerate(v):
310-
values[i] = STRING(el.encode(ENCODING) if isinstance(el, str) else el)
310+
if isinstance(el, str):
311+
el = el.encode(ENCODING)
312+
elif not isinstance(el, bytes):
313+
el = str(el).encode(ENCODING)
314+
values[i] = STRING(el)
311315
values[vlen] = STRING()
312316
return values
313317

test/testwrap.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -152,9 +152,9 @@ def xtest_tmp(self):
152152

153153
def test_vector_attributes(self):
154154
"""vector attributes work"""
155-
args = ['10', 'de', 'arglebargle']
155+
args = [10, 'de', 'arglebargle']
156156
self.jt.args = args
157-
eq_(self.jt.args, args)
157+
eq_(self.jt.args, ['10', 'de', 'arglebargle'])
158158
159159
self.jt.email = em
160160
eq_(self.jt.email, em)

0 commit comments

Comments
 (0)