Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Wrong tracebacks : pyzo is affected by ipython issue #13598 #1213

@ysalmon

Description

@ysalmon

My students use Pyzo 4.19.0 (I reproduced in 4.20 too) with IPython 8.27.0 and there is a problem with the display of tracebacks.

If I type this in a tab

def f(x) :
    x = x + 1
    x // 0

then execute (Ctrl+E) and run f(5) in the console, I correctly get

In [2]: f(5)
---------------------------------------------------------------------------
ZeroDivisionError                         Traceback (most recent call last)
File <ipython-input-2-fb48ebfde7ea>:1
----> 1 f(5)

File <tmp 1>:3, in f(x)
      1 def f(x) :
      2     x = x + 1
----> 3     x // 0

ZeroDivisionError: integer division or modulo by zero

However, if I then modify the code of f to

def f(x) :
    x = x + 1
    y = 7
    x // 0

then execute (Ctrl+E) again and run f(5) in the console, I get

In [4]: f(5)
---------------------------------------------------------------------------
ZeroDivisionError                         Traceback (most recent call last)
File <ipython-input-4-fb48ebfde7ea>:1
----> 1 f(5)

File <tmp 1>:4, in f(x)
      0 <Error retrieving source code with stack_data see ipython/ipython#13598>

ZeroDivisionError: integer division or modulo by zero

Sometimes, one does not get this error, but the traceback will claim the exception was thrown on an incorrect line (due to another line having been added since the first version of the code) and this is, legitimately, confusing students (it destroy the whole purpose of a traceback !).

This refers to an issue at IPython that seems convoluted (too much for me).

Restarting the shell allows to eschew this, but this is quite impractical.

Also, on my hoe computer, running Linux, Pyzo 4.19.0 and iPython 8.20.0, things to work well. That is, in the second phase of my example, I get

In [4]: f(5)
---------------------------------------------------------------------------
ZeroDivisionError                         Traceback (most recent call last)
File <ipython-input-4-fb48ebfde7ea>:1
----> 1 f(5)

File <tmp 1>:4, in f(x)
      2 x = x + 1
      3 y = 7
----> 4 x // 0

ZeroDivisionError: integer division or modulo by zero

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions