From 17e20c746e6b855f6bb4a28bbbfff66706762240 Mon Sep 17 00:00:00 2001 From: Pradyun Gedam Date: Sat, 28 Jan 2023 22:23:16 +0000 Subject: Correctly handle keyring auth subprocess newlines on Windows The line endings on Windows are not required to be `\n`. --- src/pip/_internal/network/auth.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/pip') diff --git a/src/pip/_internal/network/auth.py b/src/pip/_internal/network/auth.py index 68b5a5f45..c16213268 100644 --- a/src/pip/_internal/network/auth.py +++ b/src/pip/_internal/network/auth.py @@ -128,7 +128,7 @@ class KeyRingCliProvider(KeyRingBaseProvider): ) if res.returncode: return None - return res.stdout.decode("utf-8").strip("\n") + return res.stdout.decode("utf-8").strip(os.linesep) def _set_password(self, service_name: str, username: str, password: str) -> None: """Mirror the implementation of keyring.set_password using cli""" @@ -136,7 +136,7 @@ class KeyRingCliProvider(KeyRingBaseProvider): return None cmd = [self.keyring, "set", service_name, username] - input_ = password.encode("utf-8") + b"\n" + input_ = (password + os.linesep).encode("utf-8") env = os.environ.copy() env["PYTHONIOENCODING"] = "utf-8" res = subprocess.run(cmd, input=input_, env=env) -- cgit v1.2.1