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: Windows - accessing drive with nothing mounted forces user interaction
Type: behavior Stage:
Components: Library (Lib) Versions: Python 3.3, Python 3.4, Python 2.7
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: amaury.forgeotdarc, bobjalex, terry.reedy
Priority: normal Keywords:

Created on 2013-03-26 17:26 by bobjalex, last changed 2022-04-11 14:57 by admin.

Messages (5)
msg185281 - (view) Author: Bob Alexander (bobjalex) * Date: 2013-03-26 17:26
Attempting to use os.path.exists on a Windows drive that is a mobile device mount point with nothing mounted pops up a dialog asking to insert a device. This makes it impossible to search a set of drives for a specific file without the possibility of unnecessary user interaction -- for example looking for the drive that has a specific flash drive inserted.

This behavior is likely related to bug 9035 regarding "os.path.ismount" behavior on Windows.

The more correct behavior (IMO) would be to quietly return exists=False for drives with nothing mounted. In fact, I tried the same operation with Java and Ruby programs, and both simply return false with no popup.
msg185331 - (view) Author: Amaury Forgeot d'Arc (amaury.forgeotdarc) * (Python committer) Date: 2013-03-27 13:40
Does it change something if you insert in your script (in 3.3):
    import msvcrt
    msvcrt.SetErrorMode(msvcrt.SEM_FAILCRITICALERRORS)
msg185347 - (view) Author: Bob Alexander (bobjalex) * Date: 2013-03-27 16:18
Thanks for the prompt reply!

Your suggested change does change the behavior to exactly the way I think
it should work by default. Tried it on both Windows 7 and Vista; no popups
when accessing a "mobile mount" drive with nothing in it, just quietly
reports False.

I vote for making this the normal behavior of these "file exists" sort of
operations.

Hmm, I notice that msvcrt.SetErrorMode is not discussed in the current
Python 3 Standard Library docs...  :-)

Bob

On Wed, Mar 27, 2013 at 6:40 AM, Amaury Forgeot d'Arc <
report@bugs.python.org> wrote:

>
> Amaury Forgeot d'Arc added the comment:
>
> Does it change something if you insert in your script (in 3.3):
>     import msvcrt
>     msvcrt.SetErrorMode(msvcrt.SEM_FAILCRITICALERRORS)
>
> ----------
> nosy: +amaury.forgeotdarc
>
> _______________________________________
> Python tracker <report@bugs.python.org>
> <http://bugs.python.org/issue17551>
> _______________________________________
>
msg185546 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2013-03-30 05:42
Bob, when replying by email, please snip everything except your reply, and perhaps a specific small quote.

Since the doc says exists returns True or False, raising a popup seems like a bug to be fixed.
msg185577 - (view) Author: Bob Alexander (bobjalex) * Date: 2013-03-30 17:12
Thanks Terry. I agree that it's a bug.

And, in the future I'll be more careful about trimming the "history" from
my messages  :-)

Bob
History
Date User Action Args
2022-04-11 14:57:43adminsetgithub: 61751
2013-03-30 17:12:42bobjalexsetmessages: + msg185577
2013-03-30 05:42:36terry.reedysetnosy: + terry.reedy

messages: + msg185546
versions: + Python 3.4
2013-03-27 16:18:51bobjalexsetmessages: + msg185347
2013-03-27 13:40:18amaury.forgeotdarcsetnosy: + amaury.forgeotdarc
messages: + msg185331
2013-03-26 17:26:44bobjalexcreate