diff options
author | Anton Khirnov <anton@khirnov.net> | 2023-10-16 16:46:10 +0200 |
---|---|---|
committer | Anton Khirnov <anton@khirnov.net> | 2023-10-16 16:46:10 +0200 |
commit | 49c1362ff05a446c4360b8a0af104a341388a97a (patch) | |
tree | 15e287e1e6f9754e58a75a26a5a6d1c665e08736 | |
parent | c8dbad5856170e32554db2345acd43c2bb0bd729 (diff) |
_path: convert constructor argument to bytes
Allows constructing AbsPath() from anything that converts to bytes.
-rw-r--r-- | lbup/_path.py | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/lbup/_path.py b/lbup/_path.py index 994611f..49cdec5 100644 --- a/lbup/_path.py +++ b/lbup/_path.py @@ -8,6 +8,9 @@ class AbsPath: if path is not None: if isinstance(path, str): path = path.encode('utf-8') + else: + path = bytes(path) + if len(path) < 1 or not path.startswith(b'/'): raise ValueError('Path does not look like valid absolute path', path) components = filter(lambda x: len(x) > 0 and x != b'.', path[1:].split(b'/')) |