Commit a3c56090 authored by Hirokazu Yamamoto's avatar Hirokazu Yamamoto

Issue #4856: Remove checks for win NT.

parent ecb4f953
...@@ -12,6 +12,8 @@ What's New in Python 2.7 alpha 1 ...@@ -12,6 +12,8 @@ What's New in Python 2.7 alpha 1
Core and Builtins Core and Builtins
----------------- -----------------
- Issue #4856: Remove checks for win NT.
- Issue #2016: Fixed a crash in a corner case where the dictionary of keyword - Issue #2016: Fixed a crash in a corner case where the dictionary of keyword
arguments could be modified during the function call setup. arguments could be modified during the function call setup.
......
...@@ -224,11 +224,8 @@ fileio_init(PyObject *oself, PyObject *args, PyObject *kwds) ...@@ -224,11 +224,8 @@ fileio_init(PyObject *oself, PyObject *args, PyObject *kwds)
} }
#ifdef MS_WINDOWS #ifdef MS_WINDOWS
if (GetVersion() < 0x80000000) {
/* On NT, so wide API available */
if (PyUnicode_Check(nameobj)) if (PyUnicode_Check(nameobj))
widename = PyUnicode_AS_UNICODE(nameobj); widename = PyUnicode_AS_UNICODE(nameobj);
}
if (widename == NULL) if (widename == NULL)
#endif #endif
if (fd < 0) if (fd < 0)
......
...@@ -700,20 +700,6 @@ posix_fildes(PyObject *fdobj, int (*func)(int)) ...@@ -700,20 +700,6 @@ posix_fildes(PyObject *fdobj, int (*func)(int))
return Py_None; return Py_None;
} }
#ifdef MS_WINDOWS
static int
unicode_file_names(void)
{
static int canusewide = -1;
if (canusewide == -1) {
/* As per doc for ::GetVersion(), this is the correct test for
the Windows NT family. */
canusewide = (GetVersion() < 0x80000000) ? 1 : 0;
}
return canusewide;
}
#endif
static PyObject * static PyObject *
posix_1str(PyObject *args, char *format, int (*func)(const char*)) posix_1str(PyObject *args, char *format, int (*func)(const char*))
{ {
...@@ -764,7 +750,7 @@ win32_1str(PyObject* args, char* func, ...@@ -764,7 +750,7 @@ win32_1str(PyObject* args, char* func,
PyObject *uni; PyObject *uni;
char *ansi; char *ansi;
BOOL result; BOOL result;
if (unicode_file_names()) {
if (!PyArg_ParseTuple(args, wformat, &uni)) if (!PyArg_ParseTuple(args, wformat, &uni))
PyErr_Clear(); PyErr_Clear();
else { else {
...@@ -776,7 +762,6 @@ win32_1str(PyObject* args, char* func, ...@@ -776,7 +762,6 @@ win32_1str(PyObject* args, char* func,
Py_INCREF(Py_None); Py_INCREF(Py_None);
return Py_None; return Py_None;
} }
}
if (!PyArg_ParseTuple(args, format, &ansi)) if (!PyArg_ParseTuple(args, format, &ansi))
return NULL; return NULL;
Py_BEGIN_ALLOW_THREADS Py_BEGIN_ALLOW_THREADS
...@@ -938,22 +923,6 @@ attribute_data_to_stat(WIN32_FILE_ATTRIBUTE_DATA *info, struct win32_stat *resul ...@@ -938,22 +923,6 @@ attribute_data_to_stat(WIN32_FILE_ATTRIBUTE_DATA *info, struct win32_stat *resul
return 0; return 0;
} }
/* Emulate GetFileAttributesEx[AW] on Windows 95 */
static int checked = 0;
static BOOL (CALLBACK *gfaxa)(LPCSTR, GET_FILEEX_INFO_LEVELS, LPVOID);
static BOOL (CALLBACK *gfaxw)(LPCWSTR, GET_FILEEX_INFO_LEVELS, LPVOID);
static void
check_gfax()
{
HINSTANCE hKernel32;
if (checked)
return;
checked = 1;
hKernel32 = GetModuleHandle("KERNEL32");
*(FARPROC*)&gfaxa = GetProcAddress(hKernel32, "GetFileAttributesExA");
*(FARPROC*)&gfaxw = GetProcAddress(hKernel32, "GetFileAttributesExW");
}
static BOOL static BOOL
attributes_from_dir(LPCSTR pszFile, LPWIN32_FILE_ATTRIBUTE_DATA pfad) attributes_from_dir(LPCSTR pszFile, LPWIN32_FILE_ATTRIBUTE_DATA pfad)
{ {
...@@ -1000,12 +969,9 @@ Py_GetFileAttributesExA(LPCSTR pszFile, ...@@ -1000,12 +969,9 @@ Py_GetFileAttributesExA(LPCSTR pszFile,
/* First try to use the system's implementation, if that is /* First try to use the system's implementation, if that is
available and either succeeds to gives an error other than available and either succeeds to gives an error other than
that it isn't implemented. */ that it isn't implemented. */
check_gfax(); result = GetFileAttributesExA(pszFile, level, pv);
if (gfaxa) {
result = gfaxa(pszFile, level, pv);
if (result || GetLastError() != ERROR_CALL_NOT_IMPLEMENTED) if (result || GetLastError() != ERROR_CALL_NOT_IMPLEMENTED)
return result; return result;
}
/* It's either not present, or not implemented. /* It's either not present, or not implemented.
Emulate using FindFirstFile. */ Emulate using FindFirstFile. */
if (level != GetFileExInfoStandard) { if (level != GetFileExInfoStandard) {
...@@ -1030,12 +996,9 @@ Py_GetFileAttributesExW(LPCWSTR pszFile, ...@@ -1030,12 +996,9 @@ Py_GetFileAttributesExW(LPCWSTR pszFile,
/* First try to use the system's implementation, if that is /* First try to use the system's implementation, if that is
available and either succeeds to gives an error other than available and either succeeds to gives an error other than
that it isn't implemented. */ that it isn't implemented. */
check_gfax(); result = GetFileAttributesExW(pszFile, level, pv);
if (gfaxa) {
result = gfaxw(pszFile, level, pv);
if (result || GetLastError() != ERROR_CALL_NOT_IMPLEMENTED) if (result || GetLastError() != ERROR_CALL_NOT_IMPLEMENTED)
return result; return result;
}
/* It's either not present, or not implemented. /* It's either not present, or not implemented.
Emulate using FindFirstFile. */ Emulate using FindFirstFile. */
if (level != GetFileExInfoStandard) { if (level != GetFileExInfoStandard) {
...@@ -1553,9 +1516,6 @@ posix_do_stat(PyObject *self, PyObject *args, ...@@ -1553,9 +1516,6 @@ posix_do_stat(PyObject *self, PyObject *args,
PyObject *result; PyObject *result;
#ifdef MS_WINDOWS #ifdef MS_WINDOWS
/* If on wide-character-capable OS see if argument
is Unicode and if so use wide API. */
if (unicode_file_names()) {
PyUnicodeObject *po; PyUnicodeObject *po;
if (PyArg_ParseTuple(args, wformat, &po)) { if (PyArg_ParseTuple(args, wformat, &po)) {
Py_UNICODE *wpath = PyUnicode_AS_UNICODE(po); Py_UNICODE *wpath = PyUnicode_AS_UNICODE(po);
...@@ -1573,7 +1533,6 @@ posix_do_stat(PyObject *self, PyObject *args, ...@@ -1573,7 +1533,6 @@ posix_do_stat(PyObject *self, PyObject *args,
/* Drop the argument parsing error as narrow strings /* Drop the argument parsing error as narrow strings
are also valid. */ are also valid. */
PyErr_Clear(); PyErr_Clear();
}
#endif #endif
if (!PyArg_ParseTuple(args, format, if (!PyArg_ParseTuple(args, format,
...@@ -1617,7 +1576,6 @@ posix_access(PyObject *self, PyObject *args) ...@@ -1617,7 +1576,6 @@ posix_access(PyObject *self, PyObject *args)
#ifdef MS_WINDOWS #ifdef MS_WINDOWS
DWORD attr; DWORD attr;
if (unicode_file_names()) {
PyUnicodeObject *po; PyUnicodeObject *po;
if (PyArg_ParseTuple(args, "Ui:access", &po, &mode)) { if (PyArg_ParseTuple(args, "Ui:access", &po, &mode)) {
Py_BEGIN_ALLOW_THREADS Py_BEGIN_ALLOW_THREADS
...@@ -1630,10 +1588,9 @@ posix_access(PyObject *self, PyObject *args) ...@@ -1630,10 +1588,9 @@ posix_access(PyObject *self, PyObject *args)
/* Drop the argument parsing error as narrow strings /* Drop the argument parsing error as narrow strings
are also valid. */ are also valid. */
PyErr_Clear(); PyErr_Clear();
}
if (!PyArg_ParseTuple(args, "eti:access", if (!PyArg_ParseTuple(args, "eti:access",
Py_FileSystemDefaultEncoding, &path, &mode)) Py_FileSystemDefaultEncoding, &path, &mode))
return 0; return NULL;
Py_BEGIN_ALLOW_THREADS Py_BEGIN_ALLOW_THREADS
attr = GetFileAttributesA(path); attr = GetFileAttributesA(path);
Py_END_ALLOW_THREADS Py_END_ALLOW_THREADS
...@@ -1771,7 +1728,6 @@ posix_chmod(PyObject *self, PyObject *args) ...@@ -1771,7 +1728,6 @@ posix_chmod(PyObject *self, PyObject *args)
int res; int res;
#ifdef MS_WINDOWS #ifdef MS_WINDOWS
DWORD attr; DWORD attr;
if (unicode_file_names()) {
PyUnicodeObject *po; PyUnicodeObject *po;
if (PyArg_ParseTuple(args, "Ui|:chmod", &po, &i)) { if (PyArg_ParseTuple(args, "Ui|:chmod", &po, &i)) {
Py_BEGIN_ALLOW_THREADS Py_BEGIN_ALLOW_THREADS
...@@ -1795,7 +1751,7 @@ posix_chmod(PyObject *self, PyObject *args) ...@@ -1795,7 +1751,7 @@ posix_chmod(PyObject *self, PyObject *args)
/* Drop the argument parsing error as narrow strings /* Drop the argument parsing error as narrow strings
are also valid. */ are also valid. */
PyErr_Clear(); PyErr_Clear();
}
if (!PyArg_ParseTuple(args, "eti:chmod", Py_FileSystemDefaultEncoding, if (!PyArg_ParseTuple(args, "eti:chmod", Py_FileSystemDefaultEncoding,
&path, &i)) &path, &i))
return NULL; return NULL;
...@@ -2106,7 +2062,6 @@ posix_getcwdu(PyObject *self, PyObject *noargs) ...@@ -2106,7 +2062,6 @@ posix_getcwdu(PyObject *self, PyObject *noargs)
#ifdef MS_WINDOWS #ifdef MS_WINDOWS
DWORD len; DWORD len;
if (unicode_file_names()) {
wchar_t wbuf[1026]; wchar_t wbuf[1026];
wchar_t *wbuf2 = wbuf; wchar_t *wbuf2 = wbuf;
PyObject *resobj; PyObject *resobj;
...@@ -2132,7 +2087,6 @@ posix_getcwdu(PyObject *self, PyObject *noargs) ...@@ -2132,7 +2087,6 @@ posix_getcwdu(PyObject *self, PyObject *noargs)
resobj = PyUnicode_FromWideChar(wbuf2, len); resobj = PyUnicode_FromWideChar(wbuf2, len);
if (wbuf2 != wbuf) free(wbuf2); if (wbuf2 != wbuf) free(wbuf2);
return resobj; return resobj;
}
#endif /* MS_WINDOWS */ #endif /* MS_WINDOWS */
Py_BEGIN_ALLOW_THREADS Py_BEGIN_ALLOW_THREADS
...@@ -2187,9 +2141,6 @@ posix_listdir(PyObject *self, PyObject *args) ...@@ -2187,9 +2141,6 @@ posix_listdir(PyObject *self, PyObject *args)
char *bufptr = namebuf; char *bufptr = namebuf;
Py_ssize_t len = sizeof(namebuf)-5; /* only claim to have space for MAX_PATH */ Py_ssize_t len = sizeof(namebuf)-5; /* only claim to have space for MAX_PATH */
/* If on wide-character-capable OS see if argument
is Unicode and if so use wide API. */
if (unicode_file_names()) {
PyObject *po; PyObject *po;
if (PyArg_ParseTuple(args, "U:listdir", &po)) { if (PyArg_ParseTuple(args, "U:listdir", &po)) {
WIN32_FIND_DATAW wFileData; WIN32_FIND_DATAW wFileData;
...@@ -2268,7 +2219,6 @@ posix_listdir(PyObject *self, PyObject *args) ...@@ -2268,7 +2219,6 @@ posix_listdir(PyObject *self, PyObject *args)
/* Drop the argument parsing error as narrow strings /* Drop the argument parsing error as narrow strings
are also valid. */ are also valid. */
PyErr_Clear(); PyErr_Clear();
}
if (!PyArg_ParseTuple(args, "et#:listdir", if (!PyArg_ParseTuple(args, "et#:listdir",
Py_FileSystemDefaultEncoding, &bufptr, &len)) Py_FileSystemDefaultEncoding, &bufptr, &len))
...@@ -2493,7 +2443,6 @@ posix__getfullpathname(PyObject *self, PyObject *args) ...@@ -2493,7 +2443,6 @@ posix__getfullpathname(PyObject *self, PyObject *args)
char outbuf[MAX_PATH*2]; char outbuf[MAX_PATH*2];
char *temp; char *temp;
if (unicode_file_names()) {
PyUnicodeObject *po; PyUnicodeObject *po;
if (PyArg_ParseTuple(args, "U|:_getfullpathname", &po)) { if (PyArg_ParseTuple(args, "U|:_getfullpathname", &po)) {
Py_UNICODE *wpath = PyUnicode_AS_UNICODE(po); Py_UNICODE *wpath = PyUnicode_AS_UNICODE(po);
...@@ -2521,7 +2470,6 @@ posix__getfullpathname(PyObject *self, PyObject *args) ...@@ -2521,7 +2470,6 @@ posix__getfullpathname(PyObject *self, PyObject *args)
/* Drop the argument parsing error as narrow strings /* Drop the argument parsing error as narrow strings
are also valid. */ are also valid. */
PyErr_Clear(); PyErr_Clear();
}
if (!PyArg_ParseTuple (args, "et#:_getfullpathname", if (!PyArg_ParseTuple (args, "et#:_getfullpathname",
Py_FileSystemDefaultEncoding, &inbufp, Py_FileSystemDefaultEncoding, &inbufp,
...@@ -2550,7 +2498,6 @@ posix_mkdir(PyObject *self, PyObject *args) ...@@ -2550,7 +2498,6 @@ posix_mkdir(PyObject *self, PyObject *args)
int mode = 0777; int mode = 0777;
#ifdef MS_WINDOWS #ifdef MS_WINDOWS
if (unicode_file_names()) {
PyUnicodeObject *po; PyUnicodeObject *po;
if (PyArg_ParseTuple(args, "U|i:mkdir", &po, &mode)) { if (PyArg_ParseTuple(args, "U|i:mkdir", &po, &mode)) {
Py_BEGIN_ALLOW_THREADS Py_BEGIN_ALLOW_THREADS
...@@ -2566,7 +2513,6 @@ posix_mkdir(PyObject *self, PyObject *args) ...@@ -2566,7 +2513,6 @@ posix_mkdir(PyObject *self, PyObject *args)
/* Drop the argument parsing error as narrow strings /* Drop the argument parsing error as narrow strings
are also valid. */ are also valid. */
PyErr_Clear(); PyErr_Clear();
}
if (!PyArg_ParseTuple(args, "et|i:mkdir", if (!PyArg_ParseTuple(args, "et|i:mkdir",
Py_FileSystemDefaultEncoding, &path, &mode)) Py_FileSystemDefaultEncoding, &path, &mode))
return NULL; return NULL;
...@@ -2657,7 +2603,6 @@ posix_rename(PyObject *self, PyObject *args) ...@@ -2657,7 +2603,6 @@ posix_rename(PyObject *self, PyObject *args)
PyObject *o1, *o2; PyObject *o1, *o2;
char *p1, *p2; char *p1, *p2;
BOOL result; BOOL result;
if (unicode_file_names()) {
if (!PyArg_ParseTuple(args, "OO:rename", &o1, &o2)) if (!PyArg_ParseTuple(args, "OO:rename", &o1, &o2))
goto error; goto error;
if (!convert_to_unicode(&o1)) if (!convert_to_unicode(&o1))
...@@ -2678,7 +2623,6 @@ posix_rename(PyObject *self, PyObject *args) ...@@ -2678,7 +2623,6 @@ posix_rename(PyObject *self, PyObject *args)
return Py_None; return Py_None;
error: error:
PyErr_Clear(); PyErr_Clear();
}
if (!PyArg_ParseTuple(args, "ss:rename", &p1, &p2)) if (!PyArg_ParseTuple(args, "ss:rename", &p1, &p2))
return NULL; return NULL;
Py_BEGIN_ALLOW_THREADS Py_BEGIN_ALLOW_THREADS
...@@ -2853,7 +2797,6 @@ posix_utime(PyObject *self, PyObject *args) ...@@ -2853,7 +2797,6 @@ posix_utime(PyObject *self, PyObject *args)
FILETIME atime, mtime; FILETIME atime, mtime;
PyObject *result = NULL; PyObject *result = NULL;
if (unicode_file_names()) {
if (PyArg_ParseTuple(args, "UO|:utime", &obwpath, &arg)) { if (PyArg_ParseTuple(args, "UO|:utime", &obwpath, &arg)) {
wpath = PyUnicode_AS_UNICODE(obwpath); wpath = PyUnicode_AS_UNICODE(obwpath);
Py_BEGIN_ALLOW_THREADS Py_BEGIN_ALLOW_THREADS
...@@ -2867,7 +2810,7 @@ posix_utime(PyObject *self, PyObject *args) ...@@ -2867,7 +2810,7 @@ posix_utime(PyObject *self, PyObject *args)
/* Drop the argument parsing error as narrow strings /* Drop the argument parsing error as narrow strings
are also valid. */ are also valid. */
PyErr_Clear(); PyErr_Clear();
}
if (!wpath) { if (!wpath) {
if (!PyArg_ParseTuple(args, "etO:utime", if (!PyArg_ParseTuple(args, "etO:utime",
Py_FileSystemDefaultEncoding, &apath, &arg)) Py_FileSystemDefaultEncoding, &apath, &arg))
...@@ -6296,7 +6239,6 @@ posix_open(PyObject *self, PyObject *args) ...@@ -6296,7 +6239,6 @@ posix_open(PyObject *self, PyObject *args)
int fd; int fd;
#ifdef MS_WINDOWS #ifdef MS_WINDOWS
if (unicode_file_names()) {
PyUnicodeObject *po; PyUnicodeObject *po;
if (PyArg_ParseTuple(args, "Ui|i:mkdir", &po, &flag, &mode)) { if (PyArg_ParseTuple(args, "Ui|i:mkdir", &po, &flag, &mode)) {
Py_BEGIN_ALLOW_THREADS Py_BEGIN_ALLOW_THREADS
...@@ -6311,7 +6253,6 @@ posix_open(PyObject *self, PyObject *args) ...@@ -6311,7 +6253,6 @@ posix_open(PyObject *self, PyObject *args)
/* Drop the argument parsing error as narrow strings /* Drop the argument parsing error as narrow strings
are also valid. */ are also valid. */
PyErr_Clear(); PyErr_Clear();
}
#endif #endif
if (!PyArg_ParseTuple(args, "eti|i", if (!PyArg_ParseTuple(args, "eti|i",
...@@ -8290,7 +8231,6 @@ win32_startfile(PyObject *self, PyObject *args) ...@@ -8290,7 +8231,6 @@ win32_startfile(PyObject *self, PyObject *args)
char *operation = NULL; char *operation = NULL;
HINSTANCE rc; HINSTANCE rc;
if (unicode_file_names()) {
PyObject *unipath, *woperation = NULL; PyObject *unipath, *woperation = NULL;
if (!PyArg_ParseTuple(args, "U|s:startfile", if (!PyArg_ParseTuple(args, "U|s:startfile",
&unipath, &operation)) { &unipath, &operation)) {
...@@ -8298,7 +8238,6 @@ win32_startfile(PyObject *self, PyObject *args) ...@@ -8298,7 +8238,6 @@ win32_startfile(PyObject *self, PyObject *args)
goto normal; goto normal;
} }
if (operation) { if (operation) {
woperation = PyUnicode_DecodeASCII(operation, woperation = PyUnicode_DecodeASCII(operation,
strlen(operation), NULL); strlen(operation), NULL);
...@@ -8323,7 +8262,6 @@ win32_startfile(PyObject *self, PyObject *args) ...@@ -8323,7 +8262,6 @@ win32_startfile(PyObject *self, PyObject *args)
} }
Py_INCREF(Py_None); Py_INCREF(Py_None);
return Py_None; return Py_None;
}
normal: normal:
if (!PyArg_ParseTuple(args, "et|s:startfile", if (!PyArg_ParseTuple(args, "et|s:startfile",
......
...@@ -16,12 +16,6 @@ ...@@ -16,12 +16,6 @@
#include <windows.h> #include <windows.h>
#endif #endif
#ifdef _MSC_VER
/* Need GetVersion to see if on NT so safe to use _wfopen */
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#endif /* _MSC_VER */
#if defined(PYOS_OS2) && defined(PYCC_GCC) #if defined(PYOS_OS2) && defined(PYCC_GCC)
#include <io.h> #include <io.h>
#endif #endif
...@@ -2244,6 +2238,7 @@ file_init(PyObject *self, PyObject *args, PyObject *kwds) ...@@ -2244,6 +2238,7 @@ file_init(PyObject *self, PyObject *args, PyObject *kwds)
char *mode = "r"; char *mode = "r";
int bufsize = -1; int bufsize = -1;
int wideargument = 0; int wideargument = 0;
PyObject *po;
assert(PyFile_Check(self)); assert(PyFile_Check(self));
if (foself->f_fp != NULL) { if (foself->f_fp != NULL) {
...@@ -2255,8 +2250,6 @@ file_init(PyObject *self, PyObject *args, PyObject *kwds) ...@@ -2255,8 +2250,6 @@ file_init(PyObject *self, PyObject *args, PyObject *kwds)
} }
#ifdef MS_WINDOWS #ifdef MS_WINDOWS
if (GetVersion() < 0x80000000) { /* On NT, so wide API available */
PyObject *po;
if (PyArg_ParseTupleAndKeywords(args, kwds, "U|si:file", if (PyArg_ParseTupleAndKeywords(args, kwds, "U|si:file",
kwlist, &po, &mode, &bufsize)) { kwlist, &po, &mode, &bufsize)) {
wideargument = 1; wideargument = 1;
...@@ -2268,7 +2261,6 @@ file_init(PyObject *self, PyObject *args, PyObject *kwds) ...@@ -2268,7 +2261,6 @@ file_init(PyObject *self, PyObject *args, PyObject *kwds)
strings are also valid. */ strings are also valid. */
PyErr_Clear(); PyErr_Clear();
} }
}
#endif #endif
if (!wideargument) { if (!wideargument) {
......
...@@ -95,12 +95,6 @@ WIN32 is still required for the locale module. ...@@ -95,12 +95,6 @@ WIN32 is still required for the locale module.
#endif #endif
#ifdef MS_WINCE #ifdef MS_WINCE
/* Python uses GetVersion() to distinguish between
* Windows NT and 9x/ME where OS Unicode support is concerned.
* Windows CE supports Unicode in the same way as NT so we
* define the missing GetVersion() accordingly.
*/
#define GetVersion() (4)
/* Windows CE does not support environment variables */ /* Windows CE does not support environment variables */
#define getenv(v) (NULL) #define getenv(v) (NULL)
#define environ (NULL) #define environ (NULL)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment