summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnderson Bravalheri <andersonbravalheri@gmail.com>2022-08-21 06:34:41 +0100
committerAnderson Bravalheri <andersonbravalheri@gmail.com>2022-08-21 06:34:41 +0100
commit2372749be2e92df5d2aab11b1407948a8e25bf2f (patch)
tree95cccca705030ae372510ee0b939fd0bd2bbbc91
parent54a8656ecbdfaaaf47f8b12260d8779632e370e1 (diff)
downloadpython-setuptools-git-2372749be2e92df5d2aab11b1407948a8e25bf2f.tar.gz
Fix recursion problem in finder
-rw-r--r--setuptools/command/editable_wheel.py2
-rw-r--r--setuptools/tests/test_editable_install.py3
2 files changed, 3 insertions, 2 deletions
diff --git a/setuptools/command/editable_wheel.py b/setuptools/command/editable_wheel.py
index ea214841..cd535e48 100644
--- a/setuptools/command/editable_wheel.py
+++ b/setuptools/command/editable_wheel.py
@@ -755,7 +755,7 @@ class _EditableFinder: # MetaPathFinder
def find_spec(cls, fullname, path=None, target=None):
for pkg, pkg_path in reversed(list(MAPPING.items())):
if fullname.startswith(pkg):
- rest = fullname.replace(pkg, "").strip(".").split(".")
+ rest = fullname.replace(pkg, "", 1).strip(".").split(".")
return cls._find_spec(fullname, Path(pkg_path, *rest))
return None
diff --git a/setuptools/tests/test_editable_install.py b/setuptools/tests/test_editable_install.py
index ff65df9b..4a2ceb12 100644
--- a/setuptools/tests/test_editable_install.py
+++ b/setuptools/tests/test_editable_install.py
@@ -495,6 +495,7 @@ class TestFinderTemplate:
assert three.x == 3
def test_no_recursion(self, tmp_path):
+ # See issue #3550
files = {
"pkg": {
"__init__.py": "from . import pkg",
@@ -511,7 +512,7 @@ class TestFinderTemplate:
sys.modules.pop("pkg", None)
self.install_finder(template)
- with pytest.raises(ModuleNotFoundError, match="No module named 'pkg.pkg'"):
+ with pytest.raises(ImportError, match="pkg"):
import_module("pkg")