Skip to content

Path concatenation in pathlib do not allow for leading slash #130889

@cmeesters

Description

@cmeesters

Bug report

Bug description:

Under Linux, a leading / in a string results in a funny situation:

>>> p = Path("/home/someone")
>>> l = p / 'b' / 'test'
>>> print(l)
/home/someone/b/test
>>> l = p / 'b' / '/test'
>>> print(l)
/test

This may result in an unintended access relative to the root of a file system.

CPython versions tested on:

3.12

Operating systems tested on:

Linux

Metadata

Metadata

Assignees

No one assigned

    Labels

    type-bugAn unexpected behavior, bug, or error

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions