Skip to content

Commit

Permalink
Enhance stacktrace lines matching
Browse files Browse the repository at this point in the history
  • Loading branch information
gi0baro committed Mar 20, 2024
1 parent 7fb7fb7 commit f72e3f7
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
2 changes: 1 addition & 1 deletion renoir/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ def __init__(self, parser_ctx, exc_type, exc_value, tb):
self.file_path, self.lineno = self.match_template(writer_lineno)

def match_template(self, writer_lineno):
element = self.lines[writer_lineno - 1]
try:
element = self.lines[writer_lineno - 1]
reference = (element[0], element[1])
except Exception:
reference = (self.parser_ctx.name, ('<unknown>', 'unknown'))
Expand Down
8 changes: 7 additions & 1 deletion renoir/parsing/contents.py
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,8 @@ def __render__(self, parser):

def __reference__(self):
rv = []
for element in self.value:
stack = self.value if not self._evicted else []
for element in stack:
rv.extend(element.__reference__())
return rv

Expand All @@ -333,6 +334,11 @@ def __render__(self, parser):
v = to_unicode(self.render_value())
return f'\n{parser.writer}.{self._writer_method}({v})' if v else ''

def __reference__(self):
if not to_unicode(self.render_value()):
return []
return super().__reference__()


class PlainNode(WriterNode):
__slots__ = ['value', 'indent', 'source', 'lines']
Expand Down

0 comments on commit f72e3f7

Please sign in to comment.