[New-bugs-announce] [issue21714] Path.with_name can construct invalid paths

Antony Lee report at bugs.python.org
Wed Jun 11 07:39:26 CEST 2014


New submission from Antony Lee:

Path.with_name can be used to construct paths containing slashes as name contents (rather than as separators), as demonstrated below.

$ python -c 'from pathlib import Path; print(Path("foo").with_name("bar/baz").name)'
bar/baz

This should be changed to either raise a ValueError, or behave like path.parent / new_name.  Given the amount of checking in the related with_suffix method (and the fact that the second option can be readily implemented by hand), the first option seems preferable.

----------
components: Library (Lib)
messages: 220235
nosy: Antony.Lee
priority: normal
severity: normal
status: open
title: Path.with_name can construct invalid paths
versions: Python 3.4, Python 3.5

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue21714>
_______________________________________


More information about the New-bugs-announce mailing list