Navigation Menu

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

pathlib.Path('/').mkdir() raises wrong error type #69989

Closed
DanielLepage mannequin opened this issue Dec 5, 2015 · 7 comments
Closed

pathlib.Path('/').mkdir() raises wrong error type #69989

DanielLepage mannequin opened this issue Dec 5, 2015 · 7 comments
Assignees
Labels
3.7 (EOL) end of life stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error

Comments

@DanielLepage
Copy link
Mannequin

DanielLepage mannequin commented Dec 5, 2015

BPO 25803
Nosy @pitrou, @serhiy-storchaka, @eryksun
PRs
  • bpo-25803: Avoid incorrect errors raised by Path.mkdir(exist_ok=True) #805
  • bpo-25803: Avoid incorrect errors raised by Path.mkdir(exist_ok=True)… #806
  • bpo-25803: Avoid incorrect errors raised by Path.mkdir(exist_ok=True)… #807
  • 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 = 'https://github.com/serhiy-storchaka'
    closed_at = <Date 2017-03-24.19:50:35.993>
    created_at = <Date 2015-12-05.03:48:12.568>
    labels = ['3.7', 'type-bug', 'library']
    title = "pathlib.Path('/').mkdir() raises wrong error type"
    updated_at = <Date 2017-03-24.19:50:35.992>
    user = 'https://bugs.python.org/DanielLepage'

    bugs.python.org fields:

    activity = <Date 2017-03-24.19:50:35.992>
    actor = 'serhiy.storchaka'
    assignee = 'serhiy.storchaka'
    closed = True
    closed_date = <Date 2017-03-24.19:50:35.993>
    closer = 'serhiy.storchaka'
    components = ['Library (Lib)']
    creation = <Date 2015-12-05.03:48:12.568>
    creator = 'Daniel Lepage'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 25803
    keywords = []
    message_count = 7.0
    messages = ['255916', '255956', '255958', '290100', '290105', '290112', '290113']
    nosy_count = 4.0
    nosy_names = ['pitrou', 'serhiy.storchaka', 'eryksun', 'Daniel Lepage']
    pr_nums = ['805', '806', '807']
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'behavior'
    url = 'https://bugs.python.org/issue25803'
    versions = ['Python 3.5', 'Python 3.6', 'Python 3.7']

    @DanielLepage
    Copy link
    Mannequin Author

    DanielLepage mannequin commented Dec 5, 2015

    pathlib.Path('/').mkdir() raises an IsADirectoryError instead of a FileExistsError.

    @DanielLepage DanielLepage mannequin added stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error labels Dec 5, 2015
    @DanielLepage
    Copy link
    Mannequin Author

    DanielLepage mannequin commented Dec 5, 2015

    It looks like this is an OSX-specific behavior, and not a python problem:
    $ mkdir .
    mkdir: .: File exists
    $ mkdir /
    mkdir: /: Is a directory

    @eryksun
    Copy link
    Contributor

    eryksun commented Dec 5, 2015

    The mkdir method needs a fix similar to what was done for bpo-25583. For example, currently on Windows the exist_ok option doesn't handle the PermissionError raised when [accidentally] trying to create the root directory:

        >>> pathlib.Path('C:/').mkdir(exist_ok=True)
        Traceback (most recent call last):
          File "<stdin>", line 1, in <module>
          File "C:\Program Files\Python 3.5\lib\pathlib.py", line 1199, in mkdir
            self._accessor.mkdir(self, mode)
          File "C:\Program Files\Python 3.5\lib\pathlib.py", line 371, in wrapped
            return strfunc(str(pathobj), *args)
        PermissionError: [WinError 5] Access is denied: 'C:\\'

    @serhiy-storchaka
    Copy link
    Member

    I can't test on Windows and OSX but I suppose PR 805 fixes both issues.

    @serhiy-storchaka serhiy-storchaka added the 3.7 (EOL) end of life label Mar 24, 2017
    @serhiy-storchaka serhiy-storchaka self-assigned this Mar 24, 2017
    @serhiy-storchaka
    Copy link
    Member

    New changeset af7b9ec by Serhiy Storchaka in branch 'master':
    bpo-25803: Avoid incorrect errors raised by Path.mkdir(exist_ok=True) (#805)
    af7b9ec

    @serhiy-storchaka
    Copy link
    Member

    New changeset 8c8785b by Serhiy Storchaka in branch '3.6':
    bpo-25803: Avoid incorrect errors raised by Path.mkdir(exist_ok=True)… (#806)
    8c8785b

    @serhiy-storchaka
    Copy link
    Member

    New changeset 1fc1f8d by Serhiy Storchaka in branch '3.5':
    bpo-25803: Avoid incorrect errors raised by Path.mkdir(exist_ok=True) (#805) (#807)
    1fc1f8d

    @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.7 (EOL) end of life stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error
    Projects
    None yet
    Development

    No branches or pull requests

    2 participants