Issue 26329: os.path.normpath("//") returns // (original) (raw)

process

Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: Fred Rolland, Jack.McCracken, Winterflower, abarry, acue, furkanonder, lemburg, lukasz.langa, miss-islington, nanjekyejoannah, serhiy.storchaka
Priority: normal Keywords: patch

Created on 2016-02-10 14:58 by Fred Rolland, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
add-many-slash-path-note.patch Jack.McCracken,2016-06-05 22:23 review
Pull Requests
URL Status Linked Edit
PR 20138 merged furkanonder,2020-05-16 23:34
PR 27094 merged miss-islington,2021-07-12 12:48
PR 27095 merged miss-islington,2021-07-12 12:48
Messages (13)
msg260016 - (view) Author: Fred Rolland (Fred Rolland) Date: 2016-02-10 14:58
Hi, os.path.normpath("//") returns '//' I would expect to be '/' >>> os.path.normpath("//") '//' >>> os.path.normpath("///") '/' >>> os.path.normpath("////") '/'
msg260024 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2016-02-10 16:01
This is a duplicate of . This is intended behavior. It was introduced in changeset 01d5b80a3c03. From the POSIX Specification [1]: """ A pathname consisting of a single shall resolve to the root directory of the process. A null pathname shall not be successfully resolved. If a pathname begins with two successive characters, the first component following the leading characters may be interpreted in an implementation-defined manner, although more than two leading characters shall be treated as a single character. """ See also Stack Overflow and Stack Exchange questions: [2], [3], [4]. May be we should add an explanation and a link to the specification in the documentation and comments. [1] http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap04.html#tag_04_12 [2] http://stackoverflow.com/questions/7816818/why-doesnt-os-normapath-collapse-a-leading-double-slash [3] http://unix.stackexchange.com/questions/12283/unix-difference-between-path-starting-with-and [4] http://unix.stackexchange.com/questions/1910/how-does-linux-handle-multiple-consecutive-path-separators-home-username
msg265837 - (view) Author: Camilla Montonen (Winterflower) Date: 2016-05-18 20:41
Should the comment with the link to specification be added to Lib/posixpath.py? or Lib/os.py?
msg267400 - (view) Author: Arno-Can Uestuensoez (acue) Date: 2016-06-05 07:59
I propose to add at least a statement like e.g. "In conformance to IEEE Std 1003.1™, 2013 Edition; 4.12 Pathname Resolution". Because I had the same thought of a bug at first view, this because I did not find any hint in e.g. docs for 2.7.11. The reason to handle this thoroughly in my projects is the application of a path-matching library for generic unit tests, e.g. for bash scripts which require intensive PATH resolution. This has to be applied by the users of the library. See "https://pypi.python.org/pypi/pyfilesysobjects", and "https://pypi.python.org/pypi/epyunit" which requires intensive pattern matching of application provided pathnames, e.g. when it comes to automatic split of actual used PYTHONPATH items for a specific function/method, module, or package. E.g. the user provides an 'intentional casual' pathname for drop-in unit tests(see epyunit), "os.sep + context.sys.path[x] + os.sep + 'rel-module-path'", due to mixed relative and absolute paths resulting in leading "os.sep + os.sep". The pattern match than fails, but it is not immediately clear for which reason.
msg267411 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2016-06-05 12:09
Could you provide a patch Arno-Can? According to the comment in the configure script of GNU coreutils, the only POSIX platforms known for coreutils developers that have two distinct roots / and // are Cygwin, z/OS and dead Apollo DomainOS. Yet few exotic platforms are mentioned in the topic at http://comments.gmane.org/gmane.comp.standards.posix.austin.general/11947 .
msg267471 - (view) Author: Arno-Can Uestuensoez (acue) Date: 2016-06-05 20:25
Hi Serhiy, I am currently still investigating it for my own project. https://stackoverflow.com/questions/37646103/posix-path-1003-1-examples-and-behaviour-for-foo-bar Currently I do not have the build environment, so I can provide the text, but because I am a bit under pressure with finishing a larger pack of OpenSource projects currently I cannot manage to setup the environment. So can do this eventually in 2-3Weeks.
msg267478 - (view) Author: Jack McCracken (Jack.McCracken) * Date: 2016-06-05 21:44
Hey all - I would love to write a patch :) Working on it!
msg267481 - (view) Author: Jack McCracken (Jack.McCracken) * Date: 2016-06-05 22:23
Here's the patch I made.
msg343661 - (view) Author: Joannah Nanjekye (nanjekyejoannah) * (Python committer) Date: 2019-05-27 17:01
@ Jack McCracken do you want to open a pull request for this?
msg369084 - (view) Author: Furkan Onder (furkanonder) * Date: 2020-05-16 23:33
PR has been sent!
msg397304 - (view) Author: Joannah Nanjekye (nanjekyejoannah) * (Python committer) Date: 2021-07-12 12:48
New changeset 66c5853406bbcccecf35372795078c0641a5f385 by Furkan Onder in branch 'main': bpo-26329: update os.path.normpath documentation (GH-20138) https://github.com/python/cpython/commit/66c5853406bbcccecf35372795078c0641a5f385
msg397321 - (view) Author: Łukasz Langa (lukasz.langa) * (Python committer) Date: 2021-07-12 15:08
New changeset 443db64f496d3988d20cfda2c3c2ceb6702df36f by Miss Islington (bot) in branch '3.10': bpo-26329: update os.path.normpath documentation (GH-20138) (GH-27094) https://github.com/python/cpython/commit/443db64f496d3988d20cfda2c3c2ceb6702df36f
msg397328 - (view) Author: Łukasz Langa (lukasz.langa) * (Python committer) Date: 2021-07-12 15:22
New changeset 47abf240365ddd54a91c6ac167900d4bf6806c4f by Miss Islington (bot) in branch '3.9': bpo-26329: update os.path.normpath documentation (GH-20138) (#27095) https://github.com/python/cpython/commit/47abf240365ddd54a91c6ac167900d4bf6806c4f
History
Date User Action Args
2022-04-11 14:58:27 admin set github: 70517
2021-07-12 15:23:31 lukasz.langa set status: open -> closedresolution: fixedstage: patch review -> resolved
2021-07-12 15:22:37 lukasz.langa set messages: +
2021-07-12 15:08:06 lukasz.langa set nosy: + lukasz.langamessages: +
2021-07-12 12:48:26 nanjekyejoannah set messages: +
2021-07-12 12:48:24 miss-islington set pull_requests: + <pull%5Frequest25643>
2021-07-12 12:48:18 miss-islington set nosy: + miss-islingtonpull_requests: + <pull%5Frequest25642>
2021-06-21 14:12:09 iritkatriel set versions: + Python 3.9, Python 3.10, Python 3.11, - Python 2.7, Python 3.5, Python 3.6
2020-05-16 23:34:22 furkanonder set stage: needs patch -> patch reviewpull_requests: + <pull%5Frequest19444>
2020-05-16 23:33:46 furkanonder set nosy: + furkanondermessages: +
2019-05-27 17:01:03 nanjekyejoannah set nosy: + nanjekyejoannahmessages: +
2016-06-05 22:23:42 Jack.McCracken set files: + add-many-slash-path-note.patchkeywords: + patchmessages: +
2016-06-05 21:44:23 Jack.McCracken set nosy: + Jack.McCrackenmessages: +
2016-06-05 20:25:56 acue set messages: +
2016-06-05 12:09:40 serhiy.storchaka set messages: +
2016-06-05 07:59:01 acue set nosy: + acuemessages: +
2016-05-18 20:41:12 Winterflower set messages: +
2016-05-18 19:39:13 Winterflower set nosy: + Winterflower
2016-02-10 18:03:29 serhiy.storchaka set assignee: serhiy.storchaka ->
2016-02-10 16:01:15 serhiy.storchaka set nosy: + lemburgmessages: + components: + Documentation, - Library (Lib)
2016-02-10 15:17:48 abarry set assignee: serhiy.storchakatype: behaviornosy: + serhiy.storchaka, abarrystage: needs patch
2016-02-10 14:58:05 Fred Rolland create