[issue21714] Path.with_name can construct invalid paths

2014-07-06 Thread Roundup Robot

Roundup Robot added the comment:

New changeset c2636b5816a3 by Antoine Pitrou in branch '3.4':
Issue #21714: Disallow the construction of invalid paths using 
Path.with_name().  Original patch by Antony Lee.
http://hg.python.org/cpython/rev/c2636b5816a3

--
nosy: +python-dev

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue21714
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue21714] Path.with_name can construct invalid paths

2014-07-06 Thread Antoine Pitrou

Antoine Pitrou added the comment:

Ok, patch now applied (as well as the original patch for with_suffix()). Thank 
you very much!

--
resolution:  - fixed
stage: needs patch - resolved
status: open - closed

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue21714
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue21714] Path.with_name can construct invalid paths

2014-06-22 Thread Antoine Pitrou

Antoine Pitrou added the comment:

 should path.with_name('foo/') be allowed?

For sanity, I think path separators should be disallowed.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue21714
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue21714] Path.with_name can construct invalid paths

2014-06-22 Thread Antony Lee

Antony Lee added the comment:

The attached patch fixes all the issues mentioned, and also integrates the 
fixes of issue 20639 (issues with with_suffix) as they are quite similar.

--
keywords: +patch
Added file: http://bugs.python.org/file35735/pathlib-with_name-with_suffix.patch

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue21714
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue21714] Path.with_name can construct invalid paths

2014-06-11 Thread Antoine Pitrou

Antoine Pitrou added the comment:

I think raising ValueError is the way to go. Would you like to try writing a 
patch for it?

--
nosy: +pitrou
stage:  - needs patch
type:  - behavior

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue21714
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue21714] Path.with_name can construct invalid paths

2014-06-11 Thread Antony Lee

Antony Lee added the comment:

I have the patch almost ready, but ran into another issue: should 
path.with_name('foo/') be allowed?  It may make sense to treat it like 
path.with_name('foo'), just like 'Path(foo/) == Path(foo)'.

The implementation is also simpler with it, as it can reuse the parse_parts 
approach used by with_suffix.  But this also raises a separate issue, which 
is that with the current implementation, we have 
Path('foo').with_suffix('.bar') == Path('foo').with_suffix('.bar/'), and that 
is less reasonable.  Should I open a separate issue for that?

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue21714
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue21714] Path.with_name can construct invalid paths

2014-06-10 Thread Antony Lee

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 rep...@bugs.python.org
http://bugs.python.org/issue21714
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com