You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The problem with this approach is that file URIs and OS paths are quite different, for one, with windows OS paths, e.g. C:\Users\runneradmin\AppData\Local\Temp\pytest-of-unknown\pytest-0\test_select_result_serialize_p6\file-DestinationType.STR_PATH, the drive letter gets interpreted as the URL scheme:
Furthermore, URIs support percent encoding, while OS paths do not.
Here is an example of things going wrong (from here)
------------------------------ Captured log call ------------------------------
2022-07-30T12:11:21.926 ERROR root test_result.py:317:test_select_result_serialize_parse destination = C:\Users\runneradmin\AppData\Local\Temp\pytest-of-unknown\pytest-0\test_select_result_serialize_p6\file-DestinationType.STR_PATH
2022-07-30T12:11:21.926 ERROR root test_result.py:318:test_select_result_serialize_parse format = csv
2022-07-30T12:11:21.926 ERROR root test_result.py:319:test_select_result_serialize_parse encoding = utf-16
___________ test_select_result_serialize_parse[csv-STR_PATH-utf-8] ____________
Traceback (most recent call last):
File "C:\hostedtoolcache\windows\Python\3.7.9\x64\lib\shutil.py", line 566, in move
os.rename(src, real_dst)
FileNotFoundError: [WinError 3] The system cannot find the path specified: 'C:\\Users\\RUNNER~1\\AppData\\Local\\Temp\\tmpgk0vyq6q' -> '\\Users\\runneradmin\\AppData\\Local\\Temp\\pytest-of-unknown\\pytest-0\\test_select_result_serialize_p7\\file-DestinationType.STR_PATH'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "D:\a\rdflib\rdflib\test\test_sparql\test_result.py", line 323, in test_select_result_serialize_parse
encoding=encoding,
File "D:\a\rdflib\rdflib\rdflib\query.py", line 283, in serialize
shutil.move(name, path)
File "C:\hostedtoolcache\windows\Python\3.7.9\x64\lib\shutil.py", line 580, in move
copy_function(src, real_dst)
File "C:\hostedtoolcache\windows\Python\3.7.9\x64\lib\shutil.py", line 266, in copy2
copyfile(src, dst, follow_symlinks=follow_symlinks)
File "C:\hostedtoolcache\windows\Python\3.7.9\x64\lib\shutil.py", line 121, in copyfile
with open(dst, 'wb') as fdst:
FileNotFoundError: [Errno 2] No such file or directory: '\\Users\\runneradmin\\AppData\\Local\\Temp\\pytest-of-unknown\\pytest-0\\test_select_result_serialize_p7\\file-DestinationType.STR_PATH'
I think the best we can do to fix the path handling is to do the same as what happens in Graph.serialize
aucampia
changed the title
Result.serialize() path handling is broken for windows pathsResult.serialize() path handling is broken for windows paths and some other cases
Jul 30, 2022
I have been trying to figure out what is happening with these xfails:
rdflib/test/test_sparql/test_result.py
Lines 282 to 306 in 1d5f3e7
The problem is with the approach to path handling:
rdflib/rdflib/query.py
Lines 268 to 279 in 1d5f3e7
The problem with this approach is that file URIs and OS paths are quite different, for one, with windows OS paths, e.g.
C:\Users\runneradmin\AppData\Local\Temp\pytest-of-unknown\pytest-0\test_select_result_serialize_p6\file-DestinationType.STR_PATH
, the drive letter gets interpreted as the URL scheme:Furthermore, URIs support percent encoding, while OS paths do not.
Here is an example of things going wrong (from here)
I think the best we can do to fix the path handling is to do the same as what happens in
Graph.serialize
rdflib/rdflib/graph.py
Lines 1204 to 1218 in 1d5f3e7
This will fill relative path handling in some cases also, however it will break relative URI handling.
The text was updated successfully, but these errors were encountered: