diff options
author | Sascha Peilicke <sasch.pe@gmx.de> | 2013-11-13 15:33:25 +0100 |
---|---|---|
committer | Sascha Peilicke <sasch.pe@gmx.de> | 2013-11-13 15:33:25 +0100 |
commit | 310b4fb806a15f97b5cb5de4717b9869bd47a8a0 (patch) | |
tree | fb8486a6a56642fd7dd8cf57e810724a75eff33b /sphinx/setup_command.py | |
parent | 8b986fe4db94b391b5b58d29f1e96ea2af5204cb (diff) | |
download | sphinx-git-310b4fb806a15f97b5cb5de4717b9869bd47a8a0.tar.gz |
BuildDoc shouldn't fail on Unicode paths.
Sub-classes of sphinx.setup_command.BuildDoc may choose to call
finalize_options in their run() method again for various reasons. However,
currently this fails with py2.7 because of http://bugs.python.org/issue19570.
Since it is unlikely that the upstream issue will be solved, a workaround is
to re-implement distutils' Command._ensure_stringlike to support Unicode
strings.
Diffstat (limited to 'sphinx/setup_command.py')
-rw-r--r-- | sphinx/setup_command.py | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/sphinx/setup_command.py b/sphinx/setup_command.py index 07cd520c3..7999bf591 100644 --- a/sphinx/setup_command.py +++ b/sphinx/setup_command.py @@ -14,6 +14,7 @@ import sys import os +import types from StringIO import StringIO from distutils.cmd import Command @@ -98,6 +99,19 @@ class BuildDoc(Command): return root return None + # Overriding distutils' Command._ensure_stringlike which doesn't support + # unicode, causing finalize_options to fail if invoked again. Workaround + # for http://bugs.python.org/issue19570 + def _ensure_stringlike(self, option, what, default=None): + val = getattr(self, option) + if val is None: + setattr(self, option, default) + return default + elif not isinstance(val, types.StringTypes): + raise DistutilsOptionError("'%s' must be a %s (got `%s`)" + % (option, what, val)) + return val + def finalize_options(self): if self.source_dir is None: self.source_dir = self._guess_source_dir() |