Improper parsing of a file://
uri on Windows
#325
Labels
bug
The problem described is something that must be fixed
file://
uri on Windows
#325
Python includes a number of URL parsing utilities. One benefit is that the format for URLs in python is standard across libraries. It currently looks like the URL parsing code for the
file
scheme in uproot4 is not conformant on Windows (but works fine on Linux).An example of a valid windows URL:
file:///g:/mydir/file.root
. The above code will parse this, on windows, to/g:/mydir/file.root
which cannot be opened by python'sopen
function. However,g:/mydir/file.root
works just fine.There is another possible issue - in that URLs aren't unquoted during processing by the code (though I did not test this).
To work around this problem I've used some discussion on stack overflow to help me with the following code which works in python 3+, and is cross-platform:
Note that even that discussion is a bit confused: it is important to read the answer comments to interpret the answers. The above example was pulled from the last answer, and then the python2 code was stripped out.
If I might be so bold, one way to do testing on this is using
pathlib
. For example:Or similar. But this will make sure your file URL parsing works on all platforms and uses python "standards" to make sure it all works.
The text was updated successfully, but these errors were encountered: