Skip to content

Commit

Permalink
Better subprocess handling
Browse files Browse the repository at this point in the history
  • Loading branch information
uranusjr committed Jan 13, 2023
1 parent 9fdc1cd commit f53f5da
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/pip/_internal/network/auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,13 +138,14 @@ def _set_password(self, service_name: str, username: str, password: str) -> None
"""Mirror the implementation of keyring.set_password using cli"""
if self.keyring is None:
return None

cmd = [self.keyring, "set", service_name, username]
input_ = (password + os.linesep).encode("utf-8")
env = os.environ.copy()
env["PYTHONIOENCODING"] = "utf-8"
res = subprocess.run(cmd, input=input_, env=env)
res.check_returncode()
subprocess.run(
[self.keyring, "set", service_name, username],
input=f"{password}{os.linesep}".encode("utf-8"),
env=env,
check=True,
)
return None


Expand Down

0 comments on commit f53f5da

Please sign in to comment.