summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnton Khirnov <anton@khirnov.net>2023-10-16 16:46:10 +0200
committerAnton Khirnov <anton@khirnov.net>2023-10-16 16:46:10 +0200
commit49c1362ff05a446c4360b8a0af104a341388a97a (patch)
tree15e287e1e6f9754e58a75a26a5a6d1c665e08736
parentc8dbad5856170e32554db2345acd43c2bb0bd729 (diff)
_path: convert constructor argument to bytes
Allows constructing AbsPath() from anything that converts to bytes.
-rw-r--r--lbup/_path.py3
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'/'))