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.

Title: add dir_fd for mkstemp, and also maybe to all tempfile.*
Type: enhancement Stage: patch review
Components: Library (Lib) Versions: Python 3.11
Status: open Resolution:
Dependencies: 46245 Superseder:
Assigned To: Nosy List: ncoghlan, serhiy.storchaka, socketpair, ukarroum
Priority: normal Keywords: patch

Created on 2015-12-22 19:57 by socketpair, last changed 2022-04-11 14:58 by admin.

Pull Requests
URL Status Linked Edit
PR 31785 open serhiy.storchaka, 2022-03-09 14:20
Messages (9)
msg256856 - (view) Author: Марк Коренберг (socketpair) * Date: 2015-12-22 19:57
dir_fd support is good in `os` module. but tempfile module lack support of that great feature. Please add.
msg256864 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2015-12-22 20:46
Do you want to provide a patch Mark?
msg257143 - (view) Author: Марк Коренберг (socketpair) * Date: 2015-12-28 22:42
Yes, can I do it on, say, github ?
msg257148 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2015-12-28 22:57
See a guide:
msg409566 - (view) Author: Yassir Karroum (ukarroum) * Date: 2022-01-03 07:27
I started looking at this issue.

I may need to propagate the change (adding dir_fd as a keyword argument) to multiple functions in posixpath module: Functions like abspath, join, isdir, etc. The alternative will be to have the logic in tempfile module which feels off to me.

Does anyone have an issue with that ?
msg409577 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2022-01-03 11:36
I think it is better to not change posixpath for now. And it is not necessary. But shutil.rmtree() needs to support file descriptors, and it is not trivial issue.
msg409666 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2022-01-04 10:43
I have also almost finished this issue (only needed to add some tests and docs).
msg409670 - (view) Author: Yassir Karroum (ukarroum) * Date: 2022-01-04 11:04
Alright, I'll stop working on it then, thanks for the fix !
msg414802 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2022-03-09 14:28
There are two ways of supporting an open file descriptor to a directory:

1. Accept a file descriptor as the dir argument.
2. Add a new parameter dir_fd; dir will then be a path relative to dir_fd.

The original proposition is option 2. PR 31785 implements option 1. I am going to play with the code, implement option 2, and see what is simpler and what is more convenient.

Any thoughts or suggestions?
Date User Action Args
2022-04-11 14:58:25adminsetgithub: 70115
2022-03-09 14:28:05serhiy.storchakasetmessages: + msg414802
2022-03-09 14:20:54serhiy.storchakasetkeywords: + patch
stage: needs patch -> patch review
pull_requests: + pull_request29890
2022-01-04 14:07:51georg.brandlsetnosy: - georg.brandl
2022-01-04 11:04:46ukarroumsetmessages: + msg409670
2022-01-04 10:43:34serhiy.storchakasetmessages: + msg409666
2022-01-04 10:16:12ukarroumsetversions: + Python 3.11, - Python 3.6
2022-01-03 18:08:29serhiy.storchakasetdependencies: + Add support for dir_fd in shutil.rmtree()
2022-01-03 11:36:01serhiy.storchakasetmessages: + msg409577
2022-01-03 07:27:38ukarroumsetnosy: + ukarroum
messages: + msg409566
2015-12-28 22:57:58serhiy.storchakasetmessages: + msg257148
2015-12-28 22:42:12socketpairsetmessages: + msg257143
2015-12-22 20:46:34serhiy.storchakasetversions: - Python 3.3, Python 3.4, Python 3.5
nosy: + georg.brandl, ncoghlan, serhiy.storchaka

messages: + msg256864

type: enhancement
stage: needs patch
2015-12-22 19:57:23socketpairsetcomponents: + Library (Lib)
2015-12-22 19:57:01socketpaircreate