Skip to content

IPython ignore chained exception when using %xmode plain #11995

Closed

Description

@impact27

IPython ignores chained exception when using%xmode plain:
ipython:

In [2]: %xmode plain                                                                                 
Exception reporting mode: Plain

In [3]: try: 
   ...:     v = {}['a'] 
   ...: except KeyError as e: 
   ...:     raise ValueError('failed') from e 
   ...:                                                                                              
Traceback (most recent call last):
  File "<ipython-input-3-944ebf5453bb>", line 4, in <module>
    raise ValueError('failed') from e
ValueError: failed

python:

>>> try:
...     v = {}['a']
... except KeyError as e:
...     raise ValueError('failed') from e
... 
Traceback (most recent call last):
  File "<stdin>", line 2, in <module>
KeyError: 'a'

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "<stdin>", line 4, in <module>
ValueError: failed

Activity

  1. Carreau commented on Dec 1, 2019

    @Carreau
    Member

    Hum, that appear to be on purpose; and it's not going to be an easy change.

  2. impact27 commented on Dec 1, 2019

    @impact27
    ContributorAuthor

    Hum, that appear to be on purpose; and it's not going to be an easy change.

    I am not sure what the rationale of this being on purpose is. Why shouldn't 'Plain' follow https://www.python.org/dev/peps/pep-3134/? I can understang e.g. for 'Minimal'.

  3. Carreau commented on Dec 1, 2019

    @Carreau
    Member

    I'm not sure, this is pretty old code, but Plain appear to go through a path that only print the last exception.

    I agree with you that there does not appear to be any reason not to print the chain, I'm just saying that the current code appear to have been implemented in a way that assume it would not have to do it.

  4. impact27 commented on Dec 1, 2019

    @impact27
    ContributorAuthor

    Ok, I opened a PR that could solve it: #11999

  5. added this to the 7.11 milestone on Dec 9, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions