From 49c1362ff05a446c4360b8a0af104a341388a97a Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Mon, 16 Oct 2023 16:46:10 +0200 Subject: _path: convert constructor argument to bytes Allows constructing AbsPath() from anything that converts to bytes. --- lbup/_path.py | 3 +++ 1 file changed, 3 insertions(+) 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'/')) -- cgit v1.2.3