summaryrefslogtreecommitdiffstats
path: root/Modules/_io
diff options
context:
space:
mode:
authorSteve Dower <steve.dower@microsoft.com>2017-02-05 01:36:47 (GMT)
committerSteve Dower <steve.dower@microsoft.com>2017-02-05 01:36:47 (GMT)
commita7e164881e9b853044ab1dcc3063a9aba8b83b19 (patch)
tree0258917fce1d723fb49bde641e85e6146433de11 /Modules/_io
parent6f805628625e0cf4ee2d420735f7b15a93715aca (diff)
downloadcpython-a7e164881e9b853044ab1dcc3063a9aba8b83b19.zip
cpython-a7e164881e9b853044ab1dcc3063a9aba8b83b19.tar.gz
cpython-a7e164881e9b853044ab1dcc3063a9aba8b83b19.tar.bz2
Adds precheck for console filename to fix Windows 7.
Diffstat (limited to 'Modules/_io')
-rw-r--r--Modules/_io/winconsoleio.c14
1 files changed, 13 insertions, 1 deletions
diff --git a/Modules/_io/winconsoleio.c b/Modules/_io/winconsoleio.c
index 1ad0bfc..1d169e2 100644
--- a/Modules/_io/winconsoleio.c
+++ b/Modules/_io/winconsoleio.c
@@ -86,6 +86,19 @@ char _PyIO_get_console_type(PyObject *path_or_fd) {
return '\0';
}
+ char m = '\0';
+ if (!_wcsicmp(decoded_wstr, L"CONIN$")) {
+ m = 'r';
+ } else if (!_wcsicmp(decoded_wstr, L"CONOUT$")) {
+ m = 'w';
+ } else if (!_wcsicmp(decoded_wstr, L"CON")) {
+ m = 'x';
+ }
+ if (m) {
+ PyMem_Free(decoded_wstr);
+ return m;
+ }
+
DWORD length;
wchar_t name_buf[MAX_PATH], *pname_buf = name_buf;
@@ -99,7 +112,6 @@ char _PyIO_get_console_type(PyObject *path_or_fd) {
}
PyMem_Free(decoded_wstr);
- char m = '\0';
if (length) {
wchar_t *name = pname_buf;
if (length >= 4 && name[3] == L'\\' &&