Skip to content

Commit 6f3b7ee

Browse files
authored
Don't treat internal settings as valid suggestions. NFC (#16373)
1 parent c102a42 commit 6f3b7ee

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

tests/test_other.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6633,7 +6633,7 @@ def test_dash_s_typo(self):
66336633
self.assertContained('did you mean one of DISABLE_EXCEPTION_CATCHING', stderr)
66346634
# no suggestions
66356635
stderr = self.expect_fail([EMCC, test_file('hello_world.c'), '-sCHEEZ'])
6636-
self.assertContained("perhaps a typo in emcc\'s -s X=Y notation?", stderr)
6636+
self.assertContained("perhaps a typo in emcc\'s -sX=Y notation?", stderr)
66376637
self.assertContained('(see src/settings.js for valid values)', stderr)
66386638
# suggestions do not include renamed legacy settings
66396639
stderr = self.expect_fail([EMCC, test_file('hello_world.c'), '-sZBINARYEN_ASYNC_COMPILATION'])

tools/settings.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@
8383

8484
class SettingsManager:
8585
attrs = {}
86-
allowed_settings = []
86+
allowed_settings = set()
8787
legacy_settings = {}
8888
alt_names = {}
8989
internal_settings = set()
@@ -138,7 +138,7 @@ def keys(self):
138138
def limit_settings(self, allowed):
139139
self.allowed_settings.clear()
140140
if allowed:
141-
self.allowed_settings.extend(allowed)
141+
self.allowed_settings.update(allowed)
142142

143143
def __getattr__(self, attr):
144144
if self.allowed_settings:
@@ -173,12 +173,13 @@ def __setattr__(self, name, value):
173173

174174
if name not in self.attrs:
175175
msg = "Attempt to set a non-existent setting: '%s'\n" % name
176-
suggestions = difflib.get_close_matches(name, list(self.attrs.keys()))
176+
valid_keys = set(self.attrs.keys()).difference(self.internal_settings)
177+
suggestions = difflib.get_close_matches(name, valid_keys)
177178
suggestions = [s for s in suggestions if s not in self.legacy_settings]
178179
suggestions = ', '.join(suggestions)
179180
if suggestions:
180181
msg += ' - did you mean one of %s?\n' % suggestions
181-
msg += " - perhaps a typo in emcc's -s X=Y notation?\n"
182+
msg += " - perhaps a typo in emcc's -sX=Y notation?\n"
182183
msg += ' - (see src/settings.js for valid values)'
183184
exit_with_error(msg)
184185

0 commit comments

Comments
 (0)