Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

✨ Support cp850 encoding for auto-completion in PowerShell #808

Merged
merged 6 commits into from
Nov 18, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions typer/_completion_shared.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,15 +183,15 @@ def install_powershell(*, prog_name: str, complete_var: str, shell: str) -> Path
if isinstance(result.stdout, str): # pragma: no cover
path_str = result.stdout
if isinstance(result.stdout, bytes):
try:
# PowerShell would be predominant in Windows
path_str = result.stdout.decode("windows-1252")
except UnicodeDecodeError: # pragma: no cover
for encoding in ["windows-1252", "utf8", "cp850"]:
try:
path_str = result.stdout.decode("utf8")
except UnicodeDecodeError:
click.echo("Couldn't decode the path automatically", err=True)
raise
path_str = result.stdout.decode(encoding)
break
except UnicodeDecodeError: # pragma: no cover
pass
if not path_str: # pragma: no cover
click.echo("Couldn't decode the path automatically", err=True)
raise click.exceptions.Exit(1)
path_obj = Path(path_str.strip())
parent_dir: Path = path_obj.parent
parent_dir.mkdir(parents=True, exist_ok=True)
Expand Down
Loading