Commit 0262a54e authored by Richard Berger's avatar Richard Berger
Browse files

Fix Python 3 compatibility by encoding strings passed as c_char_p

parent 3a2da51a
Loading
Loading
Loading
Loading
+4 −1
Original line number Diff line number Diff line
@@ -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