Matthis Thorade added the comment:
I found this bug when trying to write a doctest that passes on Python 3.5 and
Python 2.7.9.
The following adapted example passes on Python2, but fails on Python3:
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
def f():
"""
>>> f()
Georg Brandl ge...@python.org added the comment:
Yeah, I don't really remember now what my point was.
--
status: pending - closed
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue3955
___
R. David Murray rdmur...@bitdance.com added the comment:
I fail to see the problem here. If the module has 'from __future__ import
unicode_literals, then the docstring output clauses would need to be changed
to reflect the fact that the input literals are now unicode. What am I missing?
Christoph Burgmer cburg...@ira.uka.de added the comment:
JFTR: To yield the results of my last comment, you need to apply the
patch posted in http://bugs.python.org/issue1293741
--
___
Python tracker rep...@bugs.python.org
Christoph Burgmer cburg...@ira.uka.de added the comment:
This problem seems more severe as the appended test case shows.
That gives me:
Expected:
u'ī'
Got:
u'\u012b'
Both literals are the same.
Unicode literals in doc strings are not treated as other escaped
characters:
Christoph Burgmer cburg...@ira.uka.de added the comment:
OutputChecker.check_output() seems to be responsible for comparing
'example.want' and 'got' literals and this is obviously done literally.
So as u'1' is different to '1' this is reflected in the result.
This gets more complicated with
New submission from Mark Summerfield [EMAIL PROTECTED]:
# This program works fine with Python 2.5 and 2.6:
def f():
f()
'xyz'
return xyz
if __name__ == __main__:
import doctest
doctest.testmod()
But if you put the statement from __future__ import
Georg Brandl [EMAIL PROTECTED] added the comment:
It certainly isn't a feature. I don't immediately see how to fix it,
though. unicode_literals doesn't change the repr() of unicode objects
(it obviously can't, since that change would not be module-local).
Let's try to get a comment from Uncle