Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle case inspect fails on repl-defined objects #2037

Merged
merged 2 commits into from Mar 8, 2022
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Expand Up @@ -23,6 +23,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Fixed Pretty measure not respecting expand_all https://github.com/Textualize/rich/issues/1998
- Collapsed definitions for single-character spinners, to save memory and reduce import time.
- Fix print_json indent type in __init__.py
- Fix error when inspecting object defined in REPL https://github.com/Textualize/rich/pull/2037

### Changed

Expand Down
3 changes: 2 additions & 1 deletion rich/_inspect.py
Expand Up @@ -98,7 +98,8 @@ def _get_signature(self, name: str, obj: Any) -> Optional[Text]:
source_filename: Optional[str] = None
try:
source_filename = getfile(obj)
except TypeError:
except (OSError, TypeError):
# OSError is raised if obj has no source file, e.g. when defined in REPL.
pass

callable_name = Text(name, style="inspect.callable")
Expand Down