Skip to content

Commit 5db1043

Browse files
committed
refactor: Python3 support, time values changed to double from long
1 parent 983dfc7 commit 5db1043

File tree

1 file changed

+8
-12
lines changed

1 file changed

+8
-12
lines changed

pyslurm/pyslurm.pyx

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# cython: embedsignature=True
22
# cython: profile=False
3-
# cython: language_level=2
3+
# cython: language_level=3
44
import os
55
import re
66
import sys
@@ -55,13 +55,9 @@ cdef extern from "alps_cray.h" nogil:
5555
cdef extern from "xmalloc.h" nogil:
5656
cdef void *xmalloc(size_t size)
5757

58-
try:
59-
import __builtin__
60-
except ImportError:
61-
# Python 3
62-
import builtins as __builtin__
58+
import builtins as __builtin__
6359

64-
cimport slurm
60+
from pyslurm cimport slurm
6561

6662
include "pydefines/slurm_errno_defines.pxi"
6763
include "pydefines/slurm_errno_enums.pxi"
@@ -910,7 +906,7 @@ cdef class partition:
910906

911907
if record.allow_accounts or not record.deny_accounts:
912908
if record.allow_accounts == NULL or \
913-
record.allow_accounts[0] == "\0":
909+
record.allow_accounts[0] == "\0".encode("UTF-8"):
914910
Part_dict[u'allow_accounts'] = u"ALL"
915911
else:
916912
Part_dict[u'allow_accounts'] = slurm.listOrNone(
@@ -929,15 +925,15 @@ cdef class partition:
929925
record.allow_alloc_nodes, ',')
930926

931927
if record.allow_groups == NULL or \
932-
record.allow_groups[0] == "\0":
928+
record.allow_groups[0] == "\0".encode("UTF-8"):
933929
Part_dict[u'allow_groups'] = u"ALL"
934930
else:
935931
Part_dict[u'allow_groups'] = slurm.listOrNone(
936932
record.allow_groups, ',')
937933

938934
if record.allow_qos or not record.deny_qos:
939935
if record.allow_qos == NULL or \
940-
record.allow_qos[0] == "\0":
936+
record.allow_qos[0] == "\0".encode("UTF-8"):
941937
Part_dict[u'allow_qos'] = u"ALL"
942938
else:
943939
Part_dict[u'allow_qos'] = slurm.listOrNone(
@@ -2829,7 +2825,7 @@ cdef secs2time_str(uint32_t time):
28292825
"""
28302826
cdef:
28312827
char *time_str
2832-
long days, hours, minutes, seconds
2828+
double days, hours, minutes, seconds
28332829

28342830
if time == slurm.INFINITE:
28352831
time_str = "UNLIMITED"
@@ -2859,7 +2855,7 @@ cdef mins2time_str(uint32_t time):
28592855
:rtype: `str`
28602856
"""
28612857
cdef:
2862-
long days, hours, minutes, seconds
2858+
double days, hours, minutes, seconds
28632859

28642860
if time == slurm.INFINITE:
28652861
return u"UNLIMITED"

0 commit comments

Comments
 (0)