all-changes.patch 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386
  1. --- contrib/tools/python3/src/Modules/posixmodule.c (index)
  2. +++ contrib/tools/python3/src/Modules/posixmodule.c (working tree)
  3. @@ -288,6 +288,7 @@ corresponding Unix manual entries for more information on calls.");
  4. #endif
  5. #ifdef HAVE_GETRANDOM_SYSCALL
  6. # include <sys/syscall.h>
  7. +# include <sys/random.h>
  8. #endif
  9. #if defined(MS_WINDOWS)
  10. --- contrib/tools/python3/src/Lib/ctypes/__init__.py (index)
  11. +++ contrib/tools/python3/src/Lib/ctypes/__init__.py (working tree)
  12. @@ -11,6 +11,7 @@ from _ctypes import CFuncPtr as _CFuncPtr
  13. from _ctypes import __version__ as _ctypes_version
  14. from _ctypes import RTLD_LOCAL, RTLD_GLOBAL
  15. from _ctypes import ArgumentError
  16. +from .util import find_library as _find_library
  17. from struct import calcsize as _calcsize
  18. @@ -372,8 +373,15 @@ class CDLL(object):
  19. _restype_ = self._func_restype_
  20. self._FuncPtr = _FuncPtr
  21. + self._builtin = {}
  22. +
  23. if handle is None:
  24. - self._handle = _dlopen(self._name, mode)
  25. + if isinstance(self._name, dict):
  26. + self._builtin = self._name['symbols']
  27. + self._name = self._name['name']
  28. + self._handle = 0
  29. + else:
  30. + self._handle = _dlopen(self._name, mode)
  31. else:
  32. self._handle = handle
  33. @@ -391,7 +399,13 @@ class CDLL(object):
  34. return func
  35. def __getitem__(self, name_or_ordinal):
  36. - func = self._FuncPtr((name_or_ordinal, self))
  37. + if self._builtin:
  38. + if name_or_ordinal not in self._builtin:
  39. + raise AttributeError("function %r not found" % name_or_ordinal)
  40. + func = self._FuncPtr(self._builtin[name_or_ordinal])
  41. + else:
  42. + func = self._FuncPtr((name_or_ordinal, self))
  43. +
  44. if not isinstance(name_or_ordinal, int):
  45. func.__name__ = name_or_ordinal
  46. return func
  47. @@ -458,12 +472,20 @@ class LibraryLoader(object):
  48. cdll = LibraryLoader(CDLL)
  49. pydll = LibraryLoader(PyDLL)
  50. -if _os.name == "nt":
  51. - pythonapi = PyDLL("python dll", None, _sys.dllhandle)
  52. -elif _sys.platform == "cygwin":
  53. - pythonapi = PyDLL("libpython%d.%d.dll" % _sys.version_info[:2])
  54. -else:
  55. +#if _os.name == "nt":
  56. +# pythonapi = PyDLL("python dll", None, _sys.dllhandle)
  57. +#elif _sys.platform == "cygwin":
  58. +# pythonapi = PyDLL("libpython%d.%d.dll" % _sys.version_info[:2])
  59. +#else:
  60. +# pythonapi = PyDLL(None)
  61. +
  62. +try:
  63. pythonapi = PyDLL(None)
  64. +except:
  65. + try:
  66. + pythonapi = PyDLL(_find_library('python'))
  67. + except:
  68. + pythonapi = PyDLL(dict(name='python', symbols={}))
  69. if _os.name == "nt":
  70. --- contrib/tools/python3/src/Lib/ctypes/util.py (index)
  71. +++ contrib/tools/python3/src/Lib/ctypes/util.py (working tree)
  72. @@ -329,6 +329,16 @@ elif os.name == "posix":
  73. return _findSoname_ldconfig(name) or \
  74. _get_soname(_findLib_gcc(name)) or _get_soname(_findLib_ld(name))
  75. +try:
  76. + from library.python.symbols.module import find_library as _find_library
  77. +except ImportError:
  78. + pass
  79. +else:
  80. + _next_find_library = find_library
  81. +
  82. + def find_library(name):
  83. + return _find_library(name, _next_find_library)
  84. +
  85. ################################################################
  86. # test code
  87. --- contrib/tools/python3/src/Lib/doctest.py (index)
  88. +++ contrib/tools/python3/src/Lib/doctest.py (working tree)
  89. @@ -957,7 +957,7 @@ class DocTestFinder:
  90. return module.__dict__ is object.__globals__
  91. elif (inspect.ismethoddescriptor(object) or
  92. inspect.ismethodwrapper(object)):
  93. - if hasattr(object, '__objclass__'):
  94. + if hasattr(object, '__objclass__') and hasattr(object.__objclass__, '__module__'):
  95. obj_mod = object.__objclass__.__module__
  96. elif hasattr(object, '__module__'):
  97. obj_mod = object.__module__
  98. @@ -965,7 +965,10 @@ class DocTestFinder:
  99. return True # [XX] no easy way to tell otherwise
  100. return module.__name__ == obj_mod
  101. elif inspect.isclass(object):
  102. - return module.__name__ == object.__module__
  103. + try:
  104. + return module.__name__ == object.__module__
  105. + except:
  106. + return True
  107. elif hasattr(object, '__module__'):
  108. return module.__name__ == object.__module__
  109. elif isinstance(object, property):
  110. --- contrib/tools/python3/src/Lib/multiprocessing/popen_spawn_win32.py (index)
  111. +++ contrib/tools/python3/src/Lib/multiprocessing/popen_spawn_win32.py (working tree)
  112. @@ -65,5 +65,6 @@ class Popen(object):
  113. env["__PYVENV_LAUNCHER__"] = sys.executable
  114. else:
  115. - env = None
  116. + env = os.environ.copy()
  117. + env['Y_PYTHON_ENTRY_POINT'] = ':main'
  118. cmd = ' '.join('"%s"' % x for x in cmd)
  119. --- contrib/tools/python3/src/Lib/multiprocessing/spawn.py (index)
  120. +++ contrib/tools/python3/src/Lib/multiprocessing/spawn.py (working tree)
  121. @@ -82,7 +82,7 @@ def get_command_line(**kwds):
  122. '''
  123. Returns prefix of command line used for spawning a child process
  124. '''
  125. - if getattr(sys, 'frozen', False):
  126. + if False and getattr(sys, 'frozen', False):
  127. return ([sys.executable, '--multiprocessing-fork'] +
  128. ['%s=%r' % item for item in kwds.items()])
  129. else:
  130. --- contrib/tools/python3/src/Lib/multiprocessing/util.py (index)
  131. +++ contrib/tools/python3/src/Lib/multiprocessing/util.py (working tree)
  132. @@ -383,8 +383,11 @@ class ForkAwareThreadLock(object):
  133. class ForkAwareLocal(threading.local):
  134. - def __init__(self):
  135. - register_after_fork(self, lambda obj : obj.__dict__.clear())
  136. + def __new__(cls):
  137. + self = threading.local.__new__(cls)
  138. + register_after_fork(self, lambda obj: obj.__dict__.clear())
  139. + return self
  140. +
  141. def __reduce__(self):
  142. return type(self), ()
  143. @@ -444,14 +447,26 @@ def _flush_std_streams():
  144. # Start a program with only specified fds kept open
  145. #
  146. +
  147. +def _env_list():
  148. + # Based on fork_exec in subprocess.py.
  149. + env = os.environ.copy()
  150. + env['Y_PYTHON_ENTRY_POINT'] = ':main'
  151. + env_list = []
  152. + for k, v in env.items():
  153. + if '=' not in k:
  154. + env_list.append(os.fsencode(k) + b'=' + os.fsencode(v))
  155. + return env_list
  156. +
  157. +
  158. def spawnv_passfds(path, args, passfds):
  159. import _posixsubprocess
  160. import subprocess
  161. passfds = tuple(sorted(map(int, passfds)))
  162. errpipe_read, errpipe_write = os.pipe()
  163. try:
  164. return _posixsubprocess.fork_exec(
  165. - args, [path], True, passfds, None, None,
  166. + args, [path], True, passfds, None, _env_list(),
  167. -1, -1, -1, -1, -1, -1, errpipe_read, errpipe_write,
  168. False, False, -1, None, None, None, -1, None,
  169. subprocess._USE_VFORK)
  170. --- contrib/tools/python3/src/Modules/_ctypes/_ctypes.c (index)
  171. +++ contrib/tools/python3/src/Modules/_ctypes/_ctypes.c (working tree)
  172. @@ -109,6 +109,7 @@ bytes(cdata)
  173. // windows.h must be included before pycore internal headers
  174. #ifdef MS_WIN32
  175. # include <windows.h>
  176. +# include <Unknwn.h>
  177. #endif
  178. #include "pycore_call.h" // _PyObject_CallNoArgs()
  179. --- contrib/tools/python3/src/Modules/_ctypes/callbacks.c (index)
  180. +++ contrib/tools/python3/src/Modules/_ctypes/callbacks.c (working tree)
  181. @@ -7,6 +7,7 @@
  182. // windows.h must be included before pycore internal headers
  183. #ifdef MS_WIN32
  184. # include <windows.h>
  185. +# include <Unknwn.h>
  186. #endif
  187. #include "pycore_call.h" // _PyObject_CallNoArgs()
  188. --- contrib/tools/python3/src/Modules/_ctypes/callproc.c (index)
  189. +++ contrib/tools/python3/src/Modules/_ctypes/callproc.c (working tree)
  190. @@ -63,6 +63,7 @@
  191. #ifdef MS_WIN32
  192. #include <windows.h>
  193. +#include <Unknwn.h>
  194. #include <tchar.h>
  195. #else
  196. #include "ctypes_dlfcn.h"
  197. --- contrib/tools/python3/src/Modules/_ctypes/cfield.c (index)
  198. +++ contrib/tools/python3/src/Modules/_ctypes/cfield.c (working tree)
  199. @@ -6,6 +6,7 @@
  200. // windows.h must be included before pycore internal headers
  201. #ifdef MS_WIN32
  202. # include <windows.h>
  203. +# include <Unknwn.h>
  204. #endif
  205. #include "pycore_bitutils.h" // _Py_bswap32()
  206. --- contrib/tools/python3/src/Modules/_ctypes/stgdict.c (index)
  207. +++ contrib/tools/python3/src/Modules/_ctypes/stgdict.c (working tree)
  208. @@ -7,6 +7,7 @@
  209. // windows.h must be included before pycore internal headers
  210. #ifdef MS_WIN32
  211. # include <windows.h>
  212. +# include <Unknwn.h>
  213. #endif
  214. #include "pycore_call.h" // _PyObject_CallNoArgs()
  215. --- contrib/tools/python3/src/Modules/_decimal/libmpdec/io.c (index)
  216. +++ contrib/tools/python3/src/Modules/_decimal/libmpdec/io.c (working tree)
  217. @@ -37,7 +37,7 @@
  218. #include <stdlib.h>
  219. #include <string.h>
  220. -#include "io.h"
  221. +#include "mpd_io.h"
  222. #include "typearith.h"
  223. --- contrib/tools/python3/src/Modules/_decimal/libmpdec/mpdecimal.h (index)
  224. +++ contrib/tools/python3/src/Modules/_decimal/libmpdec/mpdecimal.h (working tree)
  225. @@ -96,17 +96,17 @@ const char *mpd_version(void);
  226. /* Configuration */
  227. /******************************************************************************/
  228. -#if defined(UNIVERSAL)
  229. +#if 1
  230. #if defined(CONFIG_64) || defined(CONFIG_32)
  231. #error "cannot use CONFIG_64 or CONFIG_32 with UNIVERSAL."
  232. #endif
  233. - #if defined(__ppc__)
  234. - #define CONFIG_32
  235. - #define ANSI
  236. - #elif defined(__ppc64__)
  237. + #if defined(__powerpc64__) || defined(_M_AMD64) || defined(__aarch64__)
  238. #define CONFIG_64
  239. #define ANSI
  240. - #elif defined(__i386__)
  241. + #elif defined(__powerpc__)
  242. + #define CONFIG_32
  243. + #define ANSI
  244. + #elif defined(__i386__) || defined(_M_IX86)
  245. #define CONFIG_32
  246. #define ANSI
  247. #elif defined(__x86_64__)
  248. --- contrib/tools/python3/src/Modules/_ssl.c (index)
  249. +++ contrib/tools/python3/src/Modules/_ssl.c (working tree)
  250. @@ -28,6 +28,10 @@
  251. /* Include symbols from _socket module */
  252. #include "socketmodule.h"
  253. +#ifdef _MSC_VER
  254. +#include <wincrypt.h>
  255. +#endif
  256. +
  257. #include "_ssl.h"
  258. /* Redefined below for Windows debug builds after important #includes */
  259. --- contrib/tools/python3/src/Modules/_winapi.c (index)
  260. +++ contrib/tools/python3/src/Modules/_winapi.c (working tree)
  261. @@ -41,6 +41,7 @@
  262. #define WINDOWS_LEAN_AND_MEAN
  263. #include "windows.h"
  264. +#include <winioctl.h>
  265. #include <crtdbg.h>
  266. #include "winreparse.h"
  267. --- contrib/tools/python3/src/Modules/getpath.c (index)
  268. +++ contrib/tools/python3/src/Modules/getpath.c (working tree)
  269. @@ -1,3 +1,4 @@
  270. +#define PYTHONPATH ":"
  271. /* Return the initial module search path. */
  272. #include "Python.h"
  273. --- contrib/tools/python3/src/Modules/main.c (index)
  274. +++ contrib/tools/python3/src/Modules/main.c (working tree)
  275. @@ -51,6 +51,7 @@ pymain_init(const _PyArgv *args)
  276. PyConfig config;
  277. PyConfig_InitPythonConfig(&config);
  278. + config.pathconfig_warnings = 0; /* Suppress errors from getpath.c */
  279. /* pass NULL as the config: config is read from command line arguments,
  280. environment variables, configuration files */
  281. --- contrib/tools/python3/src/Modules/posixmodule.c (index)
  282. +++ contrib/tools/python3/src/Modules/posixmodule.c (working tree)
  283. @@ -25,2 +25,3 @@ extern char *ctermid_r(char *);
  284. # include <windows.h>
  285. +# include <winioctl.h>
  286. # include <pathcch.h>
  287. --- contrib/tools/python3/src/PC/pyconfig.h (index)
  288. +++ contrib/tools/python3/src/PC/pyconfig.h (working tree)
  289. @@ -306,10 +306,6 @@ Py_NO_ENABLE_SHARED to find out. Also support MS_NO_COREDLL for b/w compat */
  290. # endif
  291. #endif
  292. -#ifdef _DEBUG
  293. -# define Py_DEBUG
  294. -#endif
  295. -
  296. #ifdef MS_WIN32
  297. @@ -460,7 +456,9 @@ Py_NO_ENABLE_SHARED to find out. Also support MS_NO_COREDLL for b/w compat */
  298. /* #define WITH_READLINE 1 */
  299. /* Use Python's own small-block memory-allocator. */
  300. +#ifndef address_sanitizer_enabled
  301. #define WITH_PYMALLOC 1
  302. +#endif
  303. /* Define if you want to compile in object freelists optimization */
  304. #define WITH_FREELISTS 1
  305. --- contrib/tools/python3/src/Python/initconfig.c (index)
  306. +++ contrib/tools/python3/src/Python/initconfig.c (working tree)
  307. @@ -163,7 +163,7 @@ int Py_InspectFlag = 0; /* Needed to determine whether to exit at SystemExit */
  308. int Py_OptimizeFlag = 0; /* Needed by compile.c */
  309. int Py_NoSiteFlag = 0; /* Suppress 'import site' */
  310. int Py_BytesWarningFlag = 0; /* Warn on str(bytes) and str(buffer) */
  311. -int Py_FrozenFlag = 0; /* Needed by getpath.c */
  312. +int Py_FrozenFlag = 1; /* Needed by getpath.c */
  313. int Py_IgnoreEnvironmentFlag = 0; /* e.g. PYTHONPATH, PYTHONHOME */
  314. int Py_DontWriteBytecodeFlag = 0; /* Suppress writing bytecode files (*.pyc) */
  315. int Py_NoUserSiteDirectory = 0; /* for -s and site.py */
  316. --- contrib/tools/python3/src/Python/pylifecycle.c (index)
  317. +++ contrib/tools/python3/src/Python/pylifecycle.c (working tree)
  318. @@ -230,6 +230,14 @@ init_importlib_external(PyThreadState *tstate)
  319. return _PyStatus_ERR("external importer setup failed");
  320. }
  321. Py_DECREF(value);
  322. +
  323. + value = PyImport_ImportModule("__res");
  324. + if (value == NULL) {
  325. + PyErr_Print();
  326. + return _PyStatus_ERR("can't import __res");
  327. + }
  328. + Py_DECREF(value);
  329. +
  330. return _PyImportZip_Init(tstate);
  331. }
  332. --- contrib/tools/python3/src/Python/sysmodule.c (index)
  333. +++ contrib/tools/python3/src/Python/sysmodule.c (working tree)
  334. @@ -1500,12 +1500,12 @@ sys_getwindowsversion_impl(PyObject *module)
  335. hKernel32 = GetModuleHandleW(L"kernel32.dll");
  336. Py_END_ALLOW_THREADS
  337. if (hKernel32 && GetModuleFileNameW(hKernel32, kernel32_path, MAX_PATH) &&
  338. - (verblock_size = GetFileVersionInfoSizeW(kernel32_path, NULL)) &&
  339. + (verblock_size = GetFileVersionInfoSizeExW(0, kernel32_path, NULL)) &&
  340. (verblock = PyMem_RawMalloc(verblock_size))) {
  341. VS_FIXEDFILEINFO *ffi;
  342. UINT ffi_len;
  343. - if (GetFileVersionInfoW(kernel32_path, 0, verblock_size, verblock) &&
  344. + if (GetFileVersionInfoExW(0, kernel32_path, 0, verblock_size, verblock) &&
  345. VerQueryValueW(verblock, L"", (LPVOID)&ffi, &ffi_len)) {
  346. realMajor = HIWORD(ffi->dwProductVersionMS);
  347. realMinor = LOWORD(ffi->dwProductVersionMS);