Skip to content

Commit 3b4fdd9

Browse files
committed
Merge branch 'release/0.7.2'
2 parents 6f9702a + d8606af commit 3b4fdd9

File tree

4 files changed

+22
-16
lines changed

4 files changed

+22
-16
lines changed

README.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,11 @@ License
3939
Changelog
4040
~~~~~~~~~
4141

42+
- v0.7.2
43+
44+
- Fix a couple inconsistencies with ``str`` vs ``bytes`` in Python 3 in
45+
``drmaa.session``.
46+
4247
- v0.7.1
4348

4449
- Add `Read The Docs documentation <http://drmaa-python.readthedocs.org>`__

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: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -368,7 +368,9 @@ def control(jobId, operation):
368368
jobs submitted by other DRMAA session in other DRMAA implementations
369369
or jobs submitted via native utilities.
370370
"""
371-
c(drmaa_control, jobId.encode(), string_to_control_action(operation))
371+
if not isinstance(jobId, bytes):
372+
jobId = jobId.encode()
373+
c(drmaa_control, jobId, string_to_control_action(operation))
372374

373375
# takes string list, num value and boolean, no return value
374376
@staticmethod
@@ -451,8 +453,10 @@ def wait(jobId, timeout=-1):
451453
stat = c_int()
452454
jid_out = create_string_buffer(128)
453455
rusage = pointer(POINTER(drmaa_attr_values_t)())
454-
c(drmaa_wait, jobId.encode(), jid_out, sizeof(jid_out), byref(stat),
455-
timeout, rusage)
456+
if not isinstance(jobId, bytes):
457+
jobId = jobId.encode()
458+
c(drmaa_wait, jobId, jid_out, sizeof(jid_out), byref(stat), timeout,
459+
rusage)
456460
res_usage = adapt_rusage(rusage)
457461
exited = c_int()
458462
c(drmaa_wifexited, byref(exited), stat)
@@ -497,7 +501,9 @@ def jobStatus(jobId):
497501
jobs return a FAILED status.
498502
"""
499503
status = c_int()
500-
c(drmaa_job_ps, jobId.encode(), byref(status))
504+
if not isinstance(jobId, bytes):
505+
jobId = jobId.encode()
506+
c(drmaa_job_ps, jobId, byref(status))
501507
return status_to_string(status.value)
502508

503509
def __enter__(self):

drmaa/version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,5 +22,5 @@
2222
:author: Dan Blanchard ([email protected])
2323
'''
2424

25-
__version__ = '0.7.1'
25+
__version__ = '0.7.2'
2626
VERSION = tuple(int(x) for x in __version__.split('.'))

0 commit comments

Comments
 (0)