[issue3563] fix_idioms.py generates bad code

2009-10-07 Thread Benjamin Peterson

Benjamin Peterson benja...@python.org added the comment:

Thanks very much for the patch; Committed in r75278.

--
resolution:  - fixed
status: open - closed

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue3563
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue3563] fix_idioms.py generates bad code

2009-10-06 Thread Joe Amenta

Joe Amenta ament...@msu.edu added the comment:

Attached a patch that implements more thoroughly what appears to be the
intended behavior.

--
nosy: +joe.amenta
Added file: http://bugs.python.org/file15061/fix_idioms.patch

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue3563
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue3563] fix_idioms.py generates bad code

2009-10-06 Thread Joe Amenta

Changes by Joe Amenta ament...@msu.edu:


Removed file: http://bugs.python.org/file15061/fix_idioms.patch

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue3563
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue3563] fix_idioms.py generates bad code

2009-10-06 Thread Joe Amenta

Joe Amenta ament...@msu.edu added the comment:

Missed a paren in the last one... re-uploading it.

--
Added file: http://bugs.python.org/file15062/fix_idioms.patch

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue3563
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue3563] fix_idioms.py generates bad code

2009-10-06 Thread Benjamin Peterson

Changes by Benjamin Peterson benja...@python.org:


--
assignee: collinwinter - benjamin.peterson

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue3563
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue3563] fix_idioms.py generates bad code

2008-12-08 Thread Armin Ronacher

Armin Ronacher [EMAIL PROTECTED] added the comment:

I would drop the prefix in that case or attach it to the sorted() call.

So from this code:

x = foo()
# perform sorting
x.sort()

to

# perform sorting
x = sorted(foo())

Makes more sense than sticking it after the sorted() call like it
happens currently.  This should also fix the problem with outdented
statements such as except/finally.

--
nosy: +aronacher

___
Python tracker [EMAIL PROTECTED]
http://bugs.python.org/issue3563
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue3563] fix_idioms.py generates bad code

2008-08-22 Thread Terry J. Reedy

Terry J. Reedy [EMAIL PROTECTED] added the comment:

Why is the statement, whatever it is, even being touched?
Would not the same problem arise with any following outdented line?

IOW, why not delete that pair of lines from fix_idioms.py?
Does that break anything else in test_fixers?

--
nosy: +tjreedy

___
Python tracker [EMAIL PROTECTED]
http://bugs.python.org/issue3563
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue3563] fix_idioms.py generates bad code

2008-08-16 Thread Ali Polatel

New submission from Ali Polatel [EMAIL PROTECTED]:

fix_idioms.py generates bad code for conversions in try/except blocks.
Example:
s=(1, 2, 3)
try:
t = list(s)
t.sort()
except TypeError:
pass

fix_idioms.py generates this diff:
--- test.py (original)
+++ test.py (refactored)
@@ -7,8 +7,7 @@
 
 s=(1, 2, 3)
 try:
-t = list(s)
-t.sort()
-except TypeError:
+t = sorted(s)
+except TypeError:
 pass
 
except TypeError is indented wrongly.

--
assignee: collinwinter
components: 2to3 (2.x to 3.0 conversion tool)
messages: 71199
nosy: collinwinter, hawking
severity: normal
status: open
title: fix_idioms.py generates bad code

___
Python tracker [EMAIL PROTECTED]
http://bugs.python.org/issue3563
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue3563] fix_idioms.py generates bad code

2008-08-16 Thread Benjamin Peterson

Benjamin Peterson [EMAIL PROTECTED] added the comment:

It's due to these lines in fix_idioms:

if next_stmt:
 next_stmt[0].set_prefix(sort_stmt.get_prefix())

I'm not sure what the correct way to deal with this is. Anyway I'm
attaching a test case.

--
keywords: +patch
nosy: +benjamin.peterson
Added file: http://bugs.python.org/file11124/indentation_test.diff

___
Python tracker [EMAIL PROTECTED]
http://bugs.python.org/issue3563
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com