[Python-3000] [patch] Should 2to3 point out possible, but not definite changes? (original) (raw)

Adrian Holovaty adrian at holovaty.com
Sat Aug 25 07:58:57 CEST 2007


On 8/24/07, Collin Winter <collinw at gmail.com> wrote:

Adrian and I talked about this this morning, and he said he's going to go ahead with an implementation. The original warning messages were a good idea, but they tend to get lost when converting large projects.

(I assume this is the place to post patches for the 2to3 utility, but please set me straight if I should use bugs.python.org instead...)

I've attached two patches that implement the 2to3 change discussed in this thread. In 2to3_insert_comment.diff --

It also handles existing comments gracefully. If a line already has a comment above it, the new comment will be added on a new line under the old one.

The other patch, 2to3_comment_warnings.diff, is an example of how we could integrate this new insert_comment() method to replace the current functionality of fixes.basefix.BaseFix.warning(). To see this in action, apply these two patches and run the 2to3 script (refactor.py) on the following input:

foo()
map(f, x)

The resulting output should display a Python comment above the map() call instead of outputting a warning to stdout, which was the previous behavior.

If these patches are accepted, the next steps would be to change the behavior of warns() and warns_unchanged() in tests/test_fixers.py, so that the tests can catch the new behavior.

Adrian

-- Adrian Holovaty holovaty.com | djangoproject.com -------------- next part -------------- A non-text attachment was scrubbed... Name: 2to3_comment_warnings.diff Type: application/octet-stream Size: 741 bytes Desc: not available Url : http://mail.python.org/pipermail/python-3000/attachments/20070825/c87ff631/attachment.obj -------------- next part -------------- A non-text attachment was scrubbed... Name: 2to3_insert_comment.diff Type: application/octet-stream Size: 11031 bytes Desc: not available Url : http://mail.python.org/pipermail/python-3000/attachments/20070825/c87ff631/attachment-0001.obj



More information about the Python-3000 mailing list