diff --git a/src/pip/_internal/req/req_file.py b/src/pip/_internal/req/req_file.py index f6ba70fe7f6..376e465f457 100644 --- a/src/pip/_internal/req/req_file.py +++ b/src/pip/_internal/req/req_file.py @@ -595,6 +595,11 @@ def get_file_content(url: str, session: "PipSession") -> Tuple[str, str]: def _decode_req_file(data: bytes, url: str) -> str: + # NOTE: Byte Order Marks other than the UTF-8 BOM (used by PEP 263) + # aren't allowed as per the requirements.txt spec, but deprecating + # them isn't feasible as Windows Powershell uses UTF-16 (usually + # encountered while redirecting output to a requirements.txt). + # Thus, they remain as implementation-defined behaviour :/ for bom, encoding in BOMS: if data.startswith(bom): return data[len(bom) :].decode(encoding)