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

Problem with ipython 8.1.0 #28

Closed
aroberge opened this issue Feb 27, 2022 · 3 comments
Closed

Problem with ipython 8.1.0 #28

aroberge opened this issue Feb 27, 2022 · 3 comments

Comments

@aroberge
Copy link
Contributor

aroberge commented Feb 27, 2022

In [6]: a = [1, 2, 3]

In [7]: a[3]
venv-friendly-ipython\lib\site-packages\friendly_traceback\runtime_errors\index_error.py:110 index_out_of_range
    'node is not Subscript in index_out_of_range().' (str) len=46
venv-friendly-ipython\lib\site-packages\friendly_traceback\info_specific.py:90 _index_error
    str(value): 'list index out of range' (str) len=23
venv-friendly-ipython\lib\site-packages\friendly_traceback\utils.py:64 RuntimeMessageParser._get_cause


Traceback (most recent call last):
  Code block [7], line 1, in <cell line: 1>
    a[3]
IndexError: list index out of range

Friendly-traceback does not know the cause of this error.

When running this example using simply friendly, we have:

type(tb_data.node) = <class 'ast.Subscript'>

When running from withing IPython, we get <class 'NoneType'> instead.

@aroberge
Copy link
Contributor Author

Doing some diagnostics, in friendly_traceback/core.py, near line 272:

        node_info = self.records[-1].node_info  # noqa
        print(f"{node_info=}")
        if node_info:
            self.node, _ignore, self.node_text = node_info
            print(f"{self.node=}, {_ignore=}, {self.node_text=}")

Using simply friendly/friendly_traceback we get

node_info=(<ast.Subscript object at 0x000001E3FCA68460>, (0, 4), 'a[3]')
self.node=<ast.Subscript object at 0x000001E3FCA68460>, _ignore=(0, 4), self.node_text='a[3]'

However, when using within IPython, we get

node_info=(None, (0, 4), 'a[3]')
self.node=None, _ignore=(0, 4), self.node_text='a[3]'

@aroberge
Copy link
Contributor Author

One more example. When running simply IPython with the following example:

In [1]: a = [1, 2, 3]

In [2]: a[0] + a[3]
---------------------------------------------------------------------------
IndexError                                Traceback (most recent call last)
Input In [2], in <cell line: 1>()
----> 1 a[0] + a[3]

There is no highlighting of a[3].

Time for some screen captures.
image

image

@aroberge
Copy link
Contributor Author

This now appears to be fixed.

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

No branches or pull requests

1 participant