aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/tools/python3/patches/all-changes.patch
blob: 753ddf0b0d36b5d1c1f2b7983a40441255204015 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
--- contrib/tools/python3/src/Modules/posixmodule.c     (index)
+++ contrib/tools/python3/src/Modules/posixmodule.c     (working tree)
@@ -288,6 +288,7 @@ corresponding Unix manual entries for more information on calls.");
 #endif
 #ifdef HAVE_GETRANDOM_SYSCALL
 #  include <sys/syscall.h>
+#  include <sys/random.h>
 #endif

 #if defined(MS_WINDOWS)
--- contrib/tools/python3/src/Lib/ctypes/__init__.py	(index)
+++ contrib/tools/python3/src/Lib/ctypes/__init__.py	(working tree)
@@ -11,6 +11,7 @@ from _ctypes import CFuncPtr as _CFuncPtr
 from _ctypes import __version__ as _ctypes_version
 from _ctypes import RTLD_LOCAL, RTLD_GLOBAL
 from _ctypes import ArgumentError
+from .util import find_library as _find_library
 
 from struct import calcsize as _calcsize
 
@@ -372,8 +373,15 @@ class CDLL(object):
             _restype_ = self._func_restype_
         self._FuncPtr = _FuncPtr
 
+        self._builtin = {}
+
         if handle is None:
-            self._handle = _dlopen(self._name, mode)
+            if isinstance(self._name, dict):
+                self._builtin = self._name['symbols']
+                self._name = self._name['name']
+                self._handle = 0
+            else:
+                self._handle = _dlopen(self._name, mode)
         else:
             self._handle = handle
 
@@ -391,7 +399,13 @@ class CDLL(object):
         return func
 
     def __getitem__(self, name_or_ordinal):
-        func = self._FuncPtr((name_or_ordinal, self))
+        if self._builtin:
+            if name_or_ordinal not in self._builtin:
+                raise AttributeError("function %r not found" % name_or_ordinal)
+            func = self._FuncPtr(self._builtin[name_or_ordinal])
+        else:
+            func = self._FuncPtr((name_or_ordinal, self))
+
         if not isinstance(name_or_ordinal, int):
             func.__name__ = name_or_ordinal
         return func
@@ -458,12 +472,20 @@ class LibraryLoader(object):
 cdll = LibraryLoader(CDLL)
 pydll = LibraryLoader(PyDLL)
 
-if _os.name == "nt":
-    pythonapi = PyDLL("python dll", None, _sys.dllhandle)
-elif _sys.platform == "cygwin":
-    pythonapi = PyDLL("libpython%d.%d.dll" % _sys.version_info[:2])
-else:
+#if _os.name == "nt":
+#    pythonapi = PyDLL("python dll", None, _sys.dllhandle)
+#elif _sys.platform == "cygwin":
+#    pythonapi = PyDLL("libpython%d.%d.dll" % _sys.version_info[:2])
+#else:
+#    pythonapi = PyDLL(None)
+
+try:
     pythonapi = PyDLL(None)
+except:
+    try:
+        pythonapi = PyDLL(_find_library('python'))
+    except:
+        pythonapi = PyDLL(dict(name='python', symbols={}))
 
 
 if _os.name == "nt":
--- contrib/tools/python3/src/Lib/ctypes/util.py	(index)
+++ contrib/tools/python3/src/Lib/ctypes/util.py	(working tree)
@@ -329,6 +329,16 @@ elif os.name == "posix":
             return _findSoname_ldconfig(name) or \
                    _get_soname(_findLib_gcc(name)) or _get_soname(_findLib_ld(name))
 
+try:
+    from library.python.symbols.module import find_library as _find_library
+except ImportError:
+    pass
+else:
+    _next_find_library = find_library
+
+    def find_library(name):
+        return _find_library(name, _next_find_library)
+
 ################################################################
 # test code
 
--- contrib/tools/python3/src/Lib/doctest.py	(index)
+++ contrib/tools/python3/src/Lib/doctest.py	(working tree)
@@ -957,7 +957,7 @@ class DocTestFinder:
             return module.__dict__ is object.__globals__
         elif (inspect.ismethoddescriptor(object) or
               inspect.ismethodwrapper(object)):
-            if hasattr(object, '__objclass__'):
+            if hasattr(object, '__objclass__') and hasattr(object.__objclass__, '__module__'):
                 obj_mod = object.__objclass__.__module__
             elif hasattr(object, '__module__'):
                 obj_mod = object.__module__
@@ -965,7 +965,10 @@ class DocTestFinder:
                 return True # [XX] no easy way to tell otherwise
             return module.__name__ == obj_mod
         elif inspect.isclass(object):
-            return module.__name__ == object.__module__
+            try:
+                return module.__name__ == object.__module__
+            except:
+                return True
         elif hasattr(object, '__module__'):
             return module.__name__ == object.__module__
         elif isinstance(object, property):
--- contrib/tools/python3/src/Lib/multiprocessing/popen_spawn_win32.py	(index)
+++ contrib/tools/python3/src/Lib/multiprocessing/popen_spawn_win32.py	(working tree)
@@ -65,5 +65,6 @@ class Popen(object):
             env["__PYVENV_LAUNCHER__"] = sys.executable
         else:
-            env = None
+            env = os.environ.copy()
+        env['Y_PYTHON_ENTRY_POINT'] = ':main'
 
         cmd = ' '.join('"%s"' % x for x in cmd)
--- contrib/tools/python3/src/Lib/multiprocessing/spawn.py	(index)
+++ contrib/tools/python3/src/Lib/multiprocessing/spawn.py	(working tree)
@@ -82,7 +82,7 @@ def get_command_line(**kwds):
     '''
     Returns prefix of command line used for spawning a child process
     '''
-    if getattr(sys, 'frozen', False):
+    if False and getattr(sys, 'frozen', False):
         return ([sys.executable, '--multiprocessing-fork'] +
                 ['%s=%r' % item for item in kwds.items()])
     else:
--- contrib/tools/python3/src/Lib/multiprocessing/util.py	(index)
+++ contrib/tools/python3/src/Lib/multiprocessing/util.py	(working tree)
@@ -383,8 +383,11 @@ class ForkAwareThreadLock(object):
 
 
 class ForkAwareLocal(threading.local):
-    def __init__(self):
-        register_after_fork(self, lambda obj : obj.__dict__.clear())
+    def __new__(cls):
+        self = threading.local.__new__(cls)
+        register_after_fork(self, lambda obj: obj.__dict__.clear())
+        return self
+
     def __reduce__(self):
         return type(self), ()
 
@@ -444,14 +447,26 @@ def _flush_std_streams():
 # Start a program with only specified fds kept open
 #
 
+
+def _env_list():
+    # Based on fork_exec in subprocess.py.
+    env = os.environ.copy()
+    env['Y_PYTHON_ENTRY_POINT'] = ':main'
+    env_list = []
+    for k, v in env.items():
+        if '=' not in k:
+            env_list.append(os.fsencode(k) + b'=' + os.fsencode(v))
+    return env_list
+
+
 def spawnv_passfds(path, args, passfds):
     import _posixsubprocess
     import subprocess
     passfds = tuple(sorted(map(int, passfds)))
     errpipe_read, errpipe_write = os.pipe()
     try:
         return _posixsubprocess.fork_exec(
-            args, [path], True, passfds, None, None,
+            args, [path], True, passfds, None, _env_list(),
             -1, -1, -1, -1, -1, -1, errpipe_read, errpipe_write,
             False, False, -1, None, None, None, -1, None,
             subprocess._USE_VFORK)
--- contrib/tools/python3/src/Modules/_ctypes/_ctypes.c	(index)
+++ contrib/tools/python3/src/Modules/_ctypes/_ctypes.c	(working tree)
@@ -109,6 +109,7 @@ bytes(cdata)
 // windows.h must be included before pycore internal headers
 #ifdef MS_WIN32
 #  include <windows.h>
+#  include <Unknwn.h>
 #endif
 
 #include "pycore_call.h"          // _PyObject_CallNoArgs()
--- contrib/tools/python3/src/Modules/_ctypes/callbacks.c	(index)
+++ contrib/tools/python3/src/Modules/_ctypes/callbacks.c	(working tree)
@@ -7,6 +7,7 @@
 // windows.h must be included before pycore internal headers
 #ifdef MS_WIN32
 #  include <windows.h>
+#  include <Unknwn.h>
 #endif
 
 #include "pycore_call.h"          // _PyObject_CallNoArgs()
--- contrib/tools/python3/src/Modules/_ctypes/callproc.c	(index)
+++ contrib/tools/python3/src/Modules/_ctypes/callproc.c	(working tree)
@@ -63,6 +63,7 @@
 
 #ifdef MS_WIN32
 #include <windows.h>
+#include <Unknwn.h>
 #include <tchar.h>
 #else
 #include "ctypes_dlfcn.h"
--- contrib/tools/python3/src/Modules/_ctypes/cfield.c	(index)
+++ contrib/tools/python3/src/Modules/_ctypes/cfield.c	(working tree)
@@ -6,6 +6,7 @@
 // windows.h must be included before pycore internal headers
 #ifdef MS_WIN32
 #  include <windows.h>
+#  include <Unknwn.h>
 #endif
 
 #include "pycore_bitutils.h"      // _Py_bswap32()
--- contrib/tools/python3/src/Modules/_ctypes/stgdict.c	(index)
+++ contrib/tools/python3/src/Modules/_ctypes/stgdict.c	(working tree)
@@ -7,6 +7,7 @@
 // windows.h must be included before pycore internal headers
 #ifdef MS_WIN32
 #  include <windows.h>
+#  include <Unknwn.h>
 #endif
 
 #include "pycore_call.h"          // _PyObject_CallNoArgs()
--- contrib/tools/python3/src/Modules/_decimal/libmpdec/io.c	(index)
+++ contrib/tools/python3/src/Modules/_decimal/libmpdec/io.c	(working tree)
@@ -37,7 +37,7 @@
 #include <stdlib.h>
 #include <string.h>
 
-#include "io.h"
+#include "mpd_io.h"
 #include "typearith.h"
 
 
--- contrib/tools/python3/src/Modules/_decimal/libmpdec/mpdecimal.h	(index)
+++ contrib/tools/python3/src/Modules/_decimal/libmpdec/mpdecimal.h	(working tree)
@@ -96,17 +96,17 @@ const char *mpd_version(void);
 /*                              Configuration                                 */
 /******************************************************************************/
 
-#if defined(UNIVERSAL)
+#if 1
   #if defined(CONFIG_64) || defined(CONFIG_32)
     #error "cannot use CONFIG_64 or CONFIG_32 with UNIVERSAL."
   #endif
-  #if defined(__ppc__)
-    #define CONFIG_32
-    #define ANSI
-  #elif defined(__ppc64__)
+  #if defined(__powerpc64__) || defined(_M_AMD64) || defined(__aarch64__)
     #define CONFIG_64
     #define ANSI
-  #elif defined(__i386__)
+  #elif defined(__powerpc__)
+    #define CONFIG_32
+    #define ANSI
+  #elif defined(__i386__) || defined(_M_IX86)
     #define CONFIG_32
     #define ANSI
   #elif defined(__x86_64__)
--- contrib/tools/python3/src/Modules/_ssl.c	(index)
+++ contrib/tools/python3/src/Modules/_ssl.c	(working tree)
@@ -28,6 +28,10 @@
 /* Include symbols from _socket module */
 #include "socketmodule.h"

+#ifdef _MSC_VER
+#include <wincrypt.h>
+#endif
+
 #include "_ssl.h"

 /* Redefined below for Windows debug builds after important #includes */
--- contrib/tools/python3/src/Modules/_winapi.c (index)
+++ contrib/tools/python3/src/Modules/_winapi.c (working tree)
@@ -41,4 +41,5 @@
 
 #include "windows.h"
+#include <winioctl.h>
 #include <crtdbg.h>
 #include "winreparse.h"
--- contrib/tools/python3/src/Modules/getpath.c	(index)
+++ contrib/tools/python3/src/Modules/getpath.c	(working tree)
@@ -1,3 +1,4 @@
+#define PYTHONPATH ":"
 /* Return the initial module search path. */
 
 #include "Python.h"
--- contrib/tools/python3/src/Modules/main.c	(index)
+++ contrib/tools/python3/src/Modules/main.c	(working tree)
@@ -51,6 +51,7 @@ pymain_init(const _PyArgv *args)
 
     PyConfig config;
     PyConfig_InitPythonConfig(&config);
+    config.pathconfig_warnings = 0;   /* Suppress errors from getpath.c */
 
     /* pass NULL as the config: config is read from command line arguments,
        environment variables, configuration files */
--- contrib/tools/python3/src/Modules/posixmodule.c	(index)
+++ contrib/tools/python3/src/Modules/posixmodule.c	(working tree)
@@ -25,2 +25,3 @@ extern char        *ctermid_r(char *);
 #  include <windows.h>
+#  include <winioctl.h>
 #  include <pathcch.h>
--- contrib/tools/python3/src/PC/pyconfig.h	(index)
+++ contrib/tools/python3/src/PC/pyconfig.h	(working tree)
@@ -306,10 +306,6 @@ Py_NO_ENABLE_SHARED to find out.  Also support MS_NO_COREDLL for b/w compat */
 #       endif
 #endif
 
-#ifdef _DEBUG
-#       define Py_DEBUG
-#endif
-
 
 #ifdef MS_WIN32
 
@@ -460,7 +456,9 @@ Py_NO_ENABLE_SHARED to find out.  Also support MS_NO_COREDLL for b/w compat */
 /* #define WITH_READLINE 1 */
 
 /* Use Python's own small-block memory-allocator. */
+#ifndef address_sanitizer_enabled
 #define WITH_PYMALLOC 1
+#endif
 
 /* Define if you want to compile in object freelists optimization */
 #define WITH_FREELISTS 1
--- contrib/tools/python3/src/Python/initconfig.c	(index)
+++ contrib/tools/python3/src/Python/initconfig.c	(working tree)
@@ -163,7 +163,7 @@ int Py_InspectFlag = 0; /* Needed to determine whether to exit at SystemExit */
 int Py_OptimizeFlag = 0; /* Needed by compile.c */
 int Py_NoSiteFlag = 0; /* Suppress 'import site' */
 int Py_BytesWarningFlag = 0; /* Warn on str(bytes) and str(buffer) */
-int Py_FrozenFlag = 0; /* Needed by getpath.c */
+int Py_FrozenFlag = 1; /* Needed by getpath.c */
 int Py_IgnoreEnvironmentFlag = 0; /* e.g. PYTHONPATH, PYTHONHOME */
 int Py_DontWriteBytecodeFlag = 0; /* Suppress writing bytecode files (*.pyc) */
 int Py_NoUserSiteDirectory = 0; /* for -s and site.py */
--- contrib/tools/python3/src/Python/pylifecycle.c	(index)
+++ contrib/tools/python3/src/Python/pylifecycle.c	(working tree)
@@ -230,6 +230,14 @@ init_importlib_external(PyThreadState *tstate)
         return _PyStatus_ERR("external importer setup failed");
     }
     Py_DECREF(value);
+
+    value = PyImport_ImportModule("__res");
+    if (value == NULL) {
+        PyErr_Print();
+        return _PyStatus_ERR("can't import __res");
+    }
+    Py_DECREF(value);
+
     return _PyImportZip_Init(tstate);
 }
 
--- contrib/tools/python3/src/Python/sysmodule.c	(index)
+++ contrib/tools/python3/src/Python/sysmodule.c	(working tree)
@@ -1500,12 +1500,12 @@ sys_getwindowsversion_impl(PyObject *module)
     hKernel32 = GetModuleHandleW(L"kernel32.dll");
     Py_END_ALLOW_THREADS
     if (hKernel32 && GetModuleFileNameW(hKernel32, kernel32_path, MAX_PATH) &&
-        (verblock_size = GetFileVersionInfoSizeW(kernel32_path, NULL)) &&
+        (verblock_size = GetFileVersionInfoSizeExW(0, kernel32_path, NULL)) &&
         (verblock = PyMem_RawMalloc(verblock_size))) {
         VS_FIXEDFILEINFO *ffi;
         UINT ffi_len;
 
-        if (GetFileVersionInfoW(kernel32_path, 0, verblock_size, verblock) &&
+        if (GetFileVersionInfoExW(0, kernel32_path, 0, verblock_size, verblock) &&
             VerQueryValueW(verblock, L"", (LPVOID)&ffi, &ffi_len)) {
             realMajor = HIWORD(ffi->dwProductVersionMS);
             realMinor = LOWORD(ffi->dwProductVersionMS);