This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: os.stat fails on mapped network drive
Type: behavior Stage: resolved
Components: Extension Modules Versions: Python 3.2, Python 3.3, Python 3.4
process
Status: closed Resolution: out of date
Dependencies: Superseder:
Assigned To: Nosy List: brian.curtin, loewis, ocean-city, pitrou, tim.golden
Priority: normal Keywords: patch

Created on 2010-10-23 14:52 by pitrou, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
osstat.patch pitrou, 2010-10-23 16:08 review
Messages (11)
msg119430 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2010-10-23 14:52
This network drive is actually mapped through the VirtualBox guest additions. Under Python 2.7 (official 64-bit MSI installer), this works fine:

>>> s = 'Z:\\__svn__\\Lib\\test\\keycert.pem'
>>> os.stat(s)
nt.stat_result(st_mode=33206, st_ino=0L, st_dev=0, st_nlink=0, st_uid=0, st_gid=0, st_size=1783L, st_atime=1287771307L, st_mtime=1286578916L, st_ctime=1286578916L)

Under a freshly compiled 32-bit py3k, though, it fails with a rather strange error message:

>>> s = 'Z:\\__svn__\\Lib\\test\\keycert.pem'
>>> os.stat(s)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
WindowsError: [Error 1] Incorrect function: 'Z:\\__svn__\\Lib\\test\\keycert.pem'
>>> errno.errorcode[1]
'EPERM'

While a local directory works fine:

>>> os.stat('c:\\Windows')
nt.stat_result(st_mode=16895, st_ino=0, st_dev=0, st_nlink=0, st_uid=0, st_gid=0, st_size=16384, st_atime=1287843075, st_mtime=1287843075, st_ctime=1247541608)
msg119431 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2010-10-23 14:59
And 3.1 works fine.
msg119432 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2010-10-23 15:09
Hmm, it looks like this is actually VirtualBox-specific.
It works with another network drive mapped on Y:

>>> os.stat(r"y:")
nt.stat_result(st_mode=16895, st_ino=0, st_dev=0, st_nlink=0, st_uid=0, st_gid=0, st_size=0, st_atime=1287784175, st_mtime=1281439296, st_ctime=1281439296)
>>> os.stat(r"z:")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
WindowsError: [Error 1] Incorrect function: 'z:'
msg119437 - (view) Author: Martin v. Löwis (loewis) * (Python committer) Date: 2010-10-23 15:56
Let me guess: It's GetFinalPathNameByHandle that is failing. Put some debug output right after the call to verify.

Why is this critical? Not being able to stat VirtualBox folders doesn't sound that critical to me.
msg119438 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2010-10-23 15:57
Yes, indeed. It was critical before I found out that it's VirtualBox-specific.
msg119439 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2010-10-23 16:08
This patch seems to do the trick, although I'm not sure it warrants including in Python.
msg119455 - (view) Author: Martin v. Löwis (loewis) * (Python committer) Date: 2010-10-23 17:38
I think something like this is worth adding. I'd like to see two changes implemented:
- GetLastError should be checked for the "not implemented or some such" error that you got, and the fallback only performed if its this error
- a comment explaining the motivation for this fallback should be added.
msg119458 - (view) Author: Hirokazu Yamamoto (ocean-city) * (Python committer) Date: 2010-10-23 18:07
Can you try my patch in #10027? Does this also fail?
msg119461 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2010-10-23 18:22
> Can you try my patch in #10027? Does this also fail?

No, your patch seems to fix the issue.
msg201109 - (view) Author: Tim Golden (tim.golden) * (Python committer) Date: 2013-10-24 10:04
Just housekeeping some Windows calls: Antoine, your last comment suggests that this is no longer an issue. I don't have a VirtualBox install to test, so can you confirm whether this can be closed?
msg201110 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2013-10-24 10:23
I don't know, I have stopped using VirtualBox here. Suggest closing.
History
Date User Action Args
2022-04-11 14:57:07adminsetgithub: 54388
2013-10-24 10:24:37tim.goldensetstatus: open -> closed
2013-10-24 10:24:13tim.goldensetresolution: out of date
stage: resolved
2013-10-24 10:23:09pitrousetmessages: + msg201110
2013-10-24 10:04:02tim.goldensetmessages: + msg201109
2013-07-05 23:01:28christian.heimessetversions: + Python 3.3, Python 3.4
2010-10-23 18:22:52pitrousetmessages: + msg119461
2010-10-23 18:07:31ocean-citysetmessages: + msg119458
2010-10-23 17:38:05loewissetmessages: + msg119455
2010-10-23 16:08:55pitrousetfiles: + osstat.patch
keywords: + patch
messages: + msg119439
2010-10-23 15:57:58pitrousetpriority: critical -> normal

messages: + msg119438
2010-10-23 15:56:16loewissetnosy: + loewis
messages: + msg119437
2010-10-23 15:09:57pitrousetmessages: + msg119432
2010-10-23 14:59:30pitrousetmessages: + msg119431
2010-10-23 14:52:03pitroucreate