diff --git a/Doc/library/codecs.rst b/Doc/library/codecs.rst index 4fd0951e304a74..e1ec268066892b 100644 --- a/Doc/library/codecs.rst +++ b/Doc/library/codecs.rst @@ -1006,6 +1006,8 @@ particular, the following variants typically exist: +-----------------+--------------------------------+--------------------------------+ | cp1258 | windows-1258 | Vietnamese | +-----------------+--------------------------------+--------------------------------+ +| cp65001 | | Alias to ``utf_8`` encoding | ++-----------------+--------------------------------+--------------------------------+ | euc_jp | eucjp, ujis, u-jis | Japanese | +-----------------+--------------------------------+--------------------------------+ | euc_jis_2004 | jisx0213, eucjis2004 | Japanese | diff --git a/Include/patchlevel.h b/Include/patchlevel.h index d250bb8e4dcdb5..9a0c45e13d9bd0 100644 --- a/Include/patchlevel.h +++ b/Include/patchlevel.h @@ -27,7 +27,7 @@ #define PY_RELEASE_SERIAL 0 /* Version as a string */ -#define PY_VERSION "2.7.18.9" +#define PY_VERSION "2.7.18.10" /*--end constants--*/ /* Subversion Revision number of this file (not of the repository). Empty diff --git a/Lib/ctypes/util.py b/Lib/ctypes/util.py index ab10ec52ee8c35..6c43d821a6439e 100644 --- a/Lib/ctypes/util.py +++ b/Lib/ctypes/util.py @@ -19,6 +19,8 @@ def _get_build_version(): i = i + len(prefix) s, rest = sys.version[i:].split(" ", 1) majorVersion = int(s[:-2]) - 6 + if majorVersion >= 13: + majorVersion += 1 minorVersion = int(s[2:3]) / 10.0 # I don't think paths are affected by minor version in version 6 if majorVersion == 6: @@ -36,8 +38,10 @@ def find_msvcrt(): return None if version <= 6: clibname = 'msvcrt' - else: + elif version <= 13: clibname = 'msvcr%d' % (version * 10) + else: + clibname = 'appcrt%d' % (version * 10) # If python was built with in debug mode import imp diff --git a/Lib/distutils/command/build_ext.py b/Lib/distutils/command/build_ext.py index 86a85c1a0a01da..b2ee260d7e5df3 100644 --- a/Lib/distutils/command/build_ext.py +++ b/Lib/distutils/command/build_ext.py @@ -193,10 +193,10 @@ def finalize_options(self): # Append the source distribution include and library directories, # this allows distutils on windows to work in the source tree self.include_dirs.append(os.path.join(sys.exec_prefix, 'PC')) - if MSVC_VERSION == 9: + if MSVC_VERSION >= 9: # Use the .lib files for the correct architecture if self.plat_name == 'win32': - suffix = '' + suffix = 'win32' else: # win-amd64 or win-ia64 suffix = self.plat_name[4:] diff --git a/Lib/distutils/msvc9compiler.py b/Lib/distutils/msvc9compiler.py index 785e555566c656..f4194f596d0f5d 100644 --- a/Lib/distutils/msvc9compiler.py +++ b/Lib/distutils/msvc9compiler.py @@ -242,6 +242,9 @@ def get_build_version(): i = i + len(prefix) s, rest = sys.version[i:].split(" ", 1) majorVersion = int(s[:-2]) - 6 + if majorVersion >= 13: + # v13 was skipped and should be v14 + majorVersion += 1 minorVersion = int(s[2:3]) / 10.0 # I don't think paths are affected by minor version in version 6 if majorVersion == 6: @@ -716,11 +719,12 @@ def link(self, if mfinfo is not None: mffilename, mfid = mfinfo out_arg = '-outputresource:%s;%s' % (output_filename, mfid) - try: - self.spawn(['mt.exe', '-nologo', '-manifest', + if self.__version < 10: + try: + self.spawn(['mt.exe', '-nologo', '-manifest', mffilename, out_arg]) - except DistutilsExecError, msg: - raise LinkError(msg) + except DistutilsExecError, msg: + raise LinkError(msg) else: log.debug("skipping %s (up-to-date)", output_filename) diff --git a/Lib/distutils/msvccompiler.py b/Lib/distutils/msvccompiler.py index 0e69fd368cac78..77025c66e22781 100644 --- a/Lib/distutils/msvccompiler.py +++ b/Lib/distutils/msvccompiler.py @@ -164,6 +164,9 @@ def get_build_version(): i = i + len(prefix) s, rest = sys.version[i:].split(" ", 1) majorVersion = int(s[:-2]) - 6 + if majorVersion >= 13: + # v13 was skipped and should be v14 + majorVersion += 1 minorVersion = int(s[2:3]) / 10.0 # I don't think paths are affected by minor version in version 6 if majorVersion == 6: diff --git a/Lib/encodings/aliases.py b/Lib/encodings/aliases.py index a54cf774b7b1dd..c752683fcea256 100644 --- a/Lib/encodings/aliases.py +++ b/Lib/encodings/aliases.py @@ -516,6 +516,7 @@ 'utf8' : 'utf_8', 'utf8_ucs2' : 'utf_8', 'utf8_ucs4' : 'utf_8', + 'cp65001' : 'utf_8', # uu_codec codec 'uu' : 'uu_codec', diff --git a/Misc/NEWS.d/2.7.18.10.rst b/Misc/NEWS.d/2.7.18.10.rst new file mode 100644 index 00000000000000..7281381f4585a2 --- /dev/null +++ b/Misc/NEWS.d/2.7.18.10.rst @@ -0,0 +1,43 @@ +.. bpo: none +.. date: 2024-08-08 +.. nonce: +.. release date: 2024-08-08 +.. section: Core and Builtins + +Relocate vcruntime140.dll to Python executable folder. + +vcruntime140.dll has been moved to the same directory as Python.exe. + +.. bpo: none +.. date: 2024-08-08 +.. nonce: +.. release date: 2024-06-26 +.. section: Core and Builtins + +WSA Errors are handled on Unix + +We now convert WSAE* errors to unix equvalents if they are not supported. + +.. bpo: 36778 +.. date: 2019-05-10 +.. nonce: +.. release date: 2024-06-06 +.. section: Core and Builtins + +Handle Windows code page 65001 + +``cp65001`` encoding (Windows code page 65001) becomes an alias to ``utf_8`` +encoding. + +.. gh: 114315 +.. date: 2024-06-27 +.. nonce: +.. release date: 2024-08-08 +.. section: Core and Builtins + +CVE-2024-0397 Fix locking in cert_store_stats and get_ca_certs + +:meth:`ssl.SSLContext.cert_store_stats` and +:meth:`ssl.SSLContext.get_ca_certs` now correctly lock access to the +certificate store, when the :class:`ssl.SSLContext` is shared across +multiple threads. diff --git a/Modules/errnomodule.c b/Modules/errnomodule.c index 87ebab013a0b7c..90fddac6e310dd 100644 --- a/Modules/errnomodule.c +++ b/Modules/errnomodule.c @@ -6,6 +6,33 @@ /* Windows socket errors (WSA*) */ #ifdef MS_WINDOWS #include +/* The following constants were added to errno.h in VS2010 but have + preferred WSA equivalents. */ +#undef EADDRINUSE +#undef EADDRNOTAVAIL +#undef EAFNOSUPPORT +#undef EALREADY +#undef ECONNABORTED +#undef ECONNREFUSED +#undef ECONNRESET +#undef EDESTADDRREQ +#undef EHOSTUNREACH +#undef EINPROGRESS +#undef EISCONN +#undef ELOOP +#undef EMSGSIZE +#undef ENETDOWN +#undef ENETRESET +#undef ENETUNREACH +#undef ENOBUFS +#undef ENOPROTOOPT +#undef ENOTCONN +#undef ENOTSOCK +#undef EOPNOTSUPP +#undef EPROTONOSUPPORT +#undef EPROTOTYPE +#undef ETIMEDOUT +#undef EWOULDBLOCK #endif /* diff --git a/Objects/exceptions.c b/Objects/exceptions.c index fc601521208155..318aa12f86f91a 100644 --- a/Objects/exceptions.c +++ b/Objects/exceptions.c @@ -2042,6 +2042,62 @@ static PyMethodDef functions[] = { if (PyDict_SetItemString(bdict, # TYPE, PyExc_ ## TYPE)) \ Py_FatalError("Module dictionary insertion problem."); +#ifdef MS_WINDOWS +#include +/* The following constants were added to errno.h in VS2010 but have + preferred WSA equivalents. */ +#undef EADDRINUSE +#undef EADDRNOTAVAIL +#undef EAFNOSUPPORT +#undef EALREADY +#undef ECONNABORTED +#undef ECONNREFUSED +#undef ECONNRESET +#undef EDESTADDRREQ +#undef EHOSTUNREACH +#undef EINPROGRESS +#undef EISCONN +#undef ELOOP +#undef EMSGSIZE +#undef ENETDOWN +#undef ENETRESET +#undef ENETUNREACH +#undef ENOBUFS +#undef ENOPROTOOPT +#undef ENOTCONN +#undef ENOTSOCK +#undef EOPNOTSUPP +#undef EPROTONOSUPPORT +#undef EPROTOTYPE +#undef ETIMEDOUT +#undef EWOULDBLOCK + +#if defined(WSAEALREADY) && !defined(EALREADY) +#define EALREADY WSAEALREADY +#endif +#if defined(WSAECONNABORTED) && !defined(ECONNABORTED) +#define ECONNABORTED WSAECONNABORTED +#endif +#if defined(WSAECONNREFUSED) && !defined(ECONNREFUSED) +#define ECONNREFUSED WSAECONNREFUSED +#endif +#if defined(WSAECONNRESET) && !defined(ECONNRESET) +#define ECONNRESET WSAECONNRESET +#endif +#if defined(WSAEINPROGRESS) && !defined(EINPROGRESS) +#define EINPROGRESS WSAEINPROGRESS +#endif +#if defined(WSAESHUTDOWN) && !defined(ESHUTDOWN) +#define ESHUTDOWN WSAESHUTDOWN +#endif +#if defined(WSAETIMEDOUT) && !defined(ETIMEDOUT) +#define ETIMEDOUT WSAETIMEDOUT +#endif +#if defined(WSAEWOULDBLOCK) && !defined(EWOULDBLOCK) +#define EWOULDBLOCK WSAEWOULDBLOCK +#endif +#endif /* MS_WINDOWS */ + PyMODINIT_FUNC _PyExc_Init(void) diff --git a/PC/bdist_wininst/install.c b/PC/bdist_wininst/install.c index e3b52a80554bd7..a7d1c2c29c5083 100644 --- a/PC/bdist_wininst/install.c +++ b/PC/bdist_wininst/install.c @@ -1185,7 +1185,7 @@ static void CenterWindow(HWND hwnd) #include -BOOL CALLBACK +INT_PTR CALLBACK IntroDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) { LPNMHDR lpnm; @@ -1534,7 +1534,7 @@ SCHEME *GetScheme(int major, int minor) return old_scheme; } -BOOL CALLBACK +INT_PTR CALLBACK SelectPythonDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) { LPNMHDR lpnm; @@ -1836,7 +1836,7 @@ static void CloseLogfile(void) fclose(logfile); } -BOOL CALLBACK +INT_PTR CALLBACK InstallFilesDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) { LPNMHDR lpnm; @@ -1991,7 +1991,7 @@ InstallFilesDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) } -BOOL CALLBACK +INT_PTR CALLBACK FinishedDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) { LPNMHDR lpnm; @@ -2167,23 +2167,6 @@ BOOL NeedAutoUAC() return TRUE; } -// Returns TRUE if the platform supports UAC. -BOOL PlatformSupportsUAC() -{ - // Note that win2k does seem to support ShellExecute with 'runas', - // but does *not* support IsUserAnAdmin - so we just pretend things - // only work on XP and later. - BOOL bIsWindowsXPorLater; - OSVERSIONINFO winverinfo; - winverinfo.dwOSVersionInfoSize = sizeof(winverinfo); - if (!GetVersionEx(&winverinfo)) - return FALSE; // something bad has gone wrong - bIsWindowsXPorLater = - ( (winverinfo.dwMajorVersion > 5) || - ( (winverinfo.dwMajorVersion == 5) && (winverinfo.dwMinorVersion >= 1) )); - return bIsWindowsXPorLater; -} - // Spawn ourself as an elevated application. On failure, a message is // displayed to the user - but this app will always terminate, even // on error. @@ -2239,7 +2222,7 @@ int DoInstall(void) // See if we need to do the Vista UAC magic. if (strcmp(user_access_control, "force")==0) { - if (PlatformSupportsUAC() && !MyIsUserAnAdmin()) { + if (!MyIsUserAnAdmin()) { SpawnUAC(); return 0; } @@ -2247,7 +2230,7 @@ int DoInstall(void) } else if (strcmp(user_access_control, "auto")==0) { // Check if it looks like we need UAC control, based // on how Python itself was installed. - if (PlatformSupportsUAC() && !MyIsUserAnAdmin() && NeedAutoUAC()) { + if (!MyIsUserAnAdmin() && NeedAutoUAC()) { SpawnUAC(); return 0; } diff --git a/PC/layout/support/python.props b/PC/layout/support/python.props index 4a4ed47c08564c..75007b60056987 100644 --- a/PC/layout/support/python.props +++ b/PC/layout/support/python.props @@ -30,6 +30,7 @@ <_PythonRuntimeExe Include="$(PythonHome)\python*.dll" /> + <_PythonRuntimeExe Include="$(PythonHome)\vcruntime*.dll" /> <_PythonRuntimeExe Include="$(PythonHome)\python*.exe" Condition="$(IncludePythonExe) == 'true'" /> <_PythonRuntimeExe> %(Filename)%(Extension) diff --git a/PC/msvcrtmodule.c b/PC/msvcrtmodule.c index d4d62ab5cc8574..bf3ad93ccc5265 100644 --- a/PC/msvcrtmodule.c +++ b/PC/msvcrtmodule.c @@ -25,6 +25,8 @@ #ifdef _MSC_VER #if _MSC_VER >= 1500 && _MSC_VER < 1600 #include +#elif _MSC_VER >= 1600 +#include #endif #endif @@ -397,7 +399,7 @@ PyMODINIT_FUNC initmsvcrt(void) { int st; - PyObject *d; + PyObject *d, *version; PyObject *m = Py_InitModule("msvcrt", msvcrt_functions); if (m == NULL) return; @@ -411,6 +413,7 @@ initmsvcrt(void) insertint(d, "LK_UNLCK", _LK_UNLCK); /* constants for the crt versions */ + (void)st; #ifdef _VC_ASSEMBLY_PUBLICKEYTOKEN st = PyModule_AddStringConstant(m, "VC_ASSEMBLY_PUBLICKEYTOKEN", _VC_ASSEMBLY_PUBLICKEYTOKEN); @@ -426,4 +429,14 @@ initmsvcrt(void) __LIBRARIES_ASSEMBLY_NAME_PREFIX); if (st < 0)return; #endif + + /* constants for the 2010 crt versions */ +#if defined(_VC_CRT_MAJOR_VERSION) && defined (_VC_CRT_MINOR_VERSION) && defined(_VC_CRT_BUILD_VERSION) && defined(_VC_CRT_RBUILD_VERSION) + version = PyUnicode_FromFormat("%d.%d.%d.%d", _VC_CRT_MAJOR_VERSION, + _VC_CRT_MINOR_VERSION, + _VC_CRT_BUILD_VERSION, + _VC_CRT_RBUILD_VERSION); + st = PyModule_AddObject(m, "CRT_ASSEMBLY_VERSION", version); + if (st < 0) return NULL; +#endif } diff --git a/PCbuild/_bsddb.vcxproj b/PCbuild/_bsddb.vcxproj index 8ce64b500f1301..92b07b5825e393 100644 --- a/PCbuild/_bsddb.vcxproj +++ b/PCbuild/_bsddb.vcxproj @@ -67,7 +67,6 @@ ws2_32.lib;%(AdditionalDependencies) - 0x1e180000 diff --git a/PCbuild/_ctypes.vcxproj b/PCbuild/_ctypes.vcxproj index 5bcf4325d9da39..1e9e2f51323a4e 100644 --- a/PCbuild/_ctypes.vcxproj +++ b/PCbuild/_ctypes.vcxproj @@ -64,7 +64,6 @@ ..\Modules\_ctypes\libffi_msvc;%(AdditionalIncludeDirectories) - 0x1D1A0000 /EXPORT:DllGetClassObject,PRIVATE /EXPORT:DllCanUnloadNow,PRIVATE %(AdditionalOptions) diff --git a/PCbuild/_elementtree.vcxproj b/PCbuild/_elementtree.vcxproj index 511e26bb60dbd8..6d1f2dd94afb8a 100644 --- a/PCbuild/_elementtree.vcxproj +++ b/PCbuild/_elementtree.vcxproj @@ -64,9 +64,6 @@ ..\Modules\expat;%(AdditionalIncludeDirectories) _CRT_SECURE_NO_WARNINGS;USE_PYEXPAT_CAPI;XML_STATIC;%(PreprocessorDefinitions) - - 0x1D100000 - diff --git a/PCbuild/_msi.vcxproj b/PCbuild/_msi.vcxproj index 6c5fa8cf658174..ebf02f926211ab 100644 --- a/PCbuild/_msi.vcxproj +++ b/PCbuild/_msi.vcxproj @@ -62,7 +62,6 @@ cabinet.lib;msi.lib;rpcrt4.lib;%(AdditionalDependencies) - 0x1D160000 diff --git a/PCbuild/_multiprocessing.vcxproj b/PCbuild/_multiprocessing.vcxproj index 3a71c17f2200ab..fc666b8be89433 100644 --- a/PCbuild/_multiprocessing.vcxproj +++ b/PCbuild/_multiprocessing.vcxproj @@ -62,7 +62,6 @@ ws2_32.lib;%(AdditionalDependencies) - 0x1e1D0000 diff --git a/PCbuild/_socket.vcxproj b/PCbuild/_socket.vcxproj index 453d3f7f433d55..2debf21ff1e94c 100644 --- a/PCbuild/_socket.vcxproj +++ b/PCbuild/_socket.vcxproj @@ -62,7 +62,6 @@ ws2_32.lib;%(AdditionalDependencies) - 0x1e1D0000 diff --git a/PCbuild/_sqlite3.vcxproj b/PCbuild/_sqlite3.vcxproj index 0995a2c8a2de20..cb5b204e9ee8a1 100644 --- a/PCbuild/_sqlite3.vcxproj +++ b/PCbuild/_sqlite3.vcxproj @@ -64,9 +64,6 @@ $(sqlite3Dir)include;%(AdditionalIncludeDirectories) MODULE_NAME="sqlite3";%(PreprocessorDefinitions) - - 0x1e180000 - diff --git a/PCbuild/_testcapi.vcxproj b/PCbuild/_testcapi.vcxproj index 77df0cb34df92e..4c8e7ada4e598a 100644 --- a/PCbuild/_testcapi.vcxproj +++ b/PCbuild/_testcapi.vcxproj @@ -60,11 +60,6 @@ <_ProjectFileVersion>10.0.30319.1 - - - 0x1e1F0000 - - diff --git a/PCbuild/bz2.vcxproj b/PCbuild/bz2.vcxproj index 3cab2886c1d083..c4235db3517e38 100644 --- a/PCbuild/bz2.vcxproj +++ b/PCbuild/bz2.vcxproj @@ -77,9 +77,6 @@ $(bz2Dir);%(AdditionalIncludeDirectories) WIN32;_FILE_OFFSET_BITS=64;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;%(PreprocessorDefinitions) - - 0x1D170000 - diff --git a/PCbuild/python.vcxproj b/PCbuild/python.vcxproj index c1ab6e9ca9e143..a73a1a9229f391 100644 --- a/PCbuild/python.vcxproj +++ b/PCbuild/python.vcxproj @@ -66,7 +66,6 @@ Console 2000000 - 0x1d000000 diff --git a/PCbuild/pythoncore.vcxproj b/PCbuild/pythoncore.vcxproj index f8f59a7c37239f..1ea3cb60a06c39 100644 --- a/PCbuild/pythoncore.vcxproj +++ b/PCbuild/pythoncore.vcxproj @@ -78,7 +78,6 @@ $(OutDir);%(AdditionalLibraryDirectories);$(zlibLibDir) $(OutDir);%(AdditionalLibraryDirectories);$(zlibLibDir) $(OutDir);%(AdditionalLibraryDirectories);$(zlibLibDir) - 0x1e000000 diff --git a/PCbuild/pythonw.vcxproj b/PCbuild/pythonw.vcxproj index 8c5335c9563875..079594e9b15d5e 100644 --- a/PCbuild/pythonw.vcxproj +++ b/PCbuild/pythonw.vcxproj @@ -65,7 +65,6 @@ 2000000 - 0x1d000000 diff --git a/PCbuild/select.vcxproj b/PCbuild/select.vcxproj index 1cae1efd56cde8..ee526164d37ff2 100644 --- a/PCbuild/select.vcxproj +++ b/PCbuild/select.vcxproj @@ -61,7 +61,6 @@ ws2_32.lib;%(AdditionalDependencies) - 0x1D110000 diff --git a/PCbuild/unicodedata.vcxproj b/PCbuild/unicodedata.vcxproj index 92df09b010dbb0..426f81416e9806 100644 --- a/PCbuild/unicodedata.vcxproj +++ b/PCbuild/unicodedata.vcxproj @@ -59,11 +59,6 @@ <_ProjectFileVersion>10.0.30319.1 - - - 0x1D120000 - - diff --git a/Python/dynload_win.c b/Python/dynload_win.c index 4e5555e917fc58..018adb0e77210d 100644 --- a/Python/dynload_win.c +++ b/Python/dynload_win.c @@ -12,9 +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 {"_d.pyd", "rb", C_EXTENSION}, @@ -176,8 +177,10 @@ dl_funcptr _PyImport_GetDynLoadFunc(const char *fqname, const char *shortname, char pathbuf[260]; LPTSTR dummy; unsigned int old_mode; - ULONG_PTR cookie = 0; - /* We use LoadLibraryEx so Windows looks for dependent DLLs +#if HAVE_SXS + ULONG_PTR cookie = 0; +#endif + /* We use LoadLibraryEx so Windows looks for dependent DLLs in directory of pathname first. However, Windows95 can sometimes not work correctly unless the absolute path is used. If GetFullPathName() fails, the LoadLibrary @@ -190,12 +193,16 @@ dl_funcptr _PyImport_GetDynLoadFunc(const char *fqname, const char *shortname, sizeof(pathbuf), pathbuf, &dummy)) { +#if HAVE_SXS ULONG_PTR cookie = _Py_ActivateActCtx(); +#endif /* XXX This call doesn't exist in Windows CE */ hDLL = LoadLibraryEx(pathname, NULL, LOAD_WITH_ALTERED_SEARCH_PATH); - _Py_DeactivateActCtx(cookie); - } +#if HAVE_SXS + _Py_DeactivateActCtx(cookie); +#endif + } /* restore old error mode settings */ SetErrorMode(old_mode);