mirror of
https://github.com/github/codeql.git
synced 2026-04-26 01:05:15 +02:00
Merge pull request #17822 from github/tausbn/python-more-parser-fixes
Python: A few more parser fixes
This commit is contained in:
@@ -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()
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user