Skip to content

Commit 56da892

Browse files
authored
UPath.open: add mode argument default (#61)
The missing default for the `mode` argument lead to errors, as the default of `HTTPFile` in fsspec is `rb`, not `r` as in Paths. E.g. the following command produced an error before, which is fixed by using the actual Path implementation default: ```python from upath import UPath UPath("http://raw.githubusercontent.com/fsspec/universal_pathlib/main/README.md").open(encoding="utf-8").read() ```
1 parent fd10643 commit 56da892

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

upath/core.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@ def __init__(self, parsed_url: ParseResult, **kwargs):
2929
def _format_path(self, path: "UPath") -> str:
3030
return path.path
3131

32-
def open(self, path, *args, **kwargs):
33-
return self._fs.open(self._format_path(path), *args, **kwargs)
32+
def open(self, path, mode='r', *args, **kwargs):
33+
return self._fs.open(self._format_path(path), mode, *args, **kwargs)
3434

3535
def stat(self, path, **kwargs):
3636
return self._fs.stat(self._format_path(path), **kwargs)

0 commit comments

Comments
 (0)