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
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
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
___
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
Changes by Benjamin Peterson benja...@python.org:
--
assignee: collinwinter - benjamin.peterson
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue3563
___
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()
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?
--
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
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: