Skip to content

Support for file descriptor params in os.path #76052

Open

Description

@MateuszKurek
BPO 31871
Nosy @merwok, @serhiy-storchaka

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 2017-10-26.05:33:13.367>
labels = ['type-feature', '3.7', 'docs']
title = 'Support for file descriptor params in os.path'
updated_at = <Date 2017-10-28.09:49:54.401>
user = 'https://bugs.python.org/MateuszKurek'

bugs.python.org fields:

activity = <Date 2017-10-28.09:49:54.401>
actor = 'serhiy.storchaka'
assignee = 'docs@python'
closed = False
closed_date = None
closer = None
components = ['Documentation']
creation = <Date 2017-10-26.05:33:13.367>
creator = 'Mateusz Kurek'
dependencies = []
files = []
hgrepos = []
issue_num = 31871
keywords = []
message_count = 3.0
messages = ['305023', '305129', '305152']
nosy_count = 4.0
nosy_names = ['eric.araujo', 'docs@python', 'serhiy.storchaka', 'Mateusz Kurek']
pr_nums = []
priority = 'normal'
resolution = None
stage = None
status = 'open'
superseder = None
type = 'enhancement'
url = 'https://bugs.python.org/issue31871'
versions = ['Python 3.4', 'Python 3.5', 'Python 3.6', 'Python 3.7']

Activity

  1. MateuszKurek commented on Oct 26, 2017

    MateuszKurekmannequin
    MannequinAuthor

    Since Python 3.3, some os module functions, like os.stat (https://docs.python.org/3/library/os.html#os.stat), support passing file descriptor instead of a path. os.path functions, on the other hand (like os.path.exists - https://docs.python.org/3/library/os.path.html#os.path.exists - or os.path.samefile - https://docs.python.org/3/library/os.path.html#os.path.samefile) mention using os.stat underneath, but according to documentation, does not support passing file descriptor instead of a path (at least it's not mentioned in the docs that this feature is supported). Is this intentional (os.path functions should not take file descriptor params) or this feature is officialy supported, but it's ommited in the docs?

  2. merwok commented on Oct 27, 2017

    @merwok
    Member

    support passing file descriptor instead of a path. os.path functions

    Are you sure about that? The docs for os.stat show the dir_fd parameter, used to avoid directory renaming issues or attacks, but it doesn’t say that the *path* argument can be an int file descriptor instead of a str file path.

  3. serhiy-storchaka commented on Oct 28, 2017

    @serhiy-storchaka
    Member

    Éric, see https://docs.python.org/3/library/os.html#files-and-directories.

    Yes, now some os.path functions can accept a file descriptor as a path. I don't think this is intentional. And this may not work on all platforms.

    >>> os.path.isdir(1)
    False
    >>> os.path.islink(1)
    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
      File "/home/serhiy/py/cpython/Lib/posixpath.py", line 169, in islink
        st = os.lstat(path)
    TypeError: lstat: path should be string, bytes or os.PathLike, not int
  4. transferred this issue fromon Apr 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    3.7 (EOL)end of lifedocsDocumentation in the Doc dirtype-featureA feature request or enhancement

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions