
This issue trackerhas been migrated toGitHub, and is currentlyread-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.
Created on2020-03-09 16:54 byserhiy.storchaka, last changed2022-04-11 14:59 byadmin. This issue is nowclosed.
| Pull Requests | |||
|---|---|---|---|
| URL | Status | Linked | Edit |
| PR 18880 | merged | serhiy.storchaka,2020-03-09 16:58 | |
| PR 18934 | merged | miss-islington,2020-03-11 16:42 | |
| PR 18935 | merged | miss-islington,2020-03-11 16:42 | |
| Messages (4) | |||
|---|---|---|---|
| msg363750 -(view) | Author: Serhiy Storchaka (serhiy.storchaka)*![]() | Date: 2020-03-09 16:54 | |
Path.glob() uses os.scandir() in the following code. entries = list(scandir(parent_path))It properly closes the internal file descriptor opened by scandir() if success because it is automatically closed closed when the iterator is exhausted. But if it was interrupted (by KeyboardInterrupt, MemoryError or OSError), the file descriptor will be closed only when the iterator be collected by the garbage collector. It is unreliable on implementations like PyPy and emits a ResourceWarning.The proposed code uses more reliable code with scandir(parent_path) as scandir_it: entries = list(scandir_it)which is used in other sites (in the shutil module). I have no idea why I did not write it in this form at first place. | |||
| msg363934 -(view) | Author: Serhiy Storchaka (serhiy.storchaka)*![]() | Date: 2020-03-11 16:42 | |
New changeset704e2065f8b8021a4a6999470fb6ed3453f7679e by Serhiy Storchaka in branch 'master':bpo-39916: Use os.scandir() as context manager in Path.glob(). (GH-18880)https://github.com/python/cpython/commit/704e2065f8b8021a4a6999470fb6ed3453f7679e | |||
| msg363942 -(view) | Author: miss-islington (miss-islington) | Date: 2020-03-11 17:00 | |
New changesetb1b1d5ff11108620f5bc97976bb889f5cbb24373 by Miss Islington (bot) in branch '3.7':bpo-39916: Use os.scandir() as context manager in Path.glob(). (GH-18880)https://github.com/python/cpython/commit/b1b1d5ff11108620f5bc97976bb889f5cbb24373 | |||
| msg363944 -(view) | Author: miss-islington (miss-islington) | Date: 2020-03-11 17:07 | |
New changesetc22879914b03ff2da768e557b5c00e9c8c62c695 by Miss Islington (bot) in branch '3.8':bpo-39916: Use os.scandir() as context manager in Path.glob(). (GH-18880)https://github.com/python/cpython/commit/c22879914b03ff2da768e557b5c00e9c8c62c695 | |||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2022-04-11 14:59:27 | admin | set | github: 84097 |
| 2020-03-11 17:07:50 | serhiy.storchaka | set | status: open -> closed resolution: fixed stage: patch review -> resolved |
| 2020-03-11 17:07:11 | miss-islington | set | messages: +msg363944 |
| 2020-03-11 17:00:16 | miss-islington | set | messages: +msg363942 |
| 2020-03-11 16:42:31 | miss-islington | set | pull_requests: +pull_request18287 |
| 2020-03-11 16:42:24 | miss-islington | set | nosy: +miss-islington pull_requests: +pull_request18286 |
| 2020-03-11 16:42:07 | serhiy.storchaka | set | messages: +msg363934 |
| 2020-03-09 16:58:44 | serhiy.storchaka | set | keywords: +patch stage: patch review pull_requests: +pull_request18237 |
| 2020-03-09 16:54:33 | serhiy.storchaka | create | |