diff --git a/python/lammps.py b/python/lammps.py index 7344a16be30fb8ab47e3ffc1f6cd939dae95b4fe..80d1a87159e287d507a97141d740bc228b0415a9 100644 --- a/python/lammps.py +++ b/python/lammps.py @@ -190,12 +190,15 @@ class lammps(object): # send a list of commands def commands_list(self,cmdlist): - args = (c_char_p * len(cmdlist))(*cmdlist) + cmds = [x.encode() for x in cmdlist if type(x) is str] + args = (c_char_p * len(cmdlist))(*cmds) self.lib.lammps_commands_list(self.lmp,len(cmdlist),args) # send a string of commands def commands_string(self,multicmd): + if type(multicmd) is str: + multicmd = multicmd.encode() self.lib.lammps_commands_string(self.lmp,c_char_p(multicmd)) # extract global info