diff options
author | Wojtek Kosior <koszko@koszko.org> | 2022-06-14 10:40:57 +0200 |
---|---|---|
committer | Wojtek Kosior <koszko@koszko.org> | 2022-06-14 10:40:57 +0200 |
commit | 50a0341baa5fc9a8e999f77e232cb21eae54ba0a (patch) | |
tree | e0053cd18f028ef71b9126b634f9862e02994a42 /src | |
parent | 117bf196e195c758ca53fda3f9ab974767bfa90c (diff) | |
download | hydrilla-builder-50a0341baa5fc9a8e999f77e232cb21eae54ba0a.tar.gz hydrilla-builder-50a0341baa5fc9a8e999f77e232cb21eae54ba0a.zip |
restore compatibility with python 3.7
Diffstat (limited to 'src')
-rw-r--r-- | src/hydrilla/builder/build.py | 6 | ||||
-rw-r--r-- | src/hydrilla/builder/piggybacking.py | 4 |
2 files changed, 7 insertions, 3 deletions
diff --git a/src/hydrilla/builder/build.py b/src/hydrilla/builder/build.py index 44f3dd9..89c1f5a 100644 --- a/src/hydrilla/builder/build.py +++ b/src/hydrilla/builder/build.py @@ -200,11 +200,13 @@ class Build: path = piggybacked.resolve_file(desired_path) if path is None: path = (self.srcdir / desired_path).resolve() - if not path.is_relative_to(self.srcdir): + try: + rel_path = path.relative_to(self.srcdir) + except ValueError: raise FileReferenceError(_('loading_{}_outside_package_dir') .format(filename)) - if str(path.relative_to(self.srcdir)) == 'index.json': + if str(rel_path) == 'index.json': raise FileReferenceError(_('loading_reserved_index_json')) else: include_in_source_archive = False diff --git a/src/hydrilla/builder/piggybacking.py b/src/hydrilla/builder/piggybacking.py index 7c03946..00186bc 100644 --- a/src/hydrilla/builder/piggybacking.py +++ b/src/hydrilla/builder/piggybacking.py @@ -98,7 +98,9 @@ class Piggybacked: path = path.resolve() - if not path.is_relative_to(root_path): + try: + path.relative_to(root_path) + except ValueError: raise FileReferenceError(_('loading_{}_outside_piggybacked_dir') .format(file_ref_name)) |