File tree 1 file changed +18
-0
lines changed
1 file changed +18
-0
lines changed Original file line number Diff line number Diff line change 15
15
#include "dirent.h"
16
16
#endif
17
17
18
+ #if PY_MAJOR_VERSION > 2
19
+ #include <stdlib.h>
20
+ #endif
21
+
18
22
// initialize Mono and PythonNet
19
23
PyNet_Args * PyNet_Init (int ext ) {
20
24
PyNet_Args * pn_args ;
@@ -102,11 +106,25 @@ void main_thread_handler (gpointer user_data) {
102
106
103
107
int ii = 0 ;
104
108
for (ii = 0 ; ii < PyList_Size (syspath ); ++ ii ) {
109
+ #if PY_MAJOR_VERSION > 2
110
+ Py_ssize_t wlen ;
111
+ wchar_t * wstr = PyUnicode_AsWideCharString (PyList_GetItem (syspath , ii ), & wlen );
112
+ char * pydir = (char * )malloc (wlen + 1 );
113
+ size_t mblen = wcstombs (pydir , wstr , wlen + 1 );
114
+ if (mblen > wlen )
115
+ pydir [wlen ] = '\0' ;
116
+ PyMem_Free (wstr );
117
+ #else
105
118
const char * pydir = PyString_AsString (PyList_GetItem (syspath , ii ));
119
+ #endif
106
120
char * curdir = (char * ) malloc (1024 );
107
121
strncpy (curdir , strlen (pydir ) > 0 ? pydir : "." , 1024 );
108
122
strncat (curdir , slash , 1024 );
109
123
124
+ #if PY_MAJOR_VERSION > 2
125
+ free (pydir );
126
+ #endif
127
+
110
128
//look in this directory for the pn_args->pr_file
111
129
DIR * dirp = opendir (curdir );
112
130
if (dirp != NULL ) {
You can’t perform that action at this time.
0 commit comments