-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9c3843f
commit 51f4fef
Showing
3 changed files
with
118 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
|
||
import sys | ||
|
||
file = sys.argv[1] | ||
with open(file, "r+") as fp: | ||
code = fp.read() | ||
lines = code.split("\n") | ||
|
||
|
||
def do_line(frame, event, arg): | ||
print("debugging line:", lines[frame.f_lineno - 1]) | ||
return debug | ||
|
||
|
||
def debug(frame, event, arg): | ||
if event == "line": | ||
while True: | ||
_ = input("(Pdb)") | ||
if _ == 'n': | ||
return do_line(frame, event, arg) | ||
elif _.startswith('p'): | ||
_, v = _.split() | ||
v = eval(v, frame.f_globals, frame.f_locals) | ||
print(v) | ||
elif _ == 'q': | ||
sys.exit(0) | ||
return debug | ||
|
||
|
||
if __name__ == '__main__': | ||
sys.settrace(debug) | ||
exec(code, None, None) | ||
sys.settrace(None) |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters