-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathpython-2.7-superstatic-build.patch
More file actions
205 lines (192 loc) · 7.14 KB
/
python-2.7-superstatic-build.patch
File metadata and controls
205 lines (192 loc) · 7.14 KB
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
diff -ru Python-2.7.11.org/Lib/ctypes/__init__.py Python-2.7.11/Lib/ctypes/__init__.py
--- Python-2.7.11.org/Lib/ctypes/__init__.py Sat Dec 5 20:46:56 2015
+++ Python-2.7.11/Lib/ctypes/__init__.py Sat Feb 27 21:02:18 2016
@@ -445,12 +445,12 @@
cdll = LibraryLoader(CDLL)
pydll = LibraryLoader(PyDLL)
-if _os.name in ("nt", "ce"):
- 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)
+#if _os.name in ("nt", "ce"):
+# 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)
if _os.name in ("nt", "ce"):
diff -ru Python-2.7.11.org/Modules/posixmodule.c Python-2.7.11/Modules/posixmodule.c
--- Python-2.7.11.org/Modules/posixmodule.c Sat Dec 5 20:47:15 2015
+++ Python-2.7.11/Modules/posixmodule.c Sat Feb 27 21:02:50 2016
@@ -529,81 +529,16 @@
#endif
-#if defined _MSC_VER && _MSC_VER >= 1400
-/* Microsoft CRT in VS2005 and higher will verify that a filehandle is
- * valid and raise an assertion if it isn't.
- * Normally, an invalid fd is likely to be a C program error and therefore
- * an assertion can be useful, but it does contradict the POSIX standard
- * which for write(2) states:
- * "Otherwise, -1 shall be returned and errno set to indicate the error."
- * "[EBADF] The fildes argument is not a valid file descriptor open for
- * writing."
- * Furthermore, python allows the user to enter any old integer
- * as a fd and should merely raise a python exception on error.
- * The Microsoft CRT doesn't provide an official way to check for the
- * validity of a file descriptor, but we can emulate its internal behaviour
- * by using the exported __pinfo data member and knowledge of the
- * internal structures involved.
- * The structures below must be updated for each version of visual studio
- * according to the file internal.h in the CRT source, until MS comes
- * up with a less hacky way to do this.
- * (all of this is to avoid globally modifying the CRT behaviour using
- * _set_invalid_parameter_handler() and _CrtSetReportMode())
+#if defined _MSC_VER && _MSC_VER >= 1400 && _MSC_VER < 1900
+/* Legacy implementation of _PyVerify_fd_dup2 while transitioning to
+ * MSVC 14.0. This should eventually be removed. (issue23524)
*/
-/* The actual size of the structure is determined at runtime.
- * Only the first items must be present.
- */
-typedef struct {
- intptr_t osfhnd;
- char osfile;
-} my_ioinfo;
-
-extern __declspec(dllimport) char * __pioinfo[];
#define IOINFO_L2E 5
-#define IOINFO_ARRAY_ELTS (1 << IOINFO_L2E)
#define IOINFO_ARRAYS 64
+#define IOINFO_ARRAY_ELTS (1 << IOINFO_L2E)
#define _NHANDLE_ (IOINFO_ARRAYS * IOINFO_ARRAY_ELTS)
-#define FOPEN 0x01
#define _NO_CONSOLE_FILENO (intptr_t)-2
-/* This function emulates what the windows CRT does to validate file handles */
-int
-_PyVerify_fd(int fd)
-{
- const int i1 = fd >> IOINFO_L2E;
- const int i2 = fd & ((1 << IOINFO_L2E) - 1);
-
- static int sizeof_ioinfo = 0;
-
- /* Determine the actual size of the ioinfo structure,
- * as used by the CRT loaded in memory
- */
- if (sizeof_ioinfo == 0 && __pioinfo[0] != NULL) {
- sizeof_ioinfo = _msize(__pioinfo[0]) / IOINFO_ARRAY_ELTS;
- }
- if (sizeof_ioinfo == 0) {
- /* This should not happen... */
- goto fail;
- }
-
- /* See that it isn't a special CLEAR fileno */
- if (fd != _NO_CONSOLE_FILENO) {
- /* Microsoft CRT would check that 0<=fd<_nhandle but we can't do that. Instead
- * we check pointer validity and other info
- */
- if (0 <= i1 && i1 < IOINFO_ARRAYS && __pioinfo[i1] != NULL) {
- /* finally, check that the file is open */
- my_ioinfo* info = (my_ioinfo*)(__pioinfo[i1] + i2 * sizeof_ioinfo);
- if (info->osfile & FOPEN) {
- return 1;
- }
- }
- }
- fail:
- errno = EBADF;
- return 0;
-}
-
/* the special case of checking dup2. The target fd must be in a sensible range */
static int
_PyVerify_fd_dup2(int fd1, int fd2)
@@ -618,8 +553,22 @@
return 0;
}
#else
-/* dummy version. _PyVerify_fd() is already defined in fileobject.h */
-#define _PyVerify_fd_dup2(A, B) (1)
+/* This function lets the Windows CRT validate the file handle without
+ + terminating the process if it's invalid. */
+int
+_PyVerify_fd(int fd)
+{
+ intptr_t osh;
+ /* Fast check for the only condition we know */
+ if (fd < 0) {
+ _set_errno(EBADF);
+ return 0;
+ }
+ osh = _get_osfhandle(fd);
+ return osh != (intptr_t)-1;
+}
+
+#define _PyVerify_fd_dup2(fd1, fd2) (_PyVerify_fd(fd1) && (fd2) >= 0)
#endif
/* Return a dictionary corresponding to the POSIX environment table */
diff -ru Python-2.7.11.org/Modules/timemodule.c Python-2.7.11/Modules/timemodule.c
--- Python-2.7.11.org/Modules/timemodule.c Sat Dec 5 20:47:15 2015
+++ Python-2.7.11/Modules/timemodule.c Sat Feb 27 21:02:18 2016
@@ -710,7 +710,7 @@
#ifdef PYOS_OS2
PyModule_AddIntConstant(m, "timezone", _timezone);
#else /* !PYOS_OS2 */
- PyModule_AddIntConstant(m, "timezone", timezone);
+ PyModule_AddIntConstant(m, "timezone", _timezone);
#endif /* PYOS_OS2 */
#ifdef HAVE_ALTZONE
PyModule_AddIntConstant(m, "altzone", altzone);
@@ -718,12 +718,12 @@
#ifdef PYOS_OS2
PyModule_AddIntConstant(m, "altzone", _timezone-3600);
#else /* !PYOS_OS2 */
- PyModule_AddIntConstant(m, "altzone", timezone-3600);
+ PyModule_AddIntConstant(m, "altzone", _timezone-3600);
#endif /* PYOS_OS2 */
#endif
- PyModule_AddIntConstant(m, "daylight", daylight);
+ PyModule_AddIntConstant(m, "daylight", _daylight);
PyModule_AddObject(m, "tzname",
- Py_BuildValue("(zz)", tzname[0], tzname[1]));
+ Py_BuildValue("(zz)", _tzname[0], _tzname[1]));
#else /* !HAVE_TZNAME || __GLIBC__ || __CYGWIN__*/
#ifdef HAVE_STRUCT_TM_TM_ZONE
{
diff -ru Python-2.7.11.org/PC/config.c Python-2.7.11/PC/config.c
--- Python-2.7.11.org/PC/config.c Sat Dec 5 20:47:17 2015
+++ Python-2.7.11/PC/config.c Sat Feb 27 21:02:18 2016
@@ -69,6 +69,12 @@
extern void init_io(void);
extern void _PyWarnings_Init(void);
+extern void init_ssl(void);
+extern void init_hashlib(void);
+extern void init_ctypes(void);
+extern void init_socket(void);
+extern void initselect(void);
+
/* tools/freeze/makeconfig.py marker for additional "extern" */
/* -- ADDMODULE MARKER 1 -- */
@@ -164,6 +170,12 @@
{"_warnings", _PyWarnings_Init},
{"_io", init_io},
+
+ {"_ctypes", init_ctypes},
+ {"_ssl", init_ssl},
+ {"_hashlib", init_hashlib},
+ {"_socket", init_socket},
+ {"select", initselect},
/* Sentinel */
{0, 0}
diff -ru Python-2.7.11.org/PC/pyconfig.h Python-2.7.11/PC/pyconfig.h
--- Python-2.7.11.org/PC/pyconfig.h Sat Dec 5 20:47:18 2015
+++ Python-2.7.11/PC/pyconfig.h Sat Feb 27 21:02:18 2016
@@ -583,7 +583,7 @@
/* #define HAVE_CLOCK */
/* Define when any dynamic module loading is enabled */
-#define HAVE_DYNAMIC_LOADING
+/* #define HAVE_DYNAMIC_LOADING */
/* Define if you have ftime. */
#ifndef MS_WINCE