| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1866,6 +1866,10 @@ like ``find_library("c")`` will fail and return ``None``. | |||
| 1866 | 1866 | ||
| 1867 | 1867 | .. availability:: Windows | |
| 1868 | 1868 | ||
| 1869 | + .. soft-deprecated:: 3.16 | ||
| 1870 | + This function now always returns ``None``, as there are no more | ||
| 1871 | + VC runtime DLLs that are a single file and supported by Microsoft. | ||
| 1872 | + | ||
| 1869 | 1873 | ||
| 1870 | 1874 | .. _ctypes-listing-loaded-shared-libraries: | |
| 1871 | 1875 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -13,56 +13,19 @@ | |||
| 13 | 13 | ||
| 14 | 14 | # find_library(name) returns the pathname of a library, or None. | |
| 15 | 15 | if os.name == "nt": | |
| 16 | - | ||
| 17 | - def _get_build_version(): | ||
| 18 | - """Return the version of MSVC that was used to build Python. | ||
| 19 | - | ||
| 20 | - For Python 2.3 and up, the version number is included in | ||
| 21 | - sys.version. For earlier versions, assume the compiler is MSVC 6. | ||
| 22 | - """ | ||
| 23 | - # This function was copied from Lib/distutils/msvccompiler.py | ||
| 24 | - prefix = "MSC v." | ||
| 25 | - i = sys.version.find(prefix) | ||
| 26 | - if i == -1: | ||
| 27 | - return 6 | ||
| 28 | - i = i + len(prefix) | ||
| 29 | - s, rest = sys.version[i:].split(" ", 1) | ||
| 30 | - majorVersion = int(s[:-2]) - 6 | ||
| 31 | - if majorVersion >= 13: | ||
| 32 | - majorVersion += 1 | ||
| 33 | - minorVersion = int(s[2:3]) / 10.0 | ||
| 34 | - # I don't think paths are affected by minor version in version 6 | ||
| 35 | - if majorVersion == 6: | ||
| 36 | - minorVersion = 0 | ||
| 37 | - if majorVersion >= 6: | ||
| 38 | - return majorVersion + minorVersion | ||
| 39 | - # else we don't know what version of the compiler this is | ||
| 40 | - return None | ||
| 41 | - | ||
| 42 | 16 | def find_msvcrt(): | |
| 43 | - """Return the name of the VC runtime dll""" | ||
| 44 | - version = _get_build_version() | ||
| 45 | - if version is None: | ||
| 46 | - # better be safe than sorry | ||
| 47 | - return None | ||
| 48 | - if version <= 6: | ||
| 49 | - clibname = 'msvcrt' | ||
| 50 | - elif version <= 13: | ||
| 51 | - clibname = 'msvcr%d' % (version * 10) | ||
| 52 | - else: | ||
| 53 | - # CRT is no longer directly loadable. See issue23606 for the | ||
| 54 | - # discussion about alternative approaches. | ||
| 55 | - return None | ||
| 56 | - | ||
| 57 | - # If python was built with in debug mode | ||
| 58 | - import importlib.machinery | ||
| 59 | - if '_d.pyd' in importlib.machinery.EXTENSION_SUFFIXES: | ||
| 60 | - clibname += 'd' | ||
| 61 | - return clibname+'.dll' | ||
| 17 | + """Return the name of the VC runtime dll. | ||
| 18 | + This is soft deprecated as of Python 3.16.""" | ||
| 19 | + # See gh-154199. In short, this function wasn't able to return | ||
| 20 | + # newer msvcrt versions (because there was no single msvcrt DLL), | ||
| 21 | + # and the versions that are a single DLL are no longer supported | ||
| 22 | + # by Microsoft. | ||
| 23 | + return None | ||
| 62 | 24 | ||
| 63 | 25 | def find_library(name): | |
| 64 | 26 | if name in ('c', 'm'): | |
| 65 | - return find_msvcrt() | ||
| 27 | + # See gh-67794; there is no single VC runtime DLL anymore. | ||
| 28 | + return None | ||
| 66 | 29 | # See MSDN for the REAL search order. | |
| 67 | 30 | for directory in os.environ['PATH'].split(os.pathsep): | |
| 68 | 31 | fname = os.path.join(directory, name) | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,2 @@ | |||
| 1 | + Make :func:`ctypes.util.find_msvcrt` always return ``None`` for | ||
| 2 | + compatibility reasons. | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments