From 807d7c14bd11709f51b2d32a9ead08604ce05d44 Mon Sep 17 00:00:00 2001 From: Avasam Date: Fri, 21 Jun 2024 12:25:56 -0400 Subject: [PATCH] Move check to _fn --- pkg_resources/__init__.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/pkg_resources/__init__.py b/pkg_resources/__init__.py index 16a5bd8eef..89a416dc2c 100644 --- a/pkg_resources/__init__.py +++ b/pkg_resources/__init__.py @@ -1704,8 +1704,7 @@ def run_script(self, script_name: str, namespace: dict[str, Any]): **locals() ), ) - if not self.egg_info: - raise TypeError("Provider is missing egg_info", self.egg_info) + script_text = self.get_metadata(script).replace('\r\n', '\n') script_text = script_text.replace('\r', '\n') script_filename = self._fn(self.egg_info, script) @@ -1741,7 +1740,11 @@ def _listdir(self, path) -> list[str]: "Can't perform this operation for unregistered loader type" ) - def _fn(self, base: str, resource_name: str): + def _fn(self, base: str | None, resource_name: str): + if base is None: + raise TypeError( + "`base` parameter in `_fn` is `None`. Either override this method or check the parameter first." + ) self._validate_resource_path(resource_name) if resource_name: return os.path.join(base, *resource_name.split('/'))