summaryrefslogtreecommitdiff
path: root/sphinx/setup_command.py
diff options
context:
space:
mode:
authorSascha Peilicke <sasch.pe@gmx.de>2013-11-13 15:33:25 +0100
committerSascha Peilicke <sasch.pe@gmx.de>2013-11-13 15:33:25 +0100
commit900ba65ab4bae75df5f566b21bf51745d949c13a (patch)
treee19b874b2dce0837fbaa6b2099cb22803343f685 /sphinx/setup_command.py
parent63d34cca47317de7b94910a55245309e25f7e0e7 (diff)
downloadsphinx-git-900ba65ab4bae75df5f566b21bf51745d949c13a.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.py14
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()