`pathlib.Path.exists()` fails on windows with a github URL
Closed this issue · 0 comments
andyk commented
Inside _get_all_remotes()
inside git_manager, we are currently using Path.exists()
to test whether a string is a local path or not. When it isn't a local path, it is a github url, and this raises an error in Windows (but not linux).
Lines 126 to 130 in be38e02
This fails in windows:
>>> import pathlib
>>> p = pathlib.Path('https:\\github.com\\DLR-RM\\stable-baselines3.git')
>>> p
WindowsPath('https:/github.com/DLR-RM/stable-baselines3.git')
>>> p.exists()
Traceback (most recent call last):
File "<input>", line 1, in <module>
File "C:\Python39\lib\pathlib.py", line 1407, in exists
self.stat()
File "C:\Python39\lib\pathlib.py", line 1221, in stat
return self._accessor.stat(self)
OSError: [WinError 123] The filename, directory name, or volume label syntax is incorrect: 'https:\\github.com\\DLR-RM\\stable-baselines3.git'
...but not in Linux:
>>> import pathlib
>>> pathlib.Path('https:\\github.com\\DLR-RM\\stable-baselines3.git')
PosixPath('https:\\github.com\\DLR-RM\\stable-baselines3.git')
>>> p = pathlib.Path('https:\\github.com\\DLR-RM\\stable-baselines3.git')
>>> p
PosixPath('https:\\github.com\\DLR-RM\\stable-baselines3.git')
>>> p.exists()
False