Skip to content

Commit 0d46cba

Browse files
authored
Merge pull request #897 from asottile/slight-improvement
slight improvement to except fix
2 parents 34de3a0 + 72acd1c commit 0d46cba

File tree

1 file changed

+1
-4
lines changed

1 file changed

+1
-4
lines changed

pyupgrade/_plugins/exceptions.py

+1-4
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,7 @@ def _fix_except(
5252
start = find_op(tokens, except_index, '(')
5353
func_args, end = parse_call_args(tokens, start)
5454

55-
# save the exceptions and remove the block
5655
arg_strs = [arg_str(tokens, *arg) for arg in func_args]
57-
del tokens[start:end]
5856

5957
# rewrite the block without dupes
6058
args = []
@@ -74,8 +72,7 @@ def _fix_except(
7472
else:
7573
joined = unique_args[0]
7674

77-
new = Token('CODE', joined)
78-
tokens.insert(start, new)
75+
tokens[start:end] = [Token('CODE', joined)]
7976

8077

8178
def _get_rewrite(

0 commit comments

Comments
 (0)