all-changes.patch 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289
  1. --- contrib/tools/python3/Modules/posixmodule.c (index)
  2. +++ contrib/tools/python3/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/Lib/ctypes/__init__.py (index)
  11. +++ contrib/tools/python3/Lib/ctypes/__init__.py (working tree)
  12. @@ -11,6 +11,7 @@ from _ctypes import CFuncPtr as _CFuncPtr
  13. from _ctypes import RTLD_LOCAL, RTLD_GLOBAL
  14. from _ctypes import ArgumentError
  15. from _ctypes import SIZEOF_TIME_T
  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/Lib/ctypes/util.py (index)
  71. +++ contrib/tools/python3/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/Lib/doctest.py (index)
  88. +++ contrib/tools/python3/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/Lib/multiprocessing/popen_spawn_win32.py (index)
  111. +++ contrib/tools/python3/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/Lib/multiprocessing/spawn.py (index)
  120. +++ contrib/tools/python3/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/Lib/multiprocessing/util.py (index)
  131. +++ contrib/tools/python3/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/Modules/_decimal/libmpdec/io.c (index)
  171. +++ contrib/tools/python3/Modules/_decimal/libmpdec/io.c (working tree)
  172. @@ -37,7 +37,7 @@
  173. #include <stdlib.h>
  174. #include <string.h>
  175. -#include "io.h"
  176. +#include "mpd_io.h"
  177. #include "typearith.h"
  178. --- contrib/tools/python3/Modules/_decimal/libmpdec/mpdecimal.h (index)
  179. +++ contrib/tools/python3/Modules/_decimal/libmpdec/mpdecimal.h (working tree)
  180. @@ -96,17 +96,17 @@ const char *mpd_version(void);
  181. /* Configuration */
  182. /******************************************************************************/
  183. -#if defined(UNIVERSAL)
  184. +#if 1
  185. #if defined(CONFIG_64) || defined(CONFIG_32)
  186. #error "cannot use CONFIG_64 or CONFIG_32 with UNIVERSAL."
  187. #endif
  188. - #if defined(__ppc__)
  189. - #define CONFIG_32
  190. - #define ANSI
  191. - #elif defined(__ppc64__)
  192. + #if defined(__powerpc64__) || defined(_M_AMD64) || defined(__aarch64__)
  193. #define CONFIG_64
  194. #define ANSI
  195. - #elif defined(__i386__)
  196. + #elif defined(__powerpc__)
  197. + #define CONFIG_32
  198. + #define ANSI
  199. + #elif defined(__i386__) || defined(_M_IX86)
  200. #define CONFIG_32
  201. #define ANSI
  202. #elif defined(__x86_64__)
  203. --- contrib/tools/python3/Modules/getpath.c (index)
  204. +++ contrib/tools/python3/Modules/getpath.c (working tree)
  205. @@ -1,3 +1,4 @@
  206. +#define PYTHONPATH ":"
  207. /* Return the initial module search path. */
  208. #include "Python.h"
  209. --- contrib/tools/python3/Modules/main.c (index)
  210. +++ contrib/tools/python3/Modules/main.c (working tree)
  211. @@ -51,6 +51,7 @@ pymain_init(const _PyArgv *args)
  212. PyConfig config;
  213. PyConfig_InitPythonConfig(&config);
  214. + config.pathconfig_warnings = 0; /* Suppress errors from getpath.c */
  215. /* pass NULL as the config: config is read from command line arguments,
  216. environment variables, configuration files */
  217. --- contrib/tools/python3/PC/pyconfig.h (index)
  218. +++ contrib/tools/python3/PC/pyconfig.h (working tree)
  219. @@ -306,10 +306,6 @@ Py_NO_ENABLE_SHARED to find out. Also support MS_NO_COREDLL for b/w compat */
  220. # endif
  221. #endif
  222. -#ifdef _DEBUG
  223. -# define Py_DEBUG
  224. -#endif
  225. -
  226. #ifdef MS_WIN32
  227. @@ -460,7 +456,9 @@ Py_NO_ENABLE_SHARED to find out. Also support MS_NO_COREDLL for b/w compat */
  228. /* #define WITH_READLINE 1 */
  229. /* Use Python's own small-block memory-allocator. */
  230. +#ifndef address_sanitizer_enabled
  231. #define WITH_PYMALLOC 1
  232. +#endif
  233. /* Define if you want to compile in object freelists optimization */
  234. #define WITH_FREELISTS 1
  235. --- contrib/tools/python3/Python/initconfig.c (index)
  236. +++ contrib/tools/python3/Python/initconfig.c (working tree)
  237. @@ -163,7 +163,7 @@ int Py_InspectFlag = 0; /* Needed to determine whether to exit at SystemExit */
  238. int Py_OptimizeFlag = 0; /* Needed by compile.c */
  239. int Py_NoSiteFlag = 0; /* Suppress 'import site' */
  240. int Py_BytesWarningFlag = 0; /* Warn on str(bytes) and str(buffer) */
  241. -int Py_FrozenFlag = 0; /* Needed by getpath.c */
  242. +int Py_FrozenFlag = 1; /* Needed by getpath.c */
  243. int Py_IgnoreEnvironmentFlag = 0; /* e.g. PYTHONPATH, PYTHONHOME */
  244. int Py_DontWriteBytecodeFlag = 0; /* Suppress writing bytecode files (*.pyc) */
  245. int Py_NoUserSiteDirectory = 0; /* for -s and site.py */
  246. --- contrib/tools/python3/Python/import.c (index)
  247. +++ contrib/tools/python3/Python/import.c (working tree)
  248. @@ -2101,6 +2101,13 @@ init_importlib_external(PyInterpreterState *interp)
  249. return -1;
  250. }
  251. Py_DECREF(value);
  252. +
  253. + value = PyImport_ImportModule("__res");
  254. + if (value == NULL) {
  255. + return -1;
  256. + }
  257. + Py_DECREF(value);
  258. +
  259. return 0;
  260. }