New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
On windows, "import nul" always succeed #47349
Comments
on Windows, the stat() function always returns True for some special Thus "import con" manages to find that "con.py" exists, and tries to A solution is to use GetFileAttributes() instead. Note that on python2.5.2, the error message suggest that we have such a
problem, but fortunately the error is still an ImportError::
>>> import nul
ImportError: DLL load failed: Le module spécifié est introuvable. |
The title is misleading -- if what you show is correct then "import nul" |
Sorry, I was not clear. With a recent release25-maint (and all other branches), "import nul" Python 2.5.3a0 (release25-maint, Jun 11 2008, 13:17:36) [MSC v.1200 32
bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import con
^Z
a=1
b=2
c=3
^Z
│≥
c ☺ @ s► d Z d☺ Z☺ d☻ S(♥ i☻ i♥ N(☻ t☺ bt☺
c( ( ( s♠ con.py <module>☺ s☻ ♠☺ [27520 refs]
>>> dir(con)
['__builtins__', '__doc__', '__file__', '__name__', 'b', 'c']
[27533 refs] |
I was wrong. It seems that an installed python works correctly, but a |
OK, I think I got is now. The difference is between debug and release Explanation:
Whaaaa. |
GetFileAttributes() succeeds for "nul", but GetFileAttributesEx() fails. # 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
wfad = WIN32_FILE_ATTRIBUTE_DATA() print dll.GetFileAttributesExA("nul", GetFileExInfoStandard, |
Since I don't have access to Windows I am unassigning. Amaury, if this |
It's a problem with debug builds on Windows. Also, it is likely that the new import library will correct the problem. |
Did it? With standard 3.1.2,
>>> import nul
...
ImportError: DLL load failed: The specified module could not be found.
>>> import con
...
ImportError: No module named con So is there any problem with 2.7, or should we close this? |
3.1 does not use importlib for imports. |
I am not sure that I fully understand the issue - but it seems that trunk still has this issue. c:\>pcbuild\python_d.exe
Python 3.3a0 (default, May 28 2011, 20:22:11) [MSC v.1500 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import nul
[60967 refs]
>>> import con
^Z
[60986 refs]
c:\>PCbuild\python.exe
Python 3.3a0 (default, May 28 2011, 20:25:13) [MSC v.1500 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import nul
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: DLL load failed: The parameter is incorrect.
>>> import con
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: DLL load failed: The specified module could not be found.
>>> |
This one seems to have been fixed by the importlib rebuild. I haven't bothered to trace the code path, but certainly "import nul" returns the expected "ImportError: No module named 'nul'" in both Debug & Release builds. |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: