Skip to content

Fix oinspect TypeError with generic __getattr__ and test path spaces#15246

Open
Carreau wants to merge 1 commit into
mainfrom
claude/amazing-wright-zhq3c
Open

Fix oinspect TypeError with generic __getattr__ and test path spaces#15246
Carreau wants to merge 1 commit into
mainfrom
claude/amazing-wright-zhq3c

Conversation

@Carreau

@Carreau Carreau commented Jun 8, 2026

Copy link
Copy Markdown
Member

This PR fixes multiple issues in IPython's object inspection and test infrastructure:

Summary

Fixes a TypeError that occurs when inspecting objects with generic __getattr__ implementations (like polars Expr), corrects an incorrect parameter comparison in the MIME-hook inspection path, and resolves test failures on systems with spaces in file paths.

Key Changes

  • Fix generic __getattr__ handling in oinspect: Added isinstance(..., dict) guard before calling .get() on __custom_documentations__ attribute. This prevents TypeError when __getattr__ returns non-dict objects for any attribute name (regression test for issue oinspect throws TypeError when parsing incomplete code line involving polars.expr.expr #15072).

  • Fix MIME-hook parameter filtering: Corrected comparison from parameter.default != inspect.Parameter.default to parameter.default is inspect.Parameter.empty to properly identify required parameters. The previous comparison was incorrect and accidentally relied on property-object inequality.

  • Fix test path handling with spaces: Updated test_exit_code_signal in test_interactiveshell.py to use shlex.quote() when interpolating sys.executable and temporary filename into shell command strings, preventing test failures on systems where paths contain spaces (issue Test failures when path to IPython source code contains spaces #15100).

Implementation Details

  • The __getattr__ fix is minimal and defensive: it checks the type before attempting dict operations, allowing inspection to gracefully handle objects with non-standard attribute access patterns.
  • The parameter comparison fix uses identity comparison (is) with inspect.Parameter.empty sentinel, which is the correct way to detect parameters without defaults.
  • The test fix uses standard library shlex.quote() for proper shell escaping of paths with special characters.

https://claude.ai/code/session_019BzV7TkK7LXZKuWdusfqM6

…h quoting

oinspect: guard __custom_documentations__ lookup with isinstance(dict) so
objects like polars Expr (which return self for any attribute access via
__getattr__) no longer raise TypeError when inspected with ?. Fixes #15072.

oinspect: fix inspect.Parameter.empty comparison in MIME-hook path; the
previous code accidentally compared against the property descriptor object
rather than the sentinel, making the required-parameter filter a no-op.

test_interactiveshell: wrap sys.executable and self.fname in shlex.quote()
so test_exit_code_signal survives when the source path contains spaces.
Fixes #15100.

https://claude.ai/code/session_01VPnGTgifZ8HMAfiqEVftjj
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