Fix oinspect TypeError with generic __getattr__ and test path spaces#15246
Open
Carreau wants to merge 1 commit into
Open
Fix oinspect TypeError with generic __getattr__ and test path spaces#15246Carreau wants to merge 1 commit into
Carreau wants to merge 1 commit into
Conversation
…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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR fixes multiple issues in IPython's object inspection and test infrastructure:
Summary
Fixes a
TypeErrorthat occurs when inspecting objects with generic__getattr__implementations (like polarsExpr), 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: Addedisinstance(..., dict)guard before calling.get()on__custom_documentations__attribute. This preventsTypeErrorwhen__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.defaulttoparameter.default is inspect.Parameter.emptyto 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_signalintest_interactiveshell.pyto useshlex.quote()when interpolatingsys.executableand 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
__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.is) withinspect.Parameter.emptysentinel, which is the correct way to detect parameters without defaults.shlex.quote()for proper shell escaping of paths with special characters.https://claude.ai/code/session_019BzV7TkK7LXZKuWdusfqM6