From d33705c0b020632274318323931695a99753b5be Mon Sep 17 00:00:00 2001 From: Florian Weimer Date: Thu, 3 Nov 2022 12:24:17 +0100 Subject: scripts/glibcelf.py: Properly report parsing failures Without this change, parse failures result in an exception: Traceback (most recent call last): File "tst-glibcelf.py", line 23, in import glibcelf File "/path/to/git/scripts/glibcelf.py", line 226, in _elf_h = _parse_elf_h() File "/path/to/git/scripts/glibcelf.py", line 221, in _parse_elf_h result = glibcpp.macro_eval(glibcpp.macro_definitions(tokens), reporter) File "/path/to/git/scripts/glibcpp.py", line 379, in macro_eval reporter.error(md.line, 'macro {} redefined'.format(md.name)) File "/path/to/git/scripts/glibcelf.py", line 214, in error errors += 1 UnboundLocalError: local variable 'errors' referenced before assignment --- scripts/glibcelf.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/glibcelf.py b/scripts/glibcelf.py index 420cb21..59aab56 100644 --- a/scripts/glibcelf.py +++ b/scripts/glibcelf.py @@ -211,7 +211,7 @@ def _parse_elf_h(): self.errors = 0 def error(self, line, message): - errors += 1 + self.errors += 1 print('{}:{}: error: {}'.format(path, line, message)) def note(self, line, message): -- cgit v1.1