ipython / ipython/ipython

Strange inspection from ?? on builtin class Exception's __init__

Open
#10,233 3 comments 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
16.8k
Forks
4.5k
Avg merge
1d 2h
Merged PRs (30d)
6

Description

Was trying to follow up on @Carreau's review on https://github.com/jupyter/nbconvert/pull/521/files to look at the source code that creates the Exception class' `__init__` to see what was going to be inherited.

This didn't work well using ipython magics…

specifically

`?Exception`, `Exception?`, `??Exception`, and `Exception??` (the order seems redundant but it ends up mattering) return

```python
Init signature: Exception(self, /, *args, **kwargs)
Docstring: Common base class for all non-exit exceptions.
Type: type
```

I.e., it didn't print the source, then I tried

`Exception.__init()??` and got a syntax error:

```python
Exception.__init__()??
^
SyntaxError: invalid syntax
```

While `??Exception.__init()`, `??Exception.__init`, and `Exception.__init??`worked without issue (though it still didn't return any source):

```python
Signature: Exception.__init__(self, /, *args, **kwargs)
Call signature: Exception.__init__(*args, **kwargs)
Type: wrapper_descriptor
String form:
Namespace: Python builtin
```

And I checked, the magic does work on some builtins (e.g., `str??`), but seemingly not the Exception class.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.