[issue37130] pathlib.Path.with_name() handles '.' and '..' inconsistently

2020-01-31 Thread Brett Cannon


Change by Brett Cannon :


--
assignee: brett.cannon -> 

___
Python tracker 

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



[issue37130] pathlib.Path.with_name() handles '.' and '..' inconsistently

2020-01-31 Thread Brett Cannon


Brett Cannon  added the comment:

So I tried making pathlib.PurePath handle "." more like ".." and tests started 
failing all over the place in test_pathlib, which means it would be a change in 
semantics and could start silently breaking people as most of the checks are 
for specific exceptions.

So the next question is where is '..' being mishandled? It might be possible 
and better to tighten up how '..' is treated than try to make '.' suddenly be 
treated in a weaker way.

--
nosy: +jaraco

___
Python tracker 

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



[issue37130] pathlib.Path.with_name() handles '.' and '..' inconsistently

2019-07-26 Thread Jeffrey Kintscher


Jeffrey Kintscher  added the comment:

I'll take a crack at adding support for Path('.').name == '.'.

--

___
Python tracker 

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



[issue37130] pathlib.Path.with_name() handles '.' and '..' inconsistently

2019-07-26 Thread Brett Cannon


Brett Cannon  added the comment:

Anyone up for doing a PR that makes Path('.').name == '.'? It would be good to 
see if that would break the stdlib as a proxy as to how many people might be 
relying on these semantics. My hope is nothing breaks in which case we can make 
the change in 3.9 and notify people in What's New of the new, consistent 
semantics.

--

___
Python tracker 

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



[issue37130] pathlib.Path.with_name() handles '.' and '..' inconsistently

2019-07-08 Thread Steinmann


Steinmann  added the comment:

@Brett: I also think making Path('.').name evaluate to '.' would be the most 
logical thing. More even so since the documentation says PurePath.name() is 
equivalent to os.path.basename()[1], but:

>>> Path('.').name
''
>>> os.path.basename('.')
'.'

Though I'm not sure if that is ok to change this behaviour or if people already 
rely on it.

No matter which decision is made, I would say the documentation should be 
improved.
If it will be the same as basename, document this also here [2].
Otherwise add a note to [1], maybe in the same format and position as was done 
for os.path.relpath().

[1] 
https://docs.python.org/3/library/pathlib.html#correspondence-to-tools-in-the-os-module
[2] https://docs.python.org/3/library/pathlib.html#pathlib.PurePath.name

--
nosy: +lucas.steinmann

___
Python tracker 

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



[issue37130] pathlib.Path.with_name() handles '.' and '..' inconsistently

2019-07-05 Thread Brett Cannon


Brett Cannon  added the comment:

Thinking about this a bit, I my gut says having Path('.').name == '.' makes 
more sense than returning ''. My reasoning is that in any case where there's a 
single value -- e.g. Path('spam') -- you end up with the part returned in 
`name`. That suggests to me that '.' isn't any more special or ambiguous than 
'spam' or '..'.

Antoine, what do you think?

--

___
Python tracker 

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



[issue37130] pathlib.Path.with_name() handles '.' and '..' inconsistently

2019-06-13 Thread Brett Cannon


Brett Cannon  added the comment:

@Antoine: Basically Path.with_name() fails under '.' but works with '..' 
although with a somewhat odd result. And then after that is the fact that 
Path('.').name is the empty string but for Path('..').name it's '..' (which is 
what causes Path('.').with_name() to fail).

--
title: pathlib does not handle '..' directory -> pathlib.Path.with_name() 
handles '.' and '..' inconsistently

___
Python tracker 

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