Created on 2019-09-04 20:26 by eryksun, last changed 2022-04-11 14:59 by admin. This issue is now closed.
| Pull Requests | |||
|---|---|---|---|
| URL | Status | Linked | Edit |
| PR 15681 | closed | steve.dower, 2019-09-04 21:10 | |
| PR 15682 | merged | miss-islington, 2019-09-04 21:43 | |
| Messages (3) | |||
|---|---|---|---|
| msg351149 - (view) | Author: Eryk Sun (eryksun) * | Date: 2019-09-04 20:26 | |
In issue 37834, I posted a suggest implementation of win32_xstat_impl that included the following snippet of code: if (!GetFileInformationByHandle(hFile, &fileInfo)) { error = GetLastError(); if (error != ERROR_INVALID_PARAMETER && error != ERROR_INVALID_FUNCTION && error != ERROR_NOT_SUPPORTED) { retval = -1; goto cleanup; } /* Volumes and physical disks are block devices, e.g. \\.\C: and \\.\PhysicalDrive0. */ memset(result, 0, sizeof(*result)); result->st_mode = 0x6000; /* S_IFBLK */ goto cleanup; } This is meant to handle the above errors. We know we have FILE_TYPE_DISK. If GetFileInformationByHandle fails with one of the above error codes, then we must have a disk or volume device without a mounted file-system device. This should be reported as a block device. However it was changed in the final version as follows: if (!GetFileInformationByHandle(hFile, &fileInfo)) { switch (GetLastError()) { case ERROR_INVALID_PARAMETER: case ERROR_INVALID_FUNCTION: case ERROR_NOT_SUPPORTED: retval = -1; goto cleanup; } /* Volumes and physical disks are block devices, e.g. \\.\C: and \\.\PhysicalDrive0. */ memset(result, 0, sizeof(*result)); result->st_mode = 0x6000; /* S_IFBLK */ goto cleanup; } Now it's failing on the errors that should be handled, and succeeding on all other errors that should fail. If we want to use a switch statement here, I suggest the following: if (!GetFileInformationByHandle(hFile, &fileInfo)) { switch (GetLastError()) { case ERROR_INVALID_PARAMETER: case ERROR_INVALID_FUNCTION: case ERROR_NOT_SUPPORTED: /* Volumes and physical disks are block devices, e.g. \\.\C: and \\.\PhysicalDrive0. */ memset(result, 0, sizeof(*result)); result->st_mode = 0x6000; /* S_IFBLK */ goto cleanup; } retval = -1; goto cleanup; } |
|||
| msg351151 - (view) | Author: Steve Dower (steve.dower) * | Date: 2019-09-04 21:43 | |
New changeset 772ec0fad57412daa53d16d7019b6b2fe6e94942 by Steve Dower in branch 'master': bpo-38030: Fix os.stat failures on block devices on Windows (GH-15681) https://github.com/python/cpython/commit/772ec0fad57412daa53d16d7019b6b2fe6e94942 |
|||
| msg351152 - (view) | Author: miss-islington (miss-islington) | Date: 2019-09-04 22:18 | |
New changeset cad7abf8abe657b696b9c8deb4b727e0cefaf36d by Miss Islington (bot) in branch '3.8': bpo-38030: Fix os.stat failures on block devices on Windows (GH-15681) https://github.com/python/cpython/commit/cad7abf8abe657b696b9c8deb4b727e0cefaf36d |
|||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2022-04-11 14:59:19 | admin | set | github: 82211 |
| 2019-09-04 22:18:27 | steve.dower | set | status: open -> closed resolution: fixed stage: patch review -> resolved |
| 2019-09-04 22:18:08 | miss-islington | set | nosy:
+ miss-islington messages: + msg351152 |
| 2019-09-04 21:43:18 | miss-islington | set | pull_requests: + pull_request15342 |
| 2019-09-04 21:43:03 | steve.dower | set | messages: + msg351151 |
| 2019-09-04 21:10:12 | steve.dower | set | keywords:
+ patch stage: needs patch -> patch review pull_requests: + pull_request15341 |
| 2019-09-04 20:55:09 | steve.dower | set | assignee: steve.dower |
| 2019-09-04 20:26:32 | eryksun | create | |