MCPcopy Create free account
hub / github.com/emscripten-core/emscripten / __setattr__

Method __setattr__

tools/settings.py:375–410  ·  view source on GitHub ↗
(self, name, value)

Source from the content-addressed store, hash-verified

373 raise AttributeError(f"no such setting: '{attr}'")
374
375 def __setattr__(self, name, value):
376 if self.allowed_settings:
377 assert name in self.allowed_settings, f"internal error: attempt to write setting '{name}' while in limited settings mode"
378
379 if name == 'STRICT' and value:
380 for a in self.legacy_settings:
381 self.attrs.pop(a, None)
382
383 if name in self.legacy_settings:
384 # TODO(sbc): Rather then special case this we should have STRICT turn on the
385 # legacy-settings warning below
386 if self.attrs['STRICT']:
387 exit_with_error('legacy setting used in strict mode: %s', name)
388 fixed_values, error_message = self.legacy_settings[name]
389 if fixed_values and value not in fixed_values:
390 exit_with_error(f'invalid command line setting `-s{name}={value}`: {error_message}')
391 diagnostics.warning('legacy-settings', 'use of legacy setting: %s (%s)', name, error_message)
392
393 if name in self.alt_names:
394 alt_name = self.alt_names[name]
395 self.attrs[alt_name] = value
396
397 if name not in self.attrs:
398 msg = "Attempt to set a non-existent setting: '%s'\n" % name
399 valid_keys = set(self.attrs.keys()).difference(self.internal_settings)
400 suggestions = difflib.get_close_matches(name, valid_keys)
401 suggestions = [s for s in suggestions if s not in self.legacy_settings]
402 suggestions = ', '.join(suggestions)
403 if suggestions:
404 msg += ' - did you mean one of %s?\n' % suggestions
405 msg += " - perhaps a typo in emcc's -sX=Y notation?\n"
406 msg += ' - (see src/settings.js for valid values)'
407 exit_with_error(msg)
408
409 self.check_type(name, value)
410 self.attrs[name] = value
411
412 def check_type(self, name, value):
413 # These settings have a variable type so cannot be easily type checked.

Callers

nothing calls this directly

Calls 7

check_typeMethod · 0.95
exit_with_errorFunction · 0.85
warningMethod · 0.80
keysMethod · 0.65
setFunction · 0.50
popMethod · 0.45
joinMethod · 0.45

Tested by

no test coverage detected