[New-bugs-announce] [issue44316] Support preserving path meaning in os.path.normpath() and abspath()

Barney Gale report at bugs.python.org
Fri Jun 4 17:21:19 EDT 2021


New submission from Barney Gale <barney.gale at gmail.com>:

>>> os.path.normpath('a/./b/../c//.')
'a/c'
>>> pathlib.Path('a/./b/../c//.')
PosixPath('a/b/../c')

pathlib takes care not to change the meaning of the path when normalising. That means preserving '..' entries, as these can't be simplified without resolving symlinks etc.

normpath(), on the other handle, /always/ eliminates '..' entries, which can change the meaning of the path.

We could add a new argument to `normpath()` and `abspath()` that leaves '..' entries intact. This was closed as "won't fix" back in bpo-2289, but I think it's worth re-considering.

This enhancement would be helpful for my longer-term work to make pathlib an OOP wrapper of os + os.path, rather than a parallel implementation.

----------
components: Library (Lib)
messages: 395122
nosy: barneygale
priority: normal
severity: normal
status: open
title: Support preserving path meaning in os.path.normpath() and abspath()
type: enhancement

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue44316>
_______________________________________


More information about the New-bugs-announce mailing list