Merge pull request #17822 from github/tausbn/python-more-parser-fixes

Python: A few more parser fixes
This commit is contained in:
Taus
2024-10-30 13:47:10 +01:00
committed by GitHub
15 changed files with 51603 additions and 53873 deletions

View File

@@ -97,9 +97,27 @@ class AstDumper(object):
class StdoutLogger(logging.Logger):
error_count = 0
def log(self, level, fmt, *args):
sys.stdout.write(fmt % args + "\n")
def info(self, fmt, *args):
self.log(logging.INFO, fmt, *args)
def warn(self, fmt, *args):
self.log(logging.WARN, fmt, *args)
self.error_count += 1
def error(self, fmt, *args):
self.log(logging.ERROR, fmt, *args)
self.error_count += 1
def had_errors(self):
return self.error_count > 0
def reset_error_count(self):
self.error_count = 0
def old_parser(inputfile, logger):
mod = PythonSourceModule(None, inputfile, logger)
logger.close()

View File

@@ -440,7 +440,7 @@ def concatenate_stringparts(stringparts, logger):
try:
return "".join(decode_str(stringpart.s) for stringpart in stringparts)
except Exception as ex:
logger.error("Unable to concatenate string %s getting error %s", stringparts, ex)
logger.error("Unable to concatenate string {} getting error {}".format(stringparts, ex))
return stringparts[0].s