Skip to content

Use Unicode for server temp dir. - #1517

Merged
waylan merged 2 commits into
masterfrom
1516
Jun 29, 2018
Merged

waylan merged 2 commits into
masterfrom
1516

Conversation

@waylan

@waylan waylan commented Jun 24, 2018 •

Copy link
Copy Markdown
Contributor

The serve command overwrites the the site_dir and can cause a crash when
clean_directory tries to remove files with Unicode chars in their
filenames if the paths are byte strings. As os.path.join and friends
will return a byte string (in PY2) if any part is passed in is a byte
string, we must ensure all parts are Unicode strings. By passing a
Unicode string to prefix, tempfile.mkdtemp returns a Unicode string
rather than the default byte string in PY2. Fixes #1516.

This needs tests. However, the entire mkdocs.commands.serve module is untested, so this will have to wait until I have time to create tests for the entire module. I suspect lots of mock objects will be involved.

@waylan waylan added the Bug label Jun 29, 2018
@waylan waylan added this to the 1.0.0 milestone Jun 29, 2018
The serve command overrights the the site_dir and can cause a crash when
clean_directory tries to remove files with Unicode chars in their
filenames if the paths are byte strings. As os.path.join and friends
will return a byte string (in PY2) if any part is passed in is a byte
string, we must ensure all parts are Unicode strings. By passing a
Unicode string to prefix, tempfile.mkdtemp returns a Unicode string
rather than the default byte string in PY2. Fixes #1516.
@waylan
waylan merged commit 0a28707 into master Jun 29, 2018
@waylan
waylan deleted the 1516 branch June 29, 2018 23:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Unicode paths break clean_directory on server

1 participant