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 | b06dd5080fc5abd71dc3a427a2bc482cfd7a5733 (patch) | |
| tree | fb8486a6a56642fd7dd8cf57e810724a75eff33b /sphinx | |
| parent | 12c2447b0972fe8bc23ba8132ad5bf13bea5baf7 (diff) | |
| download | sphinx-b06dd5080fc5abd71dc3a427a2bc482cfd7a5733.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')
| -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 07cd520c..7999bf59 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() |
