Skip to content
Closed
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
@@ -0,0 +1,3 @@
Fix potential memory leak in c-field representation of Python objects
Copy link
Member

Choose a reason for hiding this comment

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

This doesn't seem related to the actual change. Is this from a different PR?


Resolved a memory leak issue in the `_PyObject_CAST` macro by ensuring proper casting and handling of c-fields. This fix improves memory management and prevents unintended behavior in CPython's internal object representation.
Copy link
Member

Choose a reason for hiding this comment

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

There's two blurb files, go ahead and delete one of them.

Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Fix potential memory leak in c-field representation of Python objects

Resolved a memory leak issue in the `_PyObject_CAST` macro by ensuring proper casting and handling of c-fields. This fix improves memory management and prevents unintended behavior in CPython's internal object representation.
7 changes: 6 additions & 1 deletion Tools/peg_generator/pegen/grammar.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,12 @@ class GrammarError(Exception):
class GrammarVisitor:
def visit(self, node: Any, *args: Any, **kwargs: Any) -> Any:
"""Visit a node."""
method = "visit_" + node.__class__.__name__
node_cls = node.__class__.__name__
Copy link
Member

Choose a reason for hiding this comment

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

Use type(), not __class__.

method = f"visit_{node_cls}"
if len(node.__class__.__name__) == 1:
method = f"visit_single_{node_cls}"
elif len(node.__class__.__name__) > 1:
method = f"visit_multi_{node_cls}"
visitor = getattr(self, method, self.generic_visit)
return visitor(node, *args, **kwargs)

Expand Down
Loading