Coder Social home page Coder Social logo

gaogaotiantian / wthell Goto Github PK

View Code? Open in Web Editor NEW
37.0 3.0 2.0 31 KB

wthell is a debugging tool for python to interactively check frame stack when your code quit unexpectedly

License: Apache License 2.0

Makefile 5.24% Python 94.76%
python debugging debugging-tools traceback

wthell's Introduction

wthell

wthell is a debugging tool for python to interactively check frame stack when your code did something unexpectedly

Install

You can install wthell from pip

pip install wthell

Usage

It's super easy to use wthell. Just run you script using wthell instead of python

wthell your_script.py args1 args2

In linux shell, you can simply use this right after you command failed:

wthell !!

Fun, isn't it?

Or you can import wthell in your script and run your script normally

import wthell

If there's an uncaught exception, you will enter an interactive shell like this:

/home/gaogaotiantian/programs/wthell/test.py(6)
  def g(a, b):
      a += h(a)
      b += 3
>     raise Exception("lol")


Exception raised: <class 'Exception'> lol

up(u)       -- go to outer frame  | down(d)  -- go to inner frame
clear(cl)   -- clear the console  | reset(r) -- back to trigger frame
continue(c) -- resume the program | ctrl+D   -- quit
show(s) <func> -- show source code of function <func>

>>> 

You will be in the frame(function) that raised exceptions in the beginning.

  • Type up to go to outer frame(its caller).
  • Type down to go to inner frame(when you already go out).
  • Type clear to clear the console prints
  • Type reset to go back to the original frame that triggered wthell
  • Type continue to resume the program
  • Type show <func_name> to show source code of a function

wthell will record the full call stack so you can check any frame.

While you are in a stack, you can type anything that you want to evaluation to help you debug.

>>> a
13
>>> a + 1
14
>>> h(a)
16
>>> 

Or you can trigger wthell anywhere in your code

def suspicious_function():
    # I want to check here!
    wthell.wth()

wthell behaves like an interactive shell.

Happy debugging!

License

Copyright Tian Gao, 2020.

Distributed under the terms of the Apache 2.0 license.

wthell's People

Contributors

gaogaotiantian avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

lizhixi konyakest

wthell's Issues

在windows下运行wthell报错

在windows下运行wthell报错

import wthell
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python38\lib\site-p
ackages\wthell\__init__.py", line 2, in <module>
    from .wthell import WTHell
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python38\lib\site-p
ackages\wthell\wthell.py", line 5, in <module>
    import readline
ModuleNotFoundError: No module named 'readline'

尝试

pip install readline

得到的结果是

Collecting readline
  Downloading readline-6.2.4.1.tar.gz (2.3 MB)
     ---------------------------------------- 2.3/2.3 MB 715.8 kB/s eta 0:00:00
  Preparing metadata (setup.py) ... error
  error: subprocess-exited-with-error

  × python setup.py egg_info did not run successfully.
  │ exit code: 1
  ╰─> [1 lines of output]
      error: this module is not meant to work on Windows
      [end of output]

也就是说,readline不能在windows上运行

系统:windows 7

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.