diff options
author | Florent Xicluna <florent.xicluna@gmail.com> | 2010-10-14 21:46:04 (GMT) |
---|---|---|
committer | Florent Xicluna <florent.xicluna@gmail.com> | 2010-10-14 21:46:04 (GMT) |
commit | 80800d35713912eb4b9486033c1ce86bce263728 (patch) | |
tree | 7c48c4282ed190a8303263df40d42d6d169b423e /Lib/doctest.py | |
parent | f7c24450bebabbe9870b1b306ca2d9257ec280c6 (diff) | |
download | cpython-80800d35713912eb4b9486033c1ce86bce263728.zip cpython-80800d35713912eb4b9486033c1ce86bce263728.tar.gz cpython-80800d35713912eb4b9486033c1ce86bce263728.tar.bz2 |
Fix the issue with non-ascii char in doctest. Issue #9409
Recorded merge of revisions 85495,85500 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/branches/py3k
........
r85495 | florent.xicluna | 2010-10-14 22:56:20 +0200 (jeu., 14 oct. 2010) | 3 lines
Fix the regex to match all kind of filenames, for interactive debugging in doctests. (issue #9409)
........
r85500 | florent.xicluna | 2010-10-14 23:35:58 +0200 (jeu., 14 oct. 2010) | 2 lines
Add test case for issue #9409, non-ascii char in doctest. It passes in 3.2 but needs fixing in 2.7.
........
Diffstat (limited to 'Lib/doctest.py')
-rw-r--r-- | Lib/doctest.py | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/Lib/doctest.py b/Lib/doctest.py index dd579fd..c37ff9e 100644 --- a/Lib/doctest.py +++ b/Lib/doctest.py @@ -1333,7 +1333,9 @@ class DocTestRunner: m = self.__LINECACHE_FILENAME_RE.match(filename) if m and m.group('name') == self.test.name: example = self.test.examples[int(m.group('examplenum'))] - source = example.source.encode('ascii', 'backslashreplace') + source = example.source + if isinstance(source, unicode): + source = source.encode('ascii', 'backslashreplace') return source.splitlines(True) else: return self.save_linecache_getlines(filename, module_globals) |