@@ -171,8 +171,8 @@ static char *GetPythonImport (HINSTANCE hModule)
171171 return NULL ;
172172}
173173
174- dl_funcptr _PyImport_GetDynLoadFunc (const char * shortname ,
175- const char * pathname , FILE * fp )
174+ dl_funcptr _PyImport_GetDynLoadWindows (const char * shortname ,
175+ PyObject * pathname , FILE * fp )
176176{
177177 dl_funcptr p ;
178178 char funcname [258 ], * import_python ;
@@ -185,8 +185,7 @@ dl_funcptr _PyImport_GetDynLoadFunc(const char *shortname,
185185
186186 {
187187 HINSTANCE hDLL = NULL ;
188- char pathbuf [260 ];
189- LPTSTR dummy ;
188+ wchar_t pathbuf [260 ];
190189 unsigned int old_mode ;
191190 ULONG_PTR cookie = 0 ;
192191 /* We use LoadLibraryEx so Windows looks for dependent DLLs
@@ -198,14 +197,14 @@ dl_funcptr _PyImport_GetDynLoadFunc(const char *shortname,
198197 /* Don't display a message box when Python can't load a DLL */
199198 old_mode = SetErrorMode (SEM_FAILCRITICALERRORS );
200199
201- if (GetFullPathName ( pathname ,
202- sizeof (pathbuf ),
203- pathbuf ,
204- & dummy )) {
200+ if (GetFullPathNameW ( PyUnicode_AS_UNICODE ( pathname ) ,
201+ sizeof (pathbuf ) / sizeof ( pathbuf [ 0 ] ),
202+ pathbuf ,
203+ NULL )) {
205204 ULONG_PTR cookie = _Py_ActivateActCtx ();
206205 /* XXX This call doesn't exist in Windows CE */
207- hDLL = LoadLibraryEx ( pathname , NULL ,
208- LOAD_WITH_ALTERED_SEARCH_PATH );
206+ hDLL = LoadLibraryExW ( PyUnicode_AS_UNICODE ( pathname ) , NULL ,
207+ LOAD_WITH_ALTERED_SEARCH_PATH );
209208 _Py_DeactivateActCtx (cookie );
210209 }
211210
@@ -264,21 +263,21 @@ dl_funcptr _PyImport_GetDynLoadFunc(const char *shortname,
264263 } else {
265264 char buffer [256 ];
266265
266+ PyOS_snprintf (buffer , sizeof (buffer ),
267267#ifdef _DEBUG
268- PyOS_snprintf ( buffer , sizeof ( buffer ), "python%d%d_d.dll" ,
268+ "python%d%d_d.dll" ,
269269#else
270- PyOS_snprintf ( buffer , sizeof ( buffer ), "python%d%d.dll" ,
270+ "python%d%d.dll" ,
271271#endif
272272 PY_MAJOR_VERSION ,PY_MINOR_VERSION );
273273 import_python = GetPythonImport (hDLL );
274274
275275 if (import_python &&
276276 strcasecmp (buffer ,import_python )) {
277- PyOS_snprintf (buffer , sizeof (buffer ),
278- "Module use of %.150s conflicts "
279- "with this version of Python." ,
280- import_python );
281- PyErr_SetString (PyExc_ImportError ,buffer );
277+ PyErr_Format (PyExc_ImportError ,
278+ "Module use of %.150s conflicts "
279+ "with this version of Python." ,
280+ import_python );
282281 FreeLibrary (hDLL );
283282 return NULL ;
284283 }
0 commit comments