pydata-book icon indicating copy to clipboard operation
pydata-book copied to clipboard

The problem of chapter B5.1

Open MaxforCherubim opened this issue 10 months ago • 1 comments

The code is wrong.

from IPython.core.debugger import Pdb

def set_trace():
    Pdb(.set_trace(sys._getframe().f_back)

def debug(f, *args, **kwargs):
    pdb = Pdb()
    return pdb.runcall(f, *args, **kwargs)

It should be

from IPython.core.debugger import Pdb
import sys

def set_trace():
        Pdb.set_trace(sys._getframe().f_back)

def debug(f, *arg, **kwargs):
        pdb = Pdb()
        return pdb.runcall(f, *args, **kwargs)

But even the code get repaired, there still exist a AttributeError AttributeError: 'frame' object has no attribute 'initial_frame'

MaxforCherubim avatar Apr 19 '24 12:04 MaxforCherubim

Thanks -- I will have a closer look at updating this for the latest version of Python

wesm avatar Jul 15 '24 21:07 wesm