Bug 1067499 - make build error for misspelled variables more helpful; r=mshal

This commit is contained in:
Nathan Froyd 2014-09-15 13:23:53 -04:00
parent f901a7393c
commit 0436d2dcf8

View File

@ -648,6 +648,8 @@ class BuildReaderError(Exception):
return
if inner.args[0] == 'global_ns':
import difflib
verb = None
if inner.args[1] == 'get_unknown':
verb = 'read'
@ -673,6 +675,11 @@ class BuildReaderError(Exception):
s.write('\n')
s.write(' %s\n' % inner.args[2])
s.write('\n')
close_matches = difflib.get_close_matches(inner.args[2],
VARIABLES.keys(), 2)
if close_matches:
s.write('Maybe you meant %s?\n' % ' or '.join(close_matches))
s.write('\n')
if inner.args[2] in DEPRECATION_HINTS:
s.write('%s\n' %