1 http://bugs.python.org/issue17797
2 http://connect.microsoft.com/VisualStudio/feedback/details/785119/
4 Visual Studio 2012 changed return value for fileno function that breaks
5 when python tries to check/setup stdin/out/err
6 GetStdHandle on Windows XP behaves contrary to the documentation...
7 diff -ur python3.org/Python/pythonrun.c python3/Python/pythonrun.c
8 --- python3.org/Python/pythonrun.c 2014-05-24 16:36:20.361672900 +0200
9 +++ python3/Python/pythonrun.c 2014-05-24 16:37:38.424159100 +0200
10 @@ -1036,7 +1036,15 @@
12 PyObject * encoding_attr;
13 char *encoding = NULL, *errors;
16 + OSVERSIONINFOEX osvi;
19 + ZeroMemory(&osvi, sizeof(osvi));
20 + osvi.dwOSVersionInfoSize = sizeof(osvi);
21 + GetVersionEx(&osvi);
22 + bIsWindowsXP = (osvi.dwMajorVersion < 6);
24 /* Hack to avoid a nasty recursion issue when Python is invoked
25 in verbose mode: pre-import the Latin-1 and UTF-8 codecs */
26 if ((m = PyImport_ImportModule("encodings.utf_8")) == NULL) {
27 @@ -1084,7 +1092,11 @@
28 * and fileno() may point to an invalid file descriptor. For example
29 * GUI apps don't have valid standard streams by default.
32 + if (!is_valid_fd(fd) || GetStdHandle(STD_INPUT_HANDLE) == NULL || bIsWindowsXP) {
34 if (!is_valid_fd(fd)) {
39 @@ -1099,7 +1111,11 @@
44 + if (!is_valid_fd(fd) || GetStdHandle(STD_OUTPUT_HANDLE) == NULL || bIsWindowsXP) {
46 if (!is_valid_fd(fd)) {
51 @@ -1115,7 +1131,11 @@
52 #if 1 /* Disable this if you have trouble debugging bootstrap stuff */
53 /* Set sys.stderr, replaces the preliminary stderr */
56 + if (!is_valid_fd(fd) || GetStdHandle(STD_ERROR_HANDLE) == NULL || bIsWindowsXP) {
58 if (!is_valid_fd(fd)) {