From The Compiler, 5 Years ago, written in Diff-output.
Embed
  1. # There's garbage in my c_argv when it gets called the second time
  2. # since this commit:
  3.  
  4.  
  5. commit df0fef3e0ba2dad87ac25bee860e18ef70447a93
  6. Author: Florian Bruhin <git@the-compiler.org>
  7. Date:   Fri Jan 10 10:23:28 2014 +0100
  8.  
  9.     Fuzzy arg evaluation
  10.  
  11. diff --git a/herbstclient.pyx b/herbstclient.pyx
  12. index f45d26e..3c191dd 100644
  13. --- a/herbstclient.pyx
  14. +++ b/herbstclient.pyx
  15. @@ -35,9 +35,14 @@ cdef class Client:
  16.  
  17. # earlier:
  18. # cdef char** c_argv = <char**>malloc(len(args) * sizeof(char*))
  19.  
  20.              raise MemoryError
  21.  
  22.          try:
  23. -            args = [arg.encode('UTF-8') for arg in args]
  24.              for (i, arg) in enumerate(args):
  25. -               c_argv[i] = arg
  26. +                if arg is True:
  27. +                    c_argv[i] = '1'
  28. +                elif arg in [False, None]:
  29. +                    c_argv[i] = '0'
  30. +                else:
  31. +                    outarg = str(arg).encode('UTF-8')
  32. +                    c_argv[i] = outarg
  33.              if not chc.hc_send_command(self._c_con, len(args), c_argv,
  34.                                         &c_output, &c_status):
  35.                  raise HerbstClientError("Could not send command")
  36.