This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: 2to3 does not convert output lines in doctests
Type: Stage:
Components: 2to3 (2.x to 3.x conversion tool) Versions: Python 3.2, Python 2.7, Python 2.6
process
Status: closed Resolution: wont fix
Dependencies: Superseder:
Assigned To: Nosy List: benjamin.peterson, eric.araujo
Priority: normal Keywords:

Created on 2010-01-31 17:00 by eric.araujo, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Messages (3)
msg98620 - (view) Author: Éric Araujo (eric.araujo) * (Python committer) Date: 2010-01-31 17:00
Howdy

I think there is a bug with 2to3’s doctest conversion:

$ echo ">>> u'éric'" > test
$ echo "u'éric'" >> test
$ 2to3 -d test -f unicode
--- test (original)
+++ test (refactored)
@@ -1,3 +1,3 @@
->>> u'éric'
+>>> 'éric'
 u'éric'
 
RefactoringTool: Files that need to be modified:
RefactoringTool: test


The output should be converted too.

Tested with 2.6.4+ (Debian’s), 2.7a2+ and 3.2a0.

Kind regards
msg98621 - (view) Author: Benjamin Peterson (benjamin.peterson) * (Python committer) Date: 2010-01-31 17:20
The output line can be anything, so it's impossible for 2to3 to know that it is a Python expression that needs to be converted.
msg98623 - (view) Author: Éric Araujo (eric.araujo) * (Python committer) Date: 2010-01-31 17:36
> to know that it is a Python expression that needs to be converted.

Oh, of course. I have made two assumptions here: output lines are not 
always the repr of a Python object, and the repr is not always a valid 
Python expression.

I’ll have to subclass build_2to3 in my setup script. *groans*

Thank you for answering.

Merwok
History
Date User Action Args
2022-04-11 14:56:57adminsetgithub: 52070
2010-01-31 17:36:51eric.araujosetmessages: + msg98623
2010-01-31 17:20:58benjamin.petersonsetstatus: open -> closed

nosy: + benjamin.peterson
messages: + msg98621

resolution: wont fix
2010-01-31 17:00:16eric.araujocreate