From 4344402dd5b975af5c73040678af60270d4ea962 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aalok=20=7C=20=E0=A4=86=E0=A4=B2=E0=A5=8B=E0=A4=95?= <10784697+aalok-sathe@users.noreply.github.com> Date: Tue, 2 Nov 2021 14:21:44 -0400 Subject: [PATCH] Handles name == None case (re: issue #4311) Addresses issue #4311 and others, related to `canonicalize_name` throwing TypeError because a str or bytes like object was expected. --- poetry/repositories/installed_repository.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/poetry/repositories/installed_repository.py b/poetry/repositories/installed_repository.py index f5adbe0ac7b..0c564d21fe8 100644 --- a/poetry/repositories/installed_repository.py +++ b/poetry/repositories/installed_repository.py @@ -231,8 +231,13 @@ def load(cls, env: Env, with_dependencies: bool = False) -> "InstalledRepository metadata.distributions(path=[entry]), key=lambda d: str(d._path), ): - name = canonicalize_name(distribution.metadata["name"]) - + try: + name = canonicalize_name(distribution.metadata["name"]) + except TypeError as e: + # handling the case where a distribution is empty but is nevertheless picked up in the search + # and its name is `None` + continue + if name in seen: continue