Skip to content

Commit f394fec

Browse files
committed
Fix a few remaining cases in session.py where .encode() was being called for bytes.
1 parent 6f9702a commit f394fec

1 file changed

Lines changed: 16 additions & 4 deletions

File tree

drmaa/session.py

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,12 @@
5555
wasAborted exitStatus resourceUsage""")
5656

5757

58+
# Python 3 compatability help
59+
if sys.version_info < (3, 0):
60+
bytes = str
61+
str = unicode
62+
63+
5864
class JobTemplate(object):
5965

6066
"""A job to be submitted to the DRM."""
@@ -368,7 +374,9 @@ def control(jobId, operation):
368374
jobs submitted by other DRMAA session in other DRMAA implementations
369375
or jobs submitted via native utilities.
370376
"""
371-
c(drmaa_control, jobId.encode(), string_to_control_action(operation))
377+
if isinstance(jobId, str):
378+
jobId = jobId.encode()
379+
c(drmaa_control, jobId, string_to_control_action(operation))
372380

373381
# takes string list, num value and boolean, no return value
374382
@staticmethod
@@ -451,8 +459,10 @@ def wait(jobId, timeout=-1):
451459
stat = c_int()
452460
jid_out = create_string_buffer(128)
453461
rusage = pointer(POINTER(drmaa_attr_values_t)())
454-
c(drmaa_wait, jobId.encode(), jid_out, sizeof(jid_out), byref(stat),
455-
timeout, rusage)
462+
if isinstance(jobId, str):
463+
jobId = jobId.encode()
464+
c(drmaa_wait, jobId, jid_out, sizeof(jid_out), byref(stat), timeout,
465+
rusage)
456466
res_usage = adapt_rusage(rusage)
457467
exited = c_int()
458468
c(drmaa_wifexited, byref(exited), stat)
@@ -497,7 +507,9 @@ def jobStatus(jobId):
497507
jobs return a FAILED status.
498508
"""
499509
status = c_int()
500-
c(drmaa_job_ps, jobId.encode(), byref(status))
510+
if isinstance(jobId, str):
511+
jobId = jobId.encode()
512+
c(drmaa_job_ps, jobId, byref(status))
501513
return status_to_string(status.value)
502514

503515
def __enter__(self):

0 commit comments

Comments
 (0)