
This issue trackerhas been migrated toGitHub, and is currentlyread-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.
Created on2019-01-09 03:00 byJordan Hueckstaedt, last changed2022-04-11 14:59 byadmin. This issue is nowclosed.
| Pull Requests | |||
|---|---|---|---|
| URL | Status | Linked | Edit |
| PR 11746 | merged | steve.dower,2019-02-03 00:25 | |
| PR 11746 | merged | steve.dower,2019-02-03 00:25 | |
| PR 11746 | merged | steve.dower,2019-02-03 00:25 | |
| PR 11752 | merged | miss-islington,2019-02-04 07:08 | |
| PR 11752 | merged | miss-islington,2019-02-04 07:08 | |
| PR 11752 | merged | miss-islington,2019-02-04 07:08 | |
| Messages (6) | |||
|---|---|---|---|
| msg333275 -(view) | Author: Jordan Hueckstaedt (Jordan Hueckstaedt) | Date: 2019-01-09 03:00 | |
Tested in 3.7.0 on windows 10.This looks related tohttps://bugs.python.org/issue22759>>> import pathlib>>> pathlib.Path(r"E:\Whatever\blah.txt").exists() # This drive doesn't existTraceback (most recent call last): File "<stdin>", line 1, in <module> File "C:\Users\jordanhu\AppData\Local\Continuum\anaconda2\envs\py3\lib\pathlib.py", line 1318, in exists self.stat() File "C:\Users\jordanhu\AppData\Local\Continuum\anaconda2\envs\py3\lib\pathlib.py", line 1140, in stat return self._accessor.stat(self)PermissionError: [WinError 21] The device is not ready: 'E:\\Whatever\\blah.txt'>>> pathlib.Path(r"C:\Whatever\blah.txt").exists() # This drive existsFalse | |||
| msg333724 -(view) | Author: Steve Dower (steve.dower)*![]() | Date: 2019-01-15 18:25 | |
Inissue 22759 there was some logic applied for which errors to forward rather than hide.I'm inclined to agree that this one should be hidden, but it may have to be done by checking the winerror field rather than the exception type, since other PermissionErrors may mean the file is guaranteed to exist (but you can't touch it) or that the path exists up to the point where you are not allowed to see.I'd happily argue that since these permissions indicate that the file does not exist *for the current user* and so they should be swallowed more broadly, but I'll let Antoine make the call. | |||
| msg333729 -(view) | Author: Antoine Pitrou (pitrou)*![]() | Date: 2019-01-15 18:52 | |
I think exists() should simply return False here. There's no reason a non-existing drive should fail differently than a non-existing parent directory. | |||
| msg333748 -(view) | Author: Eryk Sun (eryksun)*![]() | Date: 2019-01-16 01:36 | |
> There's no reason a non-existing drive should fail differently than > a non-existing parent directory.The drive exists (or should) if we're getting ERROR_NOT_READY (21). It's likely a removable media device, such as an optical disc or card reader, and there's no media in the device. If a logical drive isn't defined at all, we should get ERROR_PATH_NOT_FOUND (from the NT status value STATUS_OBJECT_PATH_NOT_FOUND). This gets mapped to the errno value ENOENT, which is already handled. For example: >>> os.stat('Q:/') Traceback (most recent call last): File "<stdin>", line 1, in <module> FileNotFoundError: [WinError 3] The system cannot find the path specified: 'Q:/' >>> pathlib.Path('Q:/whatever/blah.txt').exists() FalseSimilarly if a UNC 'drive' doesn't exist, we should get ERROR_BAD_NET_NAME (from NT STATUS_BAD_NETWORK_NAME), which is also mapped to ENOENT: >>> os.stat('//some/where') Traceback (most recent call last): File "<stdin>", line 1, in <module> FileNotFoundError: [WinError 67] The network name cannot be found: '//some/where' >>> pathlib.Path('//some/where/whatever/blah.txt').exists() False | |||
| msg334811 -(view) | Author: Steve Dower (steve.dower)*![]() | Date: 2019-02-04 07:08 | |
New changeset2f6fae6e510dba653391cb510a2aca8322eec03b by Steve Dower in branch 'master':bpo-35692: pathlib no longer raises when checking file and directory existence on drives that are not ready (GH-11746)https://github.com/python/cpython/commit/2f6fae6e510dba653391cb510a2aca8322eec03b | |||
| msg334814 -(view) | Author: miss-islington (miss-islington) | Date: 2019-02-04 07:27 | |
New changeset69af4395a25481e9de4009c816b6d1f032a2d8eb by Miss Islington (bot) in branch '3.7':bpo-35692: pathlib no longer raises when checking file and directory existence on drives that are not ready (GH-11746)https://github.com/python/cpython/commit/69af4395a25481e9de4009c816b6d1f032a2d8eb | |||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2022-04-11 14:59:10 | admin | set | github: 79873 |
| 2019-02-04 07:33:25 | steve.dower | set | keywords:patch,patch,patch status: open -> closed resolution: fixed stage: patch review -> resolved |
| 2019-02-04 07:27:39 | miss-islington | set | nosy: +miss-islington messages: +msg334814 |
| 2019-02-04 07:09:14 | miss-islington | set | pull_requests: +pull_request11688 |
| 2019-02-04 07:09:01 | miss-islington | set | pull_requests: +pull_request11687 |
| 2019-02-04 07:08:47 | miss-islington | set | pull_requests: +pull_request11686 |
| 2019-02-04 07:08:22 | steve.dower | set | messages: +msg334811 |
| 2019-02-03 00:26:12 | steve.dower | set | keywords:patch,patch,patch assignee:steve.dower |
| 2019-02-03 00:25:58 | steve.dower | set | keywords: +patch stage: needs patch -> patch review pull_requests: +pull_request11674 |
| 2019-02-03 00:25:44 | steve.dower | set | keywords: +patch stage: needs patch -> needs patch pull_requests: +pull_request11673 |
| 2019-02-03 00:25:31 | steve.dower | set | keywords: +patch stage: needs patch -> needs patch pull_requests: +pull_request11672 |
| 2019-01-16 01:36:13 | eryksun | set | messages: +msg333748 |
| 2019-01-15 18:52:55 | pitrou | set | stage: needs patch messages: +msg333729 versions: + Python 3.8 |
| 2019-01-15 18:25:27 | steve.dower | set | nosy: +pitrou messages: +msg333724 |
| 2019-01-09 19:17:24 | brett.cannon | set | nosy: +paul.moore,tim.golden,zach.ware,steve.dower components: + Library (Lib), Windows |
| 2019-01-09 03:18:26 | xtreak | set | nosy: +eryksun |
| 2019-01-09 03:00:15 | Jordan Hueckstaedt | create | |