[issue1311] os.path.exists(os.devnull) regression on windows
Kevin Dwyer
report at bugs.python.org
Tue Oct 23 22:56:48 CEST 2007
Kevin Dwyer added the comment:
Ok, it seems that Python 2.5 implements two new functions
Py_GetFileAttributesExA and Py_GetFileAttributesExW in posixmodule.c
within the #ifdef MS_WINDOWS block that may return
ERROR_INVALID_PARAMETER to os.stat, which will percolate WindowsError up
to os.exists():
In both functions we find:
static BOOL WINAPI
Py_GetFileAttributesExA(LPCSTR pszFile,
GET_FILEEX_INFO_LEVELS level,
LPVOID pv)
{
BOOL result;
LPWIN32_FILE_ATTRIBUTE_DATA pfad = pv;
/* 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);
if (result || GetLastError() != ERROR_CALL_NOT_IMPLEMENTED)
return result;
}
/* It's either not present, or not implemented.
Emulate using FindFirstFile. */
if (level != GetFileExInfoStandard) {
SetLastError(ERROR_INVALID_PARAMETER);
return FALSE;
...
static BOOL WINAPI
Py_GetFileAttributesExW(LPCWSTR pszFile,
GET_FILEEX_INFO_LEVELS level,
LPVOID pv)
{
BOOL result;
LPWIN32_FILE_ATTRIBUTE_DATA pfad = pv;
/* 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);
if (result || GetLastError() != ERROR_CALL_NOT_IMPLEMENTED)
return result;
}
/* It's either not present, or not implemented.
Emulate using FindFirstFile. */
if (level != GetFileExInfoStandard) {
SetLastError(ERROR_INVALID_PARAMETER);
return FALSE;
...
I'm neither a C nor a win32api programmer - can anyone explain the
purpose of this code?
__________________________________
Tracker <report at bugs.python.org>
<http://bugs.python.org/issue1311>
__________________________________
More information about the Python-bugs-list
mailing list