Fix oinspect TypeError with generic __getattr__ objects; fix test path quoting by Carreau · Pull Request #15246 · ipython/ipython · GitHub
Skip to content
Merged
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
5 changes: 3 additions & 2 deletions IPython/core/oinspect.py
21 changes: 21 additions & 0 deletions docs/source/whatsnew/pr/fix-oinspect-getattr-and-path-spaces.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
Fix oinspect TypeError with objects using generic ``__getattr__``
=================================================================

Objects whose ``__getattr__`` returns something other than ``dict`` for
``__custom_documentations__`` (e.g. polars ``Expr``, which returns a new
``Expr`` for any attribute name) no longer cause a ``TypeError`` when
inspected with ``?`` or :func:`%pinfo`. The lookup is now guarded with
``isinstance(..., dict)``. :ghissue:`15072`

Also fixed an incorrect comparison in the MIME-hook inspection path
(``inspect.Parameter.default`` → ``inspect.Parameter.empty``) that
accidentally relied on a property-object inequality to filter required
parameters.

Fix test failures when IPython source path contains spaces
==========================================================

``test_exit_code_signal`` in :file:`tests/test_interactiveshell.py` now
uses :func:`shlex.quote` when interpolating ``sys.executable`` and the
temporary filename into a shell command string, preventing test failures
on systems where either path contains spaces. :ghissue:`15100`
3 changes: 2 additions & 1 deletion tests/test_interactiveshell.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import asyncio
import ast
import os
import shlex
import signal
import shutil
import sys
Expand Down Expand Up @@ -657,7 +658,7 @@ def test_exit_code_signal(self):
"signal.setitimer(signal.ITIMER_REAL, 0.1)\n"
"time.sleep(1)\n"
)
self.system("%s %s" % (sys.executable, self.fname))
self.system("%s %s" % (shlex.quote(sys.executable), shlex.quote(self.fname)))
self.assertEqual(ip.user_ns["_exit_code"], -signal.SIGALRM)

@onlyif_cmds_exist("csh")
Expand Down
24 changes: 24 additions & 0 deletions tests/test_oinspect.py
Loading