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

Explicitly encode path as UTF-8 in truncate_filename() #319

Conversation

Freso
Copy link
Member

@Freso Freso commented Oct 29, 2018

os.pathconf() expects a bytes object, but the path is stored as a unicode object. Since there's no specified encoding, Python chokes when trying to convert it to a bytes object. Explicitly encoding it as UTF-8 allows Python to change it to a bytes object smoothly.

Fixes #315

`os.pathconf()` expects a bytes object, but the path is stored as a
unicode object. Since there's no specified encoding, Python chokes when
trying to convert it to a bytes object. Explicitly encoding it as UTF-8
allows Python to change it to a bytes object smoothly.

Fixes whipper-team#315
@Freso Freso force-pushed the issue-315-fix-unicode-error-in-truncate_filename branch from 777a3c8 to 0fff37c Compare October 29, 2018 12:06
@Freso
Copy link
Member Author

Freso commented Oct 29, 2018

Wooble in #python on Freenode said:

You probably want to use the filesystem encoding rather than hardcoding utf-8, although if the user gets "ascii" for that when their actual filesystem will happily use something else, then... well, they're going to lose.

@JoeLametta
Copy link
Collaborator

Thanks for the pull request!

Wooble in #python on Freenode said:

You probably want to use the filesystem encoding rather than hardcoding utf-8, although if the user gets "ascii" for that when their actual filesystem will happily use something else, then... well, they're going to lose.

That's a great advice indeed. I'll merge this pull request as is and open a new issue about it.

@JoeLametta JoeLametta merged commit 996cfd7 into whipper-team:master Oct 29, 2018
@Freso Freso deleted the issue-315-fix-unicode-error-in-truncate_filename branch October 29, 2018 12:28
@JoeLametta JoeLametta mentioned this pull request Nov 2, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants