Skip to content

Commit acbafe4

Browse files
committed
don't try to be too clever with exceptions: if a global name raises an exception when evaluated, just color it as None
1 parent 983824a commit acbafe4

2 files changed

Lines changed: 1 addition & 16 deletions

File tree

Lib/_pyrepl/fancycompleter.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ def global_matches(self, text):
117117
try:
118118
values.append(eval(name, self.namespace))
119119
except Exception as exc:
120-
values.append(exc)
120+
values.append(None)
121121
if self.config.use_colors and names:
122122
return self.colorize_matches(names, values)
123123
return names

Lib/test/test_pyrepl/test_fancycompleter.py

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -128,21 +128,6 @@ def test_complete_global_colored_exception(self):
128128
' '
129129
])
130130

131-
def test_complete_global_exception(self):
132-
def rlcompleter_global_matches(self, text):
133-
return ['trigger_exception!', 'nameerror', 'valid']
134-
135-
self.mock_patch.setattr(rlcompleter.Completer, 'global_matches',
136-
rlcompleter_global_matches)
137-
138-
compl = Completer({'valid': 42}, ColorConfig)
139-
self.assertEqual(compl.global_matches(""), [
140-
"\x1b[000;00m\x1b[31;01mnameerror\x1b[00m",
141-
"\x1b[001;00m\x1b[31;01mtrigger_exception!\x1b[00m",
142-
"\x1b[002;00m\x1b[33;01mvalid\x1b[00m",
143-
" ",
144-
])
145-
146131
def test_color_for_obj(self):
147132
class Config(ColorConfig):
148133
color_by_type = {}

0 commit comments

Comments
 (0)