Merged revisions 73603 via svnmerge from

svn+ssh://pythondev@svn.python.org/python/trunk

........
  r73603 | hirokazu.yamamoto | 2009-06-28 19:23:00 +0900 | 1 line

  Issue #4856: Remove checks for win NT.
........
This commit is contained in:
Hirokazu Yamamoto 2009-06-28 11:07:03 +00:00
parent 95c4601870
commit 892a37aff1
4 changed files with 254 additions and 320 deletions

View File

@ -12,6 +12,8 @@ What's New in Python 3.2 Alpha 1?
Core and Builtins
-----------------
- Issue #4856: Remove checks for win NT.
Library
-------

View File

@ -224,11 +224,8 @@ fileio_init(PyObject *oself, PyObject *args, PyObject *kwds)
}
#ifdef MS_WINDOWS
if (GetVersion() < 0x80000000) {
/* On NT, so wide API available */
if (PyUnicode_Check(nameobj))
widename = PyUnicode_AS_UNICODE(nameobj);
}
if (widename == NULL)
#endif
if (fd < 0)

View File

@ -759,20 +759,6 @@ posix_fildes(PyObject *fdobj, int (*func)(int))
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 *
posix_1str(PyObject *args, char *format, int (*func)(const char*))
{
@ -829,7 +815,7 @@ win32_1str(PyObject* args, char* func,
PyObject *uni;
char *ansi;
BOOL result;
if (unicode_file_names()) {
if (!PyArg_ParseTuple(args, wformat, &uni))
PyErr_Clear();
else {
@ -841,7 +827,6 @@ win32_1str(PyObject* args, char* func,
Py_INCREF(Py_None);
return Py_None;
}
}
if (!PyArg_ParseTuple(args, format, &ansi))
return NULL;
Py_BEGIN_ALLOW_THREADS
@ -1003,22 +988,6 @@ attribute_data_to_stat(WIN32_FILE_ATTRIBUTE_DATA *info, struct win32_stat *resul
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
attributes_from_dir(LPCSTR pszFile, LPWIN32_FILE_ATTRIBUTE_DATA pfad)
{
@ -1065,12 +1034,9 @@ Py_GetFileAttributesExA(LPCSTR pszFile,
/* First try to use the system's implementation, if that is
available and either succeeds to gives an error other than
that it isn't implemented. */
check_gfax();
if (gfaxa) {
result = gfaxa(pszFile, level, pv);
result = GetFileAttributesExA(pszFile, level, pv);
if (result || GetLastError() != ERROR_CALL_NOT_IMPLEMENTED)
return result;
}
/* It's either not present, or not implemented.
Emulate using FindFirstFile. */
if (level != GetFileExInfoStandard) {
@ -1095,12 +1061,9 @@ Py_GetFileAttributesExW(LPCWSTR pszFile,
/* First try to use the system's implementation, if that is
available and either succeeds to gives an error other than
that it isn't implemented. */
check_gfax();
if (gfaxa) {
result = gfaxw(pszFile, level, pv);
result = GetFileAttributesExW(pszFile, level, pv);
if (result || GetLastError() != ERROR_CALL_NOT_IMPLEMENTED)
return result;
}
/* It's either not present, or not implemented.
Emulate using FindFirstFile. */
if (level != GetFileExInfoStandard) {
@ -1618,9 +1581,6 @@ posix_do_stat(PyObject *self, PyObject *args,
PyObject *result;
#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;
if (PyArg_ParseTuple(args, wformat, &po)) {
Py_UNICODE *wpath = PyUnicode_AS_UNICODE(po);
@ -1638,7 +1598,6 @@ posix_do_stat(PyObject *self, PyObject *args,
/* Drop the argument parsing error as narrow strings
are also valid. */
PyErr_Clear();
}
#endif
if (!PyArg_ParseTuple(args, format,
@ -1682,7 +1641,6 @@ posix_access(PyObject *self, PyObject *args)
#ifdef MS_WINDOWS
DWORD attr;
if (unicode_file_names()) {
PyUnicodeObject *po;
if (PyArg_ParseTuple(args, "Ui:access", &po, &mode)) {
Py_BEGIN_ALLOW_THREADS
@ -1695,10 +1653,9 @@ posix_access(PyObject *self, PyObject *args)
/* Drop the argument parsing error as narrow strings
are also valid. */
PyErr_Clear();
}
if (!PyArg_ParseTuple(args, "O&i:access",
PyUnicode_FSConverter, &opath, &mode))
return 0;
return NULL;
path = bytes2str(opath, 1);
Py_BEGIN_ALLOW_THREADS
attr = GetFileAttributesA(path);
@ -1839,7 +1796,6 @@ posix_chmod(PyObject *self, PyObject *args)
int res;
#ifdef MS_WINDOWS
DWORD attr;
if (unicode_file_names()) {
PyUnicodeObject *po;
if (PyArg_ParseTuple(args, "Ui|:chmod", &po, &i)) {
Py_BEGIN_ALLOW_THREADS
@ -1863,7 +1819,7 @@ posix_chmod(PyObject *self, PyObject *args)
/* Drop the argument parsing error as narrow strings
are also valid. */
PyErr_Clear();
}
if (!PyArg_ParseTuple(args, "O&i:chmod", PyUnicode_FSConverter,
&opath, &i))
return NULL;
@ -2139,7 +2095,7 @@ posix_getcwd(int use_bytes)
char *res;
#ifdef MS_WINDOWS
if (!use_bytes && unicode_file_names()) {
if (!use_bytes) {
wchar_t wbuf[1026];
wchar_t *wbuf2 = wbuf;
PyObject *resobj;
@ -2243,9 +2199,6 @@ posix_listdir(PyObject *self, PyObject *args)
char *bufptr = namebuf;
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;
if (PyArg_ParseTuple(args, "U:listdir", &po)) {
WIN32_FIND_DATAW wFileData;
@ -2324,7 +2277,6 @@ posix_listdir(PyObject *self, PyObject *args)
/* Drop the argument parsing error as narrow strings
are also valid. */
PyErr_Clear();
}
if (!PyArg_ParseTuple(args, "O&:listdir",
PyUnicode_FSConverter, &opath))
@ -2562,7 +2514,6 @@ posix__getfullpathname(PyObject *self, PyObject *args)
char outbuf[MAX_PATH*2];
char *temp;
#ifdef MS_WINDOWS
if (unicode_file_names()) {
PyUnicodeObject *po;
if (PyArg_ParseTuple(args, "U|:_getfullpathname", &po)) {
Py_UNICODE *wpath = PyUnicode_AS_UNICODE(po);
@ -2590,7 +2541,7 @@ posix__getfullpathname(PyObject *self, PyObject *args)
/* Drop the argument parsing error as narrow strings
are also valid. */
PyErr_Clear();
}
#endif
if (!PyArg_ParseTuple (args, "O&:_getfullpathname",
PyUnicode_FSConverter, &opath))
@ -2624,7 +2575,6 @@ posix_mkdir(PyObject *self, PyObject *args)
int mode = 0777;
#ifdef MS_WINDOWS
if (unicode_file_names()) {
PyUnicodeObject *po;
if (PyArg_ParseTuple(args, "U|i:mkdir", &po, &mode)) {
Py_BEGIN_ALLOW_THREADS
@ -2640,7 +2590,6 @@ posix_mkdir(PyObject *self, PyObject *args)
/* Drop the argument parsing error as narrow strings
are also valid. */
PyErr_Clear();
}
if (!PyArg_ParseTuple(args, "O&|i:mkdir",
PyUnicode_FSConverter, &opath, &mode))
return NULL;
@ -2733,7 +2682,6 @@ posix_rename(PyObject *self, PyObject *args)
PyObject *o1, *o2;
char *p1, *p2;
BOOL result;
if (unicode_file_names()) {
if (!PyArg_ParseTuple(args, "OO:rename", &o1, &o2))
goto error;
if (!convert_to_unicode(&o1))
@ -2754,7 +2702,6 @@ posix_rename(PyObject *self, PyObject *args)
return Py_None;
error:
PyErr_Clear();
}
if (!PyArg_ParseTuple(args, "ss:rename", &p1, &p2))
return NULL;
Py_BEGIN_ALLOW_THREADS
@ -2940,7 +2887,6 @@ posix_utime(PyObject *self, PyObject *args)
FILETIME atime, mtime;
PyObject *result = NULL;
if (unicode_file_names()) {
if (PyArg_ParseTuple(args, "UO|:utime", &obwpath, &arg)) {
wpath = PyUnicode_AS_UNICODE(obwpath);
Py_BEGIN_ALLOW_THREADS
@ -2954,7 +2900,7 @@ posix_utime(PyObject *self, PyObject *args)
/* Drop the argument parsing error as narrow strings
are also valid. */
PyErr_Clear();
}
if (!wpath) {
if (!PyArg_ParseTuple(args, "O&O:utime",
PyUnicode_FSConverter, &oapath, &arg))
@ -4927,7 +4873,6 @@ posix_open(PyObject *self, PyObject *args)
int fd;
#ifdef MS_WINDOWS
if (unicode_file_names()) {
PyUnicodeObject *po;
if (PyArg_ParseTuple(args, "Ui|i:mkdir", &po, &flag, &mode)) {
Py_BEGIN_ALLOW_THREADS
@ -4942,7 +4887,6 @@ posix_open(PyObject *self, PyObject *args)
/* Drop the argument parsing error as narrow strings
are also valid. */
PyErr_Clear();
}
#endif
if (!PyArg_ParseTuple(args, "O&i|i",
@ -6816,7 +6760,6 @@ win32_startfile(PyObject *self, PyObject *args)
char *operation = NULL;
HINSTANCE rc;
if (unicode_file_names()) {
PyObject *unipath, *woperation = NULL;
if (!PyArg_ParseTuple(args, "U|s:startfile",
&unipath, &operation)) {
@ -6824,7 +6767,6 @@ win32_startfile(PyObject *self, PyObject *args)
goto normal;
}
if (operation) {
woperation = PyUnicode_DecodeASCII(operation,
strlen(operation), NULL);
@ -6849,7 +6791,6 @@ win32_startfile(PyObject *self, PyObject *args)
}
Py_INCREF(Py_None);
return Py_None;
}
normal:
if (!PyArg_ParseTuple(args, "O&|s:startfile",

View File

@ -95,12 +95,6 @@ WIN32 is still required for the locale module.
#endif
#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 */
#define getenv(v) (NULL)
#define environ (NULL)