From d4a601743e1cdb65e60e514ec1a37a33af053c0a Mon Sep 17 00:00:00 2001 From: Albert Tugushev Date: Fri, 8 Apr 2022 21:56:44 +0700 Subject: [PATCH] Don't mutate template --- src/pip/_internal/resolution/resolvelib/factory.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/pip/_internal/resolution/resolvelib/factory.py b/src/pip/_internal/resolution/resolvelib/factory.py index 3cfcac865ff..663bff89def 100644 --- a/src/pip/_internal/resolution/resolvelib/factory.py +++ b/src/pip/_internal/resolution/resolvelib/factory.py @@ -1,4 +1,5 @@ import contextlib +import copy import functools import logging from typing import ( @@ -255,7 +256,7 @@ def _iter_found_candidates( # "template". Here we just choose the first requirement to represent # all of them. # Hopefully the Project model can correct this mismatch in the future. - template = ireqs[0] + template = copy.deepcopy(ireqs[0]) assert template.req, "Candidates found on index must be PEP 508" name = canonicalize_name(template.req.name)