Repository: asottile/pyupgrade

Issue:
pyupgrade incorrect output
before
```python
expectedResult = (
    ":example.com \u0442\u0435\u0441\u0442 " "\u043d\u0438\u043a\r\n"
).encode("utf-8")
```

expected
```python
b':example.com \xd1\x82\xd0\xb5\xd1\x81\xd1\x82 \xd0\xbd\xd0\xb8\xd0\xba\r\n'
```

or maybe this?
```python
':example.com тест ник\r\n'.encode()
```

actual
```python
expectedResult = ().encode("utf-8")
```

Discussion:

Patch:
diff --git a/pyupgrade.py b/pyupgrade.py
index 8fe8d11..79f2bb2 100644
--- a/pyupgrade.py
+++ b/pyupgrade.py
@@ -2233,7 +2233,7 @@ def _fix_py3_plus(
             victims = _victims(tokens, i, call, gen=False)
             del tokens[victims.starts[0] + 1:victims.ends[-1]]
         elif token.offset in visitor.encode_calls:
-            i = _find_open_paren(tokens, i)
+            i = _find_open_paren(tokens, i + 1)
             call = visitor.encode_calls[token.offset]
             victims = _victims(tokens, i, call, gen=False)
             del tokens[victims.starts[0] + 1:victims.ends[-1]]


Test patch:
diff --git a/tests/default_encoding_test.py b/tests/default_encoding_test.py
index 4385583..f39548d 100644
--- a/tests/default_encoding_test.py
+++ b/tests/default_encoding_test.py
@@ -13,6 +13,14 @@ from pyupgrade import _fix_py3_plus
             'sys.stdout.buffer.write(\n    "a"\n    "b".encode("utf-8")\n)',
             'sys.stdout.buffer.write(\n    "a"\n    "b".encode()\n)',
         ),
+        (
+            'x = (\n'
+            '    "y\\u2603"\n'
+            ').encode("utf-8")\n',
+            'x = (\n'
+            '    "y\\u2603"\n'
+            ').encode()\n',
+        ),
     ),
 )
 def test_fix_encode(s, expected):