Stop at exception in my, not library code

后端 未结 5 2211
故里飘歌
故里飘歌 2021-02-14 22:33

I\'m developing an app using a Python library urllib and it is sometimes rising exceptions due to not being able to access an URL.

However, the exception is

5条回答
  •  臣服心动
    2021-02-14 23:21

    pdb has only incremental frame positioning (moving up or down the list of frames).

    To get the feature you want, you can try trepan (github repository). It has an IPython extension here. You then use the command frame -1 once the exception shows up:

    Frame (absolute frame positioning)

    frame [thread-Name*|*thread-number] [frame-number]

    Change the current frame to frame frame-number if specified, or the current frame, 0, if no frame number specified.

    If a thread name or thread number is given, change the current frame to a frame in that thread. Dot (.) can be used to indicate the name of the current frame the debugger is stopped in.

    A negative number indicates the position from the other or least-recently-entered end. So frame -1 moves to the oldest frame, and frame 0 moves to the newest frame. Any variable or expression that evaluates to a number can be used as a position, however due to parsing limitations, the position expression has to be seen as a single blank-delimited parameter. That is, the expression (5*3)-1 is okay while (5 * 3) - 1) isn’t.

    Once you are in the desired frame, you can use edit to modify your code.

    You may find the command backtrace useful too as it gives a stack trace with the less recent call at the bottom.

    trepan depends on uncompyle6 available here.

    pydb provides a similar feature but was unfortunately not ported to Python3.

    Otherwise, you may decide to be patient and wait for improvements. In IPython/core/debugger.py:

    """
    Pdb debugger class.
    
    Modified from the standard pdb.Pdb class to avoid including readline, so that
    the command line completion of other programs which include this isn't damaged.
    
    In the future, this class will be expanded with improvements over the standard pdb.
    [...]
    """
    

提交回复
热议问题