summaryrefslogtreecommitdiff
path: root/sphinx/util
diff options
context:
space:
mode:
authorGeorg Brandl <georg@python.org>2012-01-29 12:23:17 +0100
committerGeorg Brandl <georg@python.org>2012-01-29 12:23:17 +0100
commit482d5619ec528a24b1ee93449905024e17193755 (patch)
tree70b948bd2b0830520cec26c05f04bfe1d27ccc40 /sphinx/util
parent992d0879ae4ffcd7e9117a3b266173ce21ed5897 (diff)
downloadsphinx-482d5619ec528a24b1ee93449905024e17193755.tar.gz
Closes #810: fix deprecation warnings with Python 3. What is left over is from nose or docutils.
Diffstat (limited to 'sphinx/util')
-rw-r--r--sphinx/util/inspect.py5
-rw-r--r--sphinx/util/pycompat.py5
2 files changed, 9 insertions, 1 deletions
diff --git a/sphinx/util/inspect.py b/sphinx/util/inspect.py
index f5c8911d..b5c3db59 100644
--- a/sphinx/util/inspect.py
+++ b/sphinx/util/inspect.py
@@ -16,6 +16,7 @@ import sys
inspect = __import__('inspect')
from sphinx.util import force_decode
+from sphinx.util.pycompat import bytes
if sys.version_info >= (2, 5):
@@ -89,4 +90,6 @@ def safe_repr(object):
s = repr(object)
except Exception:
raise ValueError
- return force_decode(s, None).replace('\n', ' ')
+ if isinstance(s, bytes):
+ return force_decode(s, None).replace('\n', ' ')
+ return s.replace('\n', ' ')
diff --git a/sphinx/util/pycompat.py b/sphinx/util/pycompat.py
index cd9f6e2f..9e081b02 100644
--- a/sphinx/util/pycompat.py
+++ b/sphinx/util/pycompat.py
@@ -64,6 +64,11 @@ else:
return s.encode('ascii', 'backslashreplace')
+try:
+ from html import escape as htmlescape
+except ImportError:
+ from cgi import escape as htmlescape
+
# ------------------------------------------------------------------------------
# Missing builtins and itertools in Python < 2.6