Skip to content

Windows encoding bugfix#277

Closed
matejfroebe wants to merge 5 commits intofastapi:masterfrom
matejfroebe:win-encoding-bugfix
Closed

Windows encoding bugfix#277
matejfroebe wants to merge 5 commits intofastapi:masterfrom
matejfroebe:win-encoding-bugfix

Conversation

@matejfroebe
Copy link
Copy Markdown

Problem: When installing auto-completion in Powershell, the path to
the profile file was decoded with windows-1252 encoding - but such
path didn't exist in my case. The correct encoding was cp850.

Solution:

  • try to decode with cp850 also
  • check if the decoded path exists (checking for UnicodeDecodeError isn't enough)

Problem: When installing auto-completion in Powershell, the path to
the profile file was decoded with windows-1252 encoding - but such
path didn't exist in my case. The correct encoding was cp850.

Solution:
- try to decode with cp850 also
- check if the decoded path exists (checking for UnicodeDecodeError isn't enough)
@svlandeg svlandeg added the os / windows Related to Windows label Apr 21, 2022
@svlandeg svlandeg added bug Something isn't working autocompletion p2 and removed investigate labels Mar 8, 2024
Comment thread typer/_completion_shared.py
@svlandeg svlandeg marked this pull request as draft April 19, 2024 15:38
Comment thread typer/_completion_shared.py Outdated
Copy link
Copy Markdown
Member

@svlandeg svlandeg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi!

Thanks for your contribution, and I apologize for the delay in reviewing this.

For easier reviewing, I suggest to split the suggested changes up in two PRs:

  • one adding the cp850 encoding - this should be straightforward.
  • one for also checking whether the path exists.

After some initial testing, it looks like the second PR would require some changes to the test suite, so I prefer getting the first change in as such, and then build on it. I'll look into this after #808 is merged.

Comment on lines 193 to +194
except UnicodeDecodeError:
click.echo("Couldn't decode the path automatically", err=True)
raise
pass
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not use contextlib.suppress there?

@tiangolo
Copy link
Copy Markdown
Member

Thanks @matejfroebe! 🤓 This was handled in #808, so I'll close this one now. The fix will be available in the next release in a few hours. 0.13.1 🚀

@tiangolo tiangolo closed this Nov 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working os / windows Related to Windows p2 shell / powershell

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants