Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -90,16 +90,12 @@ def parse_stack_trace_line(self, line: str) -> Optional[BugPathEvent]:
return None

file_path = file_match.group('path')
if file_path and os.path.exists(file_path):
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

By removing file_path check of None, it might have a chance that get_or_create_file gets invoked with a None as first argument (file_path). This might cause undefined behaviour (or a big error stack). I think a None check would be beneficial here.

col = file_match.group('column')
return BugPathEvent(
line.rstrip(),
get_or_create_file(
os.path.abspath(file_path), self._file_cache),
int(file_match.group('line')),
int(col) if col else 0)

return None
col = file_match.group('column')
return BugPathEvent(
line.rstrip(),
get_or_create_file(os.path.abspath(file_path), self._file_cache),
int(file_match.group('line')),
int(col) if col else 0)

def create_report(
self,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,8 +137,9 @@ def __get_report_hash_context_free(report: Report) -> List[str]:

if line_content == '' and \
not os.path.isfile(report.file.original_path):
LOG.error("Failed to include source line in the report hash.")
LOG.error('%s does not exists!', report.file.original_path)
LOG.warning(
"Failed to include source line in the report hash. "
'%s does not exist!', report.file.original_path)

return [
report.file.name,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ def get_line(file_path: str, line_no: int, errors: str = 'ignore') -> str:
with open(file_path, mode='r', encoding='utf-8', errors=errors) as f:
return get_linef(f, line_no)
except IOError:
LOG.error("Failed to open file %s", file_path)
LOG.warning("Failed to open file %s", file_path)
return ''


Expand Down