Skip to content

Use guarded_eval for the callable in python_func_kw_matches - #15338

Open
sage-mode-hunter wants to merge 1 commit into
ipython:mainfrom
sage-mode-hunter:func-kw-guarded-eval
Open

Use guarded_eval for the callable in python_func_kw_matches#15338
sage-mode-hunter wants to merge 1 commit into
ipython:mainfrom
sage-mode-hunter:func-kw-guarded-eval

Conversation

@sage-mode-hunter

Copy link
Copy Markdown
Contributor

Keyword completion is the one evaluation site left in the completer that never consulted the policy:

  • python_func_kw_matches resolves the callable with a bare eval(), while global_matches, _evaluate_expr and the dict key matcher all go through guarded_eval
  • python_func_kw_matcher is in the default matcher list, so obj.attr( plus Tab runs a property getter or a custom __getattr__ with no cell executed
  • guarded_eval refuses that same attribute access under the default limited policy, so the two currently disagree about the same expression

Routed it through the EvaluationContext the sibling matchers already build. Plain functions and ordinary methods still complete their keywords, and the eager behaviour stays available under evaluation="unsafe".

@krassowski krassowski left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGMT, thank you!

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