This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: String conversion of Path removes '/' from original url
Type: behavior Stage: resolved
Components: Library (Lib) Versions: Python 3.6
process
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: Nosy List: eric.smith, manish.satwani
Priority: normal Keywords:

Created on 2021-08-05 16:15 by manish.satwani, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Messages (5)
msg399008 - (view) Author: Manish Satwani (manish.satwani) Date: 2021-08-05 16:15
import pathlib
p = pathlib.Path('adl://myblob.azuredatalakestore.net/local/abc/xyz')
s = str(p)
print(s)
what you expect s to be??
There is a bug in path.Path.str(conversion to string) and it remove a slash
s is 'adl:/myblob.azuredatalakestore.net/local/abc/xyz' <-- this is getting print....plz fix it
msg399009 - (view) Author: Manish Satwani (manish.satwani) Date: 2021-08-05 16:16
import pathlib
p = pathlib.Path('adl://myblob.azuredatalakestore.net/local/abc/xyz')
s = str(p)
print(s)
what you expect s to be??
There is a bug in path.Path.str(conversion to string) and it remove a slash
s is 'adl:/myblob.azuredatalakestore.net/local/abc/xyz' <-- this is getting print....plz fix it
msg399013 - (view) Author: Eric V. Smith (eric.smith) * (Python committer) Date: 2021-08-05 16:30
pathlib is not designed to support URIs, so this behavior is not surprising. 

You want to use a different library, maybe urllib.
msg399036 - (view) Author: Manish Satwani (manish.satwani) Date: 2021-08-05 20:15
Thanks for the update Eric, if it is not designed to support URI it should tell to the user. It is very wired it just returns wrong data.

You can detect it very well if user has specified URI or not.
msg399043 - (view) Author: Eric V. Smith (eric.smith) * (Python committer) Date: 2021-08-05 22:10
But that's a perfectly valid filename:

$ mkdir -p adl://myblob.azuredatalakestore.net/local/abc/xyz
$ ls -R adl:
'adl:':
myblob.azuredatalakestore.net/

'adl:/myblob.azuredatalakestore.net':
local/

'adl:/myblob.azuredatalakestore.net/local':
abc/

'adl:/myblob.azuredatalakestore.net/local/abc':
xyz/

'adl:/myblob.azuredatalakestore.net/local/abc/xyz':

The pathlib module isn't going to guess whether you passed it a filename or URI of some sort, especially when it's a valid filename. That's the caller's job to get right.

Removing the double slashes is a normal part of pathlib's behavior of normalizing paths, just as if you said from a bash shell "ls //etc//sysconfig", which will show the contents of "/etc/sysconfig". Although I'll admit I couldn't find this documented anywhere with a quick search.
History
Date User Action Args
2022-04-11 14:59:48adminsetgithub: 89005
2021-08-05 22:10:06eric.smithsetstatus: open -> closed
resolution: not a bug
messages: + msg399043

stage: resolved
2021-08-05 20:15:07manish.satwanisetmessages: + msg399036
2021-08-05 16:30:00eric.smithsetnosy: + eric.smith
messages: + msg399013
2021-08-05 16:16:06manish.satwanisetmessages: + msg399009
2021-08-05 16:15:08manish.satwanicreate