Skip to content

Commit 5ac39e1

Browse files
clear builtins in suggestion when deleting
1 parent 86513f6 commit 5ac39e1

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

Lib/traceback.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
import tokenize
1212
import io
1313
import _colorize
14+
import dis
1415

1516
from contextlib import suppress
1617

@@ -1677,8 +1678,9 @@ def _compute_suggestion_error(exc_value, tb, wrong_name):
16771678
d = (
16781679
list(frame.f_locals)
16791680
+ list(frame.f_globals)
1680-
+ list(frame.f_builtins)
16811681
)
1682+
if not dis.opname[frame.f_code.co_code[frame.f_lasti]].startswith('DELETE_'):
1683+
d += list(frame.f_builtins)
16821684
d = [x for x in d if isinstance(x, str)]
16831685

16841686
# Check first if we are in a method and the instance

0 commit comments

Comments
 (0)