From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2178) id 1179A3858D37; Thu, 3 Nov 2022 11:28:39 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 1179A3858D37 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1667474919; bh=mhIzU43vboVSKzOLwsLiyJqE/DpUPjjGmjw7njZVT/s=; h=From:To:Subject:Date:From; b=vIURxvNrEa8kVpBfPMVdnPVsEYLTPmnOgqb+HInm9cvOcMSWPBDOHyrHFoZSnpo5W 3GCcfALq9vDpAYxj8j+5/k8fdIaOEt0uk7W+0G+t/6Ln+hFxWN3Fdby8LVwPmi1lN8 5tR6OYpzQOiTundPMiCSwTh6hlWikMEnUvez6M+Y= Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: Florian Weimer To: glibc-cvs@sourceware.org Subject: [glibc] scripts/glibcelf.py: Properly report parsing failures X-Act-Checkin: glibc X-Git-Author: Florian Weimer X-Git-Refname: refs/heads/master X-Git-Oldrev: ee1ada1bdb8074de6e1bdc956ab19aef7b6a7872 X-Git-Newrev: d33705c0b020632274318323931695a99753b5be Message-Id: <20221103112839.1179A3858D37@sourceware.org> Date: Thu, 3 Nov 2022 11:28:39 +0000 (GMT) List-Id: https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=d33705c0b020632274318323931695a99753b5be commit d33705c0b020632274318323931695a99753b5be Author: Florian Weimer Date: Thu Nov 3 12:24:17 2022 +0100 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 Diff: --- scripts/glibcelf.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/glibcelf.py b/scripts/glibcelf.py index 420cb21943..59aab56ecf 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):