[Cython] A couple bug reports + possibly suboptimal solutions for them
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 WinMain <at> 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
<div><p>Hello,
<br><br>I'd like to report a bug with Cython 0.12.1 which is also present in the
latest SVN version:
<br>embedding an interpreter with the --embed option (to create the .exe
file) fails on MS Windows
<br>with the error "undefined reference to WinMain <at> 16". I was able to
overcome that error by
<br>changing this line in the output .c file:
<br><br>int wmain(int argc, wchar_t **argv) {
<br><br>into this:
<br><br>int main(int argc, wchar_t **argv) {
<br><br><br>The second problem (also on MS Windows) is that sys.argv do not get
parsed correctly due to
<br>the fact that it seems like the command line is parsed as "char**", but
Python expects "wchar_t**".
<br>Here's what I did to overcome the issue:
<br><br>I changed this:
<br><br> PySys_SetArgv(argc, argv); __pyx_module_is_main_test1 = 1;
<br><br>Into this:
<br><br> //PySys_SetArgv(argc, argv); __pyx_module_is_main_test1 = 1;
<br> PyObject *py_argv= PyList_New(0);
<br> int i;
<br> for (i=0; i<argc; i++) {
<br> PyObject *item= PyUnicode_Decode(argv[i], strlen(argv[i]),
Py_FileSystemDefaultEncoding, NULL);
<br> if(item==NULL) { // should never happen
<br> PyErr_Print();
<br> PyErr_Clear();
<br> }
<br> else {
<br> PyList_Append(py_argv, item);
<br> Py_DECREF(item);
<br> }
<br> }
<br> PySys_SetObject("argv", py_argv);
<br> Py_DECREF(py_argv);
<br><br><br>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
<br>or whatever, so it's just a proposed bug report with a demo as to how I
solved the issue). Hope it helps. <span class="moz-smiley-s1"><span> :) </span></span>
<br><br>I love your project, thank you so much for Cython! :D
<br><br>Best regards,
<br>Michael
<br><br></p></div>
RSS Feed