Skip to content
Snippets Groups Projects
Commit 054ecbf4 authored by Giovanni Bussi's avatar Giovanni Bussi
Browse files

fixed basestring in python3

parent e663a33b
No related branches found
No related tags found
No related merge requests found
...@@ -30,6 +30,7 @@ cimport cplumed # This imports information from pxd file - including contents o ...@@ -30,6 +30,7 @@ cimport cplumed # This imports information from pxd file - including contents o
from cpython cimport array from cpython cimport array
import array import array
import sys
try: try:
import numpy as np import numpy as np
...@@ -37,6 +38,12 @@ try: ...@@ -37,6 +38,12 @@ try:
except ImportError: except ImportError:
HAS_NUMPY=False HAS_NUMPY=False
if sys.version_info < (3,):
type_str=basestring
else:
type_str=str
cdef class Plumed: cdef class Plumed:
cdef cplumed.Plumed c_plumed cdef cplumed.Plumed c_plumed
def __cinit__(self,kernel=None): def __cinit__(self,kernel=None):
...@@ -117,7 +124,7 @@ cdef class Plumed: ...@@ -117,7 +124,7 @@ cdef class Plumed:
self.c_plumed.cmd( ckey, <void*> ar.data.as_voidptr) self.c_plumed.cmd( ckey, <void*> ar.data.as_voidptr)
else : else :
raise ValueError("ndarrays should be double (size=8) or int") raise ValueError("ndarrays should be double (size=8) or int")
elif isinstance(val, basestring ) : elif isinstance(val, type_str ) :
py_bytes = val.encode() py_bytes = val.encode()
cval = py_bytes cval = py_bytes
self.c_plumed.cmd( ckey, <void*>cval ) self.c_plumed.cmd( ckey, <void*>cval )
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment