]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
scripts/glibcelf.py: Properly report <elf.h> parsing failures
authorFlorian Weimer <fweimer@redhat.com>
Thu, 3 Nov 2022 11:24:17 +0000 (12:24 +0100)
committerFlorian Weimer <fweimer@redhat.com>
Thu, 3 Nov 2022 11:24:17 +0000 (12:24 +0100)
Without this change, parse failures result in an exception:

Traceback (most recent call last):
  File "tst-glibcelf.py", line 23, in <module>
    import glibcelf
  File "/path/to/git/scripts/glibcelf.py", line 226, in <module>
    _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

index 420cb21943b28bba2681e1e125649cfa4e4474d0..59aab56ecf9deb3e6ef8cb1a7c2d9c238604fd56 100644 (file)
@@ -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):