Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add dir_fd for mkstemp, and also maybe to all tempfile.* #70115

Open
socketpair mannequin opened this issue Dec 22, 2015 · 9 comments
Open

add dir_fd for mkstemp, and also maybe to all tempfile.* #70115

socketpair mannequin opened this issue Dec 22, 2015 · 9 comments
Labels
3.11 only security fixes stdlib Python modules in the Lib dir type-feature A feature request or enhancement

Comments

@socketpair
Copy link
Mannequin

socketpair mannequin commented Dec 22, 2015

BPO 25927
Nosy @ncoghlan, @socketpair, @serhiy-storchaka, @ukarroum
PRs
  • [WIP] bpo-25927: Add support of a file descriptor in the tempfile module #31785
  • Dependencies
  • bpo-46245: Add support for dir_fd in shutil.rmtree()
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = None
    closed_at = None
    created_at = <Date 2015-12-22.19:57:01.835>
    labels = ['type-feature', 'library', '3.11']
    title = 'add dir_fd for mkstemp, and also maybe to all tempfile.*'
    updated_at = <Date 2022-03-09.14:28:05.687>
    user = 'https://github.com/socketpair'

    bugs.python.org fields:

    activity = <Date 2022-03-09.14:28:05.687>
    actor = 'serhiy.storchaka'
    assignee = 'none'
    closed = False
    closed_date = None
    closer = None
    components = ['Library (Lib)']
    creation = <Date 2015-12-22.19:57:01.835>
    creator = 'socketpair'
    dependencies = ['46245']
    files = []
    hgrepos = []
    issue_num = 25927
    keywords = ['patch']
    message_count = 9.0
    messages = ['256856', '256864', '257143', '257148', '409566', '409577', '409666', '409670', '414802']
    nosy_count = 4.0
    nosy_names = ['ncoghlan', 'socketpair', 'serhiy.storchaka', 'ukarroum']
    pr_nums = ['31785']
    priority = 'normal'
    resolution = None
    stage = 'patch review'
    status = 'open'
    superseder = None
    type = 'enhancement'
    url = 'https://bugs.python.org/issue25927'
    versions = ['Python 3.11']

    @socketpair
    Copy link
    Mannequin Author

    socketpair mannequin commented Dec 22, 2015

    dir_fd support is good in os module. but tempfile module lack support of that great feature. Please add.

    @socketpair socketpair mannequin added the stdlib Python modules in the Lib dir label Dec 22, 2015
    @serhiy-storchaka
    Copy link
    Member

    Do you want to provide a patch Mark?

    @serhiy-storchaka serhiy-storchaka added the type-feature A feature request or enhancement label Dec 22, 2015
    @socketpair
    Copy link
    Mannequin Author

    socketpair mannequin commented Dec 28, 2015

    Yes, can I do it on, say, github ?

    @serhiy-storchaka
    Copy link
    Member

    See a guide: https://docs.python.org/devguide/.

    @ukarroum
    Copy link
    Mannequin

    ukarroum mannequin commented Jan 3, 2022

    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 ?

    @serhiy-storchaka
    Copy link
    Member

    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.

    @ukarroum ukarroum mannequin added the 3.11 only security fixes label Jan 4, 2022
    @serhiy-storchaka
    Copy link
    Member

    I have also almost finished this issue (only needed to add some tests and docs).

    @ukarroum
    Copy link
    Mannequin

    ukarroum mannequin commented Jan 4, 2022

    Alright, I'll stop working on it then, thanks for the fix !

    @serhiy-storchaka
    Copy link
    Member

    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?

    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    3.11 only security fixes stdlib Python modules in the Lib dir type-feature A feature request or enhancement
    Projects
    Status: No status
    Development

    No branches or pull requests

    1 participant