Closed
Description
This is a patch to make Python 2.7.11 build on VS2015:
From 4ab220c38c7d15192ed3b394f47e4196c947f056 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?D=C5=BEenan=20Zuki=C4=87?= <dzenan.zukic@kitware.com>
Date: Mon, 24 Oct 2016 09:13:30 -0400
Subject: [PATCH] Build with VS2015
---
Modules/posixmodule.c | 36 +++++-------------------------------
Modules/timemodule.c | 8 ++++----
2 files changed, 9 insertions(+), 35 deletions(-)
diff --git a/Modules/posixmodule.c b/Modules/posixmodule.c
index 4fc3ef7..d90953f 100644
--- a/Modules/posixmodule.c
+++ b/Modules/posixmodule.c
@@ -570,38 +570,12 @@ extern __declspec(dllimport) char * __pioinfo[];
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;
+ //a call to _get_osfhandle with invalid fd sets errno to EBADF
+ if (_get_osfhandle(fd) == INVALID_HANDLE_VALUE)
+ return 0;
+ else
+ return 1;
}
/* the special case of checking dup2. The target fd must be in a sensible range */
diff --git a/Modules/timemodule.c b/Modules/timemodule.c
index 12c43b0..8692080 100644
--- a/Modules/timemodule.c
+++ b/Modules/timemodule.c
@@ -710,7 +710,7 @@ inittimezone(PyObject *m) {
#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 @@ inittimezone(PyObject *m) {
#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
{
--
2.9.0.windows.1