summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorJim Fulton <jim@zope.com>2004-10-13 14:15:32 (GMT)
committerJim Fulton <jim@zope.com>2004-10-13 14:15:32 (GMT)
commit7d428788e156200df2f8e6421cad9fce083fd96b (patch)
tree64ee331217a5b783b97b63b020c2a31636e72fe2 /Lib
parent73cc8479f000bbb84d0775aea55fb9de75ec110e (diff)
downloadcpython-7d428788e156200df2f8e6421cad9fce083fd96b.zip
cpython-7d428788e156200df2f8e6421cad9fce083fd96b.tar.gz
cpython-7d428788e156200df2f8e6421cad9fce083fd96b.tar.bz2
Fixed a small bug. doctest didn't handle unicode docstrings containing
non-ascii characters.
Diffstat (limited to 'Lib')
-rw-r--r--Lib/doctest.py4
-rw-r--r--Lib/test/test_doctest2.py18
-rw-r--r--Lib/test/test_doctest2.txt7
3 files changed, 26 insertions, 3 deletions
diff --git a/Lib/doctest.py b/Lib/doctest.py
index 26a8914..a8162f3 100644
--- a/Lib/doctest.py
+++ b/Lib/doctest.py
@@ -962,7 +962,9 @@ class DocTestFinder:
if obj.__doc__ is None:
docstring = ''
else:
- docstring = str(obj.__doc__)
+ docstring = obj.__doc__
+ if not isinstance(docstring, basestring):
+ docstring = str(docstring)
except (TypeError, AttributeError):
docstring = ''
diff --git a/Lib/test/test_doctest2.py b/Lib/test/test_doctest2.py
index 3593d41..5b7f36f 100644
--- a/Lib/test/test_doctest2.py
+++ b/Lib/test/test_doctest2.py
@@ -1,17 +1,31 @@
-"""A module to test whether doctest recognizes some 2.2 features,
+# -*- coding: utf-8 -*-
+u"""A module to test whether doctest recognizes some 2.2 features,
like static and class methods.
>>> print 'yup' # 1
yup
+
+We include some (random) encoded (utf-8) text in the text surrounding
+the example. It should be ignored:
+
+ЉЊЈЁЂ
+
"""
from test import test_support
class C(object):
- """Class C.
+ u"""Class C.
>>> print C() # 2
42
+
+
+ We include some (random) encoded (utf-8) text in the text surrounding
+ the example. It should be ignored:
+
+ ЉЊЈЁЂ
+
"""
def __init__(self):
diff --git a/Lib/test/test_doctest2.txt b/Lib/test/test_doctest2.txt
index 0d7d1d5..2e14856 100644
--- a/Lib/test/test_doctest2.txt
+++ b/Lib/test/test_doctest2.txt
@@ -5,3 +5,10 @@ In this example, we'll rely on some silly setup:
>>> import test.test_doctest
>>> test.test_doctest.sillySetup
True
+
+This test also has some (random) encoded (utf-8) unicode text:
+
+ ЉЊЈЁЂ
+
+This doesn't cause a problem in the tect surrounding the examples, but
+we include it here (in this test text file) to make sure. :)