diff --git a/docs/changelog.rst b/docs/changelog.rst index ba00ed1f..1ef13666 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -10,6 +10,12 @@ v0.19.5 (UNRELEASED) Bug fix release. +- config: Support UTF-8 in default config. If an extension with non-ASCII + characters in its default config was installed, and Mopidy didn't already + have a config file, Mopidy would crashed when trying to create the initial + config file based on the default config of all available extensions. + (Fixes: :discuss:`428`) + - Models: Hide empty collections from :func:`repr()` representations. - Models: Field values are no longer stored on the model instance when the diff --git a/mopidy/config/__init__.py b/mopidy/config/__init__.py index 5611c717..a6578825 100644 --- a/mopidy/config/__init__.py +++ b/mopidy/config/__init__.py @@ -97,8 +97,12 @@ def format_initial(extensions): versions = ['Mopidy %s' % versioning.get_version()] for extension in sorted(extensions, key=lambda ext: ext.dist_name): versions.append('%s %s' % (extension.dist_name, extension.version)) - description = _INITIAL_HELP.strip() % {'versions': '\n# '.join(versions)} - return description + '\n\n' + _format(config, {}, schemas, False, True) + + header = _INITIAL_HELP.strip() % {'versions': '\n# '.join(versions)} + formatted_config = _format( + config=config, comments={}, schemas=schemas, + display=False, disable=True).decode('utf-8') + return header + '\n\n' + formatted_config def _load(files, defaults, overrides):