Skip to content

Commit 14029fd

Browse files
committed
Clean up handling of strings vs bytes a little bit.
1 parent f394fec commit 14029fd

4 files changed

Lines changed: 9 additions & 20 deletions

File tree

drmaa/helpers.py

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,6 @@
4545
drmaa_set_attribute, drmaa_set_vector_attribute,
4646
drmaa_version, STRING)
4747

48-
# Python 3 compatability help
49-
if sys.version_info < (3, 0):
50-
bytes = str
51-
str = unicode
52-
5348

5449
_BUFLEN = ATTR_BUFFER
5550

@@ -59,10 +54,10 @@ class BoolConverter(object):
5954
"""Helper class to convert to/from bool attributes."""
6055

6156
def __init__(self, true=b'y', false=b'n'):
62-
if isinstance(true, str):
57+
if not isinstance(true, bytes):
6358
true = true.encode()
6459
self.true = true
65-
if isinstance(false, str):
60+
if not isinstance(false, bytes):
6661
false = false.encode()
6762
self.false = false
6863

@@ -137,15 +132,15 @@ def __init__(self, name, type_converter=None):
137132
a converter to translate attribute values to/from the underlying
138133
implementation. See BoolConverter for an example.
139134
"""
140-
if isinstance(name, str):
135+
if not isinstance(name, bytes):
141136
name = name.encode()
142137
self.name = name
143138
self.converter = type_converter
144139

145140
def __set__(self, instance, value):
146141
if self.converter:
147142
v = self.converter.to_drmaa(value)
148-
elif isinstance(value, str):
143+
elif not isinstance(value, bytes):
149144
v = value.encode()
150145
else:
151146
v = value
@@ -172,7 +167,7 @@ class VectorAttribute(object):
172167
"""
173168

174169
def __init__(self, name):
175-
if isinstance(name, str):
170+
if not isinstance(name, bytes):
176171
name = name.encode()
177172
self.name = name
178173

@@ -193,7 +188,7 @@ class DictAttribute(object):
193188
"""
194189

195190
def __init__(self, name):
196-
if isinstance(name, str):
191+
if not isinstance(name, bytes):
197192
name = name.encode()
198193
self.name = name
199194

drmaa/session.py

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -55,12 +55,6 @@
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-
6458
class JobTemplate(object):
6559

6660
"""A job to be submitted to the DRM."""
@@ -374,7 +368,7 @@ def control(jobId, operation):
374368
jobs submitted by other DRMAA session in other DRMAA implementations
375369
or jobs submitted via native utilities.
376370
"""
377-
if isinstance(jobId, str):
371+
if not isinstance(jobId, bytes):
378372
jobId = jobId.encode()
379373
c(drmaa_control, jobId, string_to_control_action(operation))
380374

@@ -459,7 +453,7 @@ def wait(jobId, timeout=-1):
459453
stat = c_int()
460454
jid_out = create_string_buffer(128)
461455
rusage = pointer(POINTER(drmaa_attr_values_t)())
462-
if isinstance(jobId, str):
456+
if not isinstance(jobId, bytes):
463457
jobId = jobId.encode()
464458
c(drmaa_wait, jobId, jid_out, sizeof(jid_out), byref(stat), timeout,
465459
rusage)
@@ -507,7 +501,7 @@ def jobStatus(jobId):
507501
jobs return a FAILED status.
508502
"""
509503
status = c_int()
510-
if isinstance(jobId, str):
504+
if not isinstance(jobId, bytes):
511505
jobId = jobId.encode()
512506
c(drmaa_job_ps, jobId, byref(status))
513507
return status_to_string(status.value)

examples/sleeper.sh

100755100644
File mode changed.

travis/install_sge.sh

100755100644
File mode changed.

0 commit comments

Comments
 (0)