diff --git a/pyupgrade/_plugins/six_calls.py b/pyupgrade/_plugins/six_calls.py index 3fd30cd7..1bb50fae 100644 --- a/pyupgrade/_plugins/six_calls.py +++ b/pyupgrade/_plugins/six_calls.py @@ -51,7 +51,7 @@ 'assertRegex': '{args[0]}.assertRegex({rest})', } SIX_INT2BYTE_TMPL = 'bytes(({args[0]},))' -RAISE_FROM_TMPL = 'raise {args[0]} from {rest}' +RAISE_FROM_TMPL = 'raise {args[0]} from {args[1]}' RERAISE_TMPL = 'raise' RERAISE_2_TMPL = 'raise {args[1]}.with_traceback(None)' RERAISE_3_TMPL = 'raise {args[1]}.with_traceback({args[2]})' diff --git a/tests/features/six_test.py b/tests/features/six_test.py index 2b87b8ff..e1f6cd88 100644 --- a/tests/features/six_test.py +++ b/tests/features/six_test.py @@ -126,6 +126,16 @@ def test_fix_six_noop(s): 'six.raise_from(exc, exc_from)\n', 'raise exc from exc_from\n', ), + pytest.param( + 'six.raise_from(\n' + ' e,\n' + ' f,\n' + ')', + + 'raise e from f', + + id='six raise_from across multiple lines', + ), ( 'six.reraise(tp, exc, tb)\n', 'raise exc.with_traceback(tb)\n',