From d6095e99c846aef17f4d5a6d8a78432a54aacc52 Mon Sep 17 00:00:00 2001 From: Anderson Bravalheri Date: Sun, 21 Aug 2022 06:43:34 +0100 Subject: Limit number of string replacements --- setuptools/command/editable_wheel.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'setuptools/command') diff --git a/setuptools/command/editable_wheel.py b/setuptools/command/editable_wheel.py index cd535e48..b908298f 100644 --- a/setuptools/command/editable_wheel.py +++ b/setuptools/command/editable_wheel.py @@ -684,9 +684,13 @@ def _is_nested(pkg: str, pkg_path: str, parent: str, parent_path: str) -> bool: False >>> _is_nested("a.b", "path/a/b", "c", "path/c") False + >>> _is_nested("a.a", "path/a/a", "a", "path/a") + True + >>> _is_nested("b.a", "path/b/a", "a", "path/a") + False """ norm_pkg_path = _normalize_path(pkg_path) - rest = pkg.replace(parent, "").strip(".").split(".") + rest = pkg.replace(parent, "", 1).strip(".").split(".") return ( pkg.startswith(parent) and norm_pkg_path == _normalize_path(Path(parent_path, *rest)) -- cgit v1.2.1