[issue26976] pathlib equivalent for os.path.realpath()

2016-05-08 Thread Brett Cannon

Changes by Brett Cannon :


--
nosy: +pitrou

___
Python tracker 

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



[issue26976] pathlib equivalent for os.path.realpath()

2016-05-08 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

This is a duplicate of issue19717.

--
nosy: +serhiy.storchaka
resolution:  -> duplicate
stage:  -> resolved
status: open -> closed
superseder:  -> resolve() fails when the path doesn't exist

___
Python tracker 

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



[issue26976] pathlib equivalent for os.path.realpath()

2016-05-08 Thread Davide Rizzo

Changes by Davide Rizzo :


--
type:  -> enhancement

___
Python tracker 

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



[issue26976] pathlib equivalent for os.path.realpath()

2016-05-08 Thread Davide Rizzo

New submission from Davide Rizzo:

pathlib doesn't provide an exact replacement for os.path.realpath().

Path.resolve() is the closest equivalent, but differs in behavior in one case: 
when the path does not exist.

>>> os.path.realpath('/foo')
'/foo'

>>> Path('/foo').resolve()
Traceback (most recent call last):
  File "", line 1, in 
  File 
"/usr/local/Cellar/python3/3.5.1/Frameworks/Python.framework/Versions/3.5/lib/python3.5/pathlib.py",
 line 1094, in resolve
s = self._flavour.resolve(self)
  File 
"/usr/local/Cellar/python3/3.5.1/Frameworks/Python.framework/Versions/3.5/lib/python3.5/pathlib.py",
 line 330, in resolve
return _resolve(base, str(path)) or sep
  File 
"/usr/local/Cellar/python3/3.5.1/Frameworks/Python.framework/Versions/3.5/lib/python3.5/pathlib.py",
 line 315, in _resolve
target = accessor.readlink(newpath)
  File 
"/usr/local/Cellar/python3/3.5.1/Frameworks/Python.framework/Versions/3.5/lib/python3.5/pathlib.py",
 line 422, in readlink
return os.readlink(path)
FileNotFoundError: [Errno 2] No such file or directory: '/foo'

This impairs pathlib usefulness to sanitize user input when I am about to 
create a file or a directory. The file does not exist yet, and pathlib doesn't 
provide an easy mean to validate whether the provided input is safe.

--
components: Library (Lib)
messages: 265128
nosy: davide.rizzo
priority: normal
severity: normal
status: open
title: pathlib equivalent for os.path.realpath()
versions: Python 3.6

___
Python tracker 

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