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

Error when using a unicode filename on Windows #833

Closed
sebastian-marinescu opened this issue Feb 21, 2016 · 5 comments
Closed

Error when using a unicode filename on Windows #833

sebastian-marinescu opened this issue Feb 21, 2016 · 5 comments
Labels
Bug

Comments

@sebastian-marinescu
Copy link

@sebastian-marinescu sebastian-marinescu commented Feb 21, 2016

I am not totally sure this is the right place, but you will tell me :)
In a mkdocs-material-project I wanted to use diacritics in the filename, like this:

/Kapitel
  1. Einstieg
  2. Übersicht
  3. Etcetera

And such an "Ü" seems to break everything:

C:\Python27\lib\urllib.py:1303: UnicodeWarning: Unicode equal comparison failed to convert both arguments to Unicode - interpreting them as being unequal
  return ''.join(map(quoter, s))
ERROR   -  Error building page Allgemeines\1. Richtlinien.md
Traceback (most recent call last):
  File "C:\Python27\lib\runpy.py", line 162, in _run_module_as_main
    "__main__", fname, loader, pkg_name)
  File "C:\Python27\lib\runpy.py", line 72, in _run_code
    exec code in run_globals
  File "C:\Python27\Scripts\mkdocs.exe\__main__.py", line 9, in <module>
  File "C:\Python27\lib\site-packages\click\core.py", line 716, in __call__
    return self.main(*args, **kwargs)
  File "C:\Python27\lib\site-packages\click\core.py", line 696, in main
    rv = self.invoke(ctx)
  File "C:\Python27\lib\site-packages\click\core.py", line 1060, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "C:\Python27\lib\site-packages\click\core.py", line 889, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "C:\Python27\lib\site-packages\click\core.py", line 534, in invoke
    return callback(*args, **kwargs)
  File "C:\Python27\lib\site-packages\mkdocs\__main__.py", line 115, in serve_command
    livereload=livereload,
  File "C:\Python27\lib\site-packages\mkdocs\commands\serve.py", line 78, in serve
    config = builder()
  File "C:\Python27\lib\site-packages\mkdocs\commands\serve.py", line 74, in builder
    build(config, live_server=True, clean_site_dir=True)
  File "C:\Python27\lib\site-packages\mkdocs\commands\build.py", line 289, in build
    build_pages(config)
  File "C:\Python27\lib\site-packages\mkdocs\commands\build.py", line 249, in build_pages
    dump_json)
  File "C:\Python27\lib\site-packages\mkdocs\commands\build.py", line 184, in _build_page
    output_content = template.render(context)
  File "C:\Python27\lib\site-packages\jinja2\environment.py", line 989, in render
    return self.environment.handle_exception(exc_info, True)
  File "C:\Python27\lib\site-packages\jinja2\environment.py", line 754, in handle_exception
    reraise(exc_type, exc_value, tb)
  File "C:\Python27\lib\site-packages\material\base.html", line 102, in top-level template code
    {% include "drawer.html" %}
  File "C:\Python27\lib\site-packages\material\drawer.html", line 41, in top-level template code
    {% include "nav.html" %}
  File "C:\Python27\lib\site-packages\material\nav.html", line 6, in top-level template code
    {% include 'nav.html' %}
  File "C:\Python27\lib\site-packages\material\nav.html", line 12, in top-level template code
    <a class="{% if nav_item.active %}current{% endif %}" title="{{ nav_item.title }}" href="{{ nav_item.url }}">
  File "C:\Python27\lib\site-packages\jinja2\environment.py", line 408, in getattr
    return getattr(obj, attribute)
  File "C:\Python27\lib\site-packages\mkdocs\nav.py", line 153, in url
    return self.url_context.make_relative(self.abs_url)
  File "C:\Python27\lib\site-packages\mkdocs\nav.py", line 105, in make_relative
    return utils.path_to_url(relative_path)
  File "C:\Python27\lib\site-packages\mkdocs\utils\__init__.py", line 324, in path_to_url
    return pathname2url(path)
  File "C:\Python27\lib\nturl2path.py", line 54, in pathname2url
    return urllib.quote('/'.join(components))
  File "C:\Python27\lib\urllib.py", line 1303, in quote
    return ''.join(map(quoter, s))
KeyError: u'\xdc'

Is this already known?

@d0ugal d0ugal changed the title Can't use diacritics in the filename? Error when using a unicode filename Feb 22, 2016
@d0ugal d0ugal changed the title Error when using a unicode filename Error when using a unicode filename on Windows Feb 22, 2016
@d0ugal
Copy link
Member

@d0ugal d0ugal commented Feb 22, 2016

I just checked your example and this works fine on Linux (and last time I checked it did on OSX too). So I am fairly sure this is an issue with how we support Windows.

Unfortunately Windows is a best effort support, as I don't use windows.

@d0ugal d0ugal added the Bug label Feb 22, 2016
@d0ugal
Copy link
Member

@d0ugal d0ugal commented Feb 22, 2016

Our Windows CI failed with a similar error when I added a new unicode-filename test. So that gives me one way to reproduce it, now we just need to figure out a fix.

See lines 1065 - 1109.
https://ci.appveyor.com/project/d0ugal/mkdocs/build/2.785/job/d2yc5lqi8mohq69i

@d0ugal
Copy link
Member

@d0ugal d0ugal commented Feb 22, 2016

The test did pass on Python 3 under windows, so a work around would be to use Python 3.

@sebastian-marinescu
Copy link
Author

@sebastian-marinescu sebastian-marinescu commented Feb 22, 2016

Thanks for the information. For the current project I just stuck to the page-tree 👍

@d0ugal
Copy link
Member

@d0ugal d0ugal commented Feb 22, 2016

This is the actual error outside of MkDocs.

Python 2.7.10 (default, Aug 18 2015, 10:37:14) 
[GCC 5.1.1 20150618 (Red Hat 5.1.1-4)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from urllib import pathname2url
>>> pathname2url(u"Ü")
/home/dougal/.pyenv/versions/2.7.10/lib/python2.7/urllib.py:1303: UnicodeWarning: Unicode equal comparison failed to convert both arguments to Unicode - interpreting them as being unequal
  return ''.join(map(quoter, s))
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/dougal/.pyenv/versions/2.7.10/lib/python2.7/urllib.py", line 61, in pathname2url
    return quote(pathname)
  File "/home/dougal/.pyenv/versions/2.7.10/lib/python2.7/urllib.py", line 1303, in quote
    return ''.join(map(quoter, s))
KeyError: u'\xdc'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.