Hello,

I'd like to report a bug with Cython 0.12.1 which is also present in the
latest SVN version:
embedding an interpreter with the --embed option (to create the .exe file)
fails on MS Windows
with the error "undefined reference to winm...@16". I was able to overcome
that error by
changing this line in the output .c file:

int wmain(int argc, wchar_t **argv) {

into this:

int main(int argc, wchar_t **argv) {


The second problem (also on MS Windows) is that sys.argv do not get parsed
correctly due to
the fact that it seems like the command line is parsed as "char**", but
Python expects "wchar_t**".
Here's what I did to overcome the issue:

I changed this:

  PySys_SetArgv(argc, argv);    __pyx_module_is_main_test1 = 1;

Into this:

  //PySys_SetArgv(argc, argv);    __pyx_module_is_main_test1 = 1;
  PyObject *py_argv= PyList_New(0);
  int i;
      for (i=0; i<argc; i++) {
          PyObject *item= PyUnicode_Decode(argv[i], strlen(argv[i]),
Py_FileSystemDefaultEncoding, NULL);
      if(item==NULL) { // should never happen
          PyErr_Print();
          PyErr_Clear();
      }
      else {
          PyList_Append(py_argv, item);
          Py_DECREF(item);
      }
      }
      PySys_SetObject("argv", py_argv);
      Py_DECREF(py_argv);


I'm not sure if it's optimal, I do get warnings during compilation, but at
least it works (it might not be cross-platform
or whatever, so it's just a proposed bug report with a demo as to how I
solved the issue). Hope it helps. :)

I love your project, thank you so much for Cython! :D

Best regards,
Michael
_______________________________________________
Cython-dev mailing list
[email protected]
http://codespeak.net/mailman/listinfo/cython-dev

Reply via email to