diff --git a/PC/dl_nt.c b/PC/dl_nt.c --- a/PC/dl_nt.c +++ b/PC/dl_nt.c @@ -18,7 +18,8 @@ HMODULE PyWin_DLLhModule = NULL; const char *PyWin_DLLVersionString = dllVersionBuffer; -// Windows "Activation Context" work: +#if HAVE_SXS +// Windows "Activation Context" work. // Our .pyd extension modules are generally built without a manifest (ie, // those included with Python and those built with a default distutils. // This requires we perform some "activation context" magic when loading our @@ -29,6 +30,8 @@ // As an added complication, this magic only works on XP or later - we simply // use the existence (or not) of the relevant function pointers from kernel32. // See bug 4566 (http://python.org/sf/4566) for more details. +// In Visual Studio 2010, side by side assemblies are no longer used by +// default. typedef BOOL (WINAPI * PFN_GETCURRENTACTCTX)(HANDLE *); typedef BOOL (WINAPI * PFN_ACTIVATEACTCTX)(HANDLE, ULONG_PTR *); @@ -75,6 +78,7 @@ if (!(*pfnDeactivateActCtx)(0, cookie)) OutputDebugString("Python failed to de-activate the activation context\n"); } +#endif /* HAVE_SXS */ BOOL WINAPI DllMain (HANDLE hInst, ULONG ul_reason_for_call, @@ -87,17 +91,21 @@ // 1000 is a magic number I picked out of the air. Could do with a #define, I spose... LoadString(hInst, 1000, dllVersionBuffer, sizeof(dllVersionBuffer)); +#if HAVE_SXS // and capture our activation context for use when loading extensions. _LoadActCtxPointers(); if (pfnGetCurrentActCtx && pfnAddRefActCtx) if ((*pfnGetCurrentActCtx)(&PyWin_DLLhActivationContext)) if (!(*pfnAddRefActCtx)(PyWin_DLLhActivationContext)) OutputDebugString("Python failed to load the default activation context\n"); +#endif break; case DLL_PROCESS_DETACH: +#if HAVE_SXS if (pfnReleaseActCtx) (*pfnReleaseActCtx)(PyWin_DLLhActivationContext); +#endif break; } return TRUE; diff --git a/PC/msvcrtmodule.c b/PC/msvcrtmodule.c --- a/PC/msvcrtmodule.c +++ b/PC/msvcrtmodule.c @@ -494,6 +494,7 @@ #endif /* constants for the crt versions */ + (void)st; #ifdef _VC_ASSEMBLY_PUBLICKEYTOKEN st = PyModule_AddStringConstant(m, "VC_ASSEMBLY_PUBLICKEYTOKEN", _VC_ASSEMBLY_PUBLICKEYTOKEN); diff --git a/PC/pyconfig.h b/PC/pyconfig.h --- a/PC/pyconfig.h +++ b/PC/pyconfig.h @@ -215,14 +215,19 @@ #define copysign _copysign #define hypot _hypot -#endif /* _MSC_VER */ +/* Side by Side assemblies supported in VS 2005 and VS 2008 but not 2010*/ +#if _MSC_VER >= 1400 && _MSC_VER < 1600 +#define HAVE_SXS 1 +#endif /* define some ANSI types that are not defined in earlier Win headers */ -#if defined(_MSC_VER) && _MSC_VER >= 1200 +#if _MSC_VER >= 1200 /* This file only exists in VC 6.0 or higher */ #include #endif +#endif /* _MSC_VER */ + /* ------------------------------------------------------------------------*/ /* The Borland compiler defines __BORLANDC__ */ /* XXX These defines are likely incomplete, but should be easy to fix. */ diff --git a/Python/dynload_win.c b/Python/dynload_win.c --- a/Python/dynload_win.c +++ b/Python/dynload_win.c @@ -12,8 +12,10 @@ #include // "activation context" magic - see dl_nt.c... +#if HAVE_SXS extern ULONG_PTR _Py_ActivateActCtx(); void _Py_DeactivateActCtx(ULONG_PTR cookie); +#endif const struct filedescr _PyImport_DynLoadFiletab[] = { #ifdef _DEBUG @@ -191,18 +193,24 @@ { HINSTANCE hDLL = NULL; unsigned int old_mode; +#if HAVE_SXS ULONG_PTR cookie = 0; +#endif /* Don't display a message box when Python can't load a DLL */ old_mode = SetErrorMode(SEM_FAILCRITICALERRORS); +#if HAVE_SXS cookie = _Py_ActivateActCtx(); +#endif /* We use LoadLibraryEx so Windows looks for dependent DLLs in directory of pathname first. */ /* XXX This call doesn't exist in Windows CE */ hDLL = LoadLibraryExW(wpathname, NULL, LOAD_WITH_ALTERED_SEARCH_PATH); +#if HAVE_SXS _Py_DeactivateActCtx(cookie); +#endif /* restore old error mode settings */ SetErrorMode(old_mode);