[issue3099] On windows, "import nul" always succeed

Hirokazu Yamamoto report at bugs.python.org
Tue Jul 1 09:55:09 CEST 2008

Hirokazu Yamamoto <ocean-city at users.sourceforge.net> added the comment:

GetFileAttributes() succeeds for "nul", but GetFileAttributesEx() fails.
Maybe is it good idea to use GetFileAttributesEx()?

# test code

import ctypes
import ctypes.wintypes as type

dll = ctypes.windll.kernel32

print dll.GetFileAttributesA("nul") # 32

class WIN32_FILE_ATTRIBUTE_DATA(ctypes.Structure):
	_fields_ = [("dwFileAttributes", type.DWORD),
	            ("ftCreationTime", type.FILETIME),
	            ("ftLastAccessTime", type.FILETIME),
	            ("ftLastWriteTime", type.FILETIME),
	            ("nFileSizeHigh", type.DWORD),
	            ("nFileSizeLow", type.DWORD)]

GetFileExInfoStandard = 0


print dll.GetFileAttributesExA("nul", GetFileExInfoStandard,
ctypes.byref(wfad)) # 0

Python tracker <report at bugs.python.org>

More information about the Python-bugs-list mailing list