Skip to content

Prevent CAIT __getattr__ recursion crash in Pyodide when astNode is unavailable - #166

Draft
acbart with Copilot wants to merge 2 commits into
masterfrom
copilot/investigate-pedal-error
Draft

Prevent CAIT __getattr__ recursion crash in Pyodide when astNode is unavailable#166
acbart with Copilot wants to merge 2 commits into
masterfrom
copilot/investigate-pedal-error

Conversation

Copilot AI commented Jul 14, 2026

Copy link
Copy Markdown
Contributor

CAIT usage in Pyodide could trigger a fatal runtime error (Maximum call stack size exceeded) from recursive attribute fallback in CaitNode.__getattr__. This surfaced on CAIT operations like prevent_operation("*") when astNode access failed and re-entered __getattr__ indefinitely.

  • Root-cause hardening in CaitNode.__getattr__

    • Replaced recursive self.astNode resolution with direct object.__getattribute__(self, "astNode").
    • Converted missing/invalid astNode cases into an immediate AttributeError instead of re-entering __getattr__.
  • Error behavior cleanup

    • Standardized the missing-attribute path to raise a descriptive AttributeError for the requested attribute.
  • Regression coverage

    • Added a CAIT node test that deletes astNode and asserts attribute access raises AttributeError (no recursion path).
try:
    ast_node = object.__getattribute__(self, "astNode")
except AttributeError:
    raise AttributeError(f"{type(self).__name__} has no attribute {item!r}")

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants