summaryrefslogtreecommitdiff
path: root/sphinx/util
diff options
context:
space:
mode:
Diffstat (limited to 'sphinx/util')
-rw-r--r--sphinx/util/console.py18
-rw-r--r--sphinx/util/inspect.py4
2 files changed, 17 insertions, 5 deletions
diff --git a/sphinx/util/console.py b/sphinx/util/console.py
index 7663feb1e..d62169adf 100644
--- a/sphinx/util/console.py
+++ b/sphinx/util/console.py
@@ -87,9 +87,21 @@ def coloron():
codes.update(_orig_codes)
-def colorize(name, text):
- # type: (str, unicode) -> unicode
- return codes.get(name, '') + text + codes.get('reset', '')
+def colorize(name, text, input_mode=False):
+ # type: (str, unicode, bool) -> unicode
+ def escseq(name):
+ # Wrap escape sequence with ``\1`` and ``\2`` to let readline know
+ # it is non-printable characters
+ # ref: https://tiswww.case.edu/php/chet/readline/readline.html
+ #
+ # Note: This hack does not work well in Windows (see #5059)
+ escape = codes.get(name, '')
+ if input_mode and escape and sys.platform != 'win32':
+ return '\1' + escape + '\2'
+ else:
+ return escape
+
+ return escseq(name) + text + escseq('reset')
def strip_colors(s):
diff --git a/sphinx/util/inspect.py b/sphinx/util/inspect.py
index 7bda11503..5727d69b1 100644
--- a/sphinx/util/inspect.py
+++ b/sphinx/util/inspect.py
@@ -176,8 +176,8 @@ def isstaticmethod(obj, cls=None, name=None):
elif cls and name:
# trace __mro__ if the method is defined in parent class
#
- # .. note:: This only works with new style classes.
- for basecls in getattr(cls, '__mro__', []):
+ # .. note:: This only works well with new style classes.
+ for basecls in getattr(cls, '__mro__', [cls]):
meth = basecls.__dict__.get(name)
if meth:
if isinstance(meth, staticmethod):