Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/topic/bbannier/format-no-non-err…
Browse files Browse the repository at this point in the history
…or-children'
  • Loading branch information
bbannier committed Dec 9, 2024
2 parents becb994 + cfc00bb commit 3d4d6b9
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 2 deletions.
19 changes: 19 additions & 0 deletions CHANGES
Original file line number Diff line number Diff line change
@@ -1,3 +1,22 @@
1.2.9-56 | 2024-12-09 14:00:22 +0100

* Fix formatting of nodes with no non-error children (Benjamin Bannier, Corelight)

When formatting a `Node`'s child we allowed omitting passing in of the
child to format. In that case the user would pass a `None` child and we
would attempt to default to formatting the next non-error child. The
helper we used to get that child could still return `None` (in case
there were only error children remaining, or on incorrect use of the
function when the node had no children), but we never handled that case;
instead we would have surfaced an `AttributeError` like

```
AttributeError: 'NoneType' object has no attribute 'prev_error_siblings'
```

With this path we explicitly skip any child formatting if we found no
child to be formatted.

1.2.9-54 | 2024-12-09 14:00:03 +0100

* Bump pre-commit hooks (Benjamin Bannier, Corelight)
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.2.9-54
1.2.9-56
2 changes: 1 addition & 1 deletion zeekscript/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"""Wrapper around more low-level tests."""

__version__ = "1.2.9-54"
__version__ = "1.2.9-56"
__all__ = [
"Formatter",
"Script",
Expand Down
2 changes: 2 additions & 0 deletions zeekscript/formatter.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,8 @@ def _format_child_impl(self, node, indent, hints=None):
def _format_child(self, child=None, indent=False, hints=None):
if child is None:
child = self._next_child()
if child is None:
return

# XXX Pretty subtle that we handle the child's surrounding context here,
# in the parent. Might have to refactor in the future.
Expand Down

0 comments on commit 3d4d6b9

Please sign in to comment.