# Buggy code
def path_to_url(path):
    """Convert a system path to a URL."""

    if os.path.sep == "/":
        return path

    return pathname2url(path)


# Traceback (KeyError)
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'

# Fixed code
def path_to_url(path):
    """Convert a system path to a URL."""

    if os.path.sep == "/":
        return path

    if sys.version_info < (3, 0):
        path = path.encode("utf8")
    return pathname2url(path)