mirror of
https://github.com/python/cpython.git
synced 2025-07-31 15:14:22 +00:00
Allow code objects to be passed to run() and eval().
This commit is contained in:
parent
7e42caba01
commit
4808dcb564
1 changed files with 7 additions and 2 deletions
|
@ -7,6 +7,7 @@
|
||||||
# And of course... you can roll your own!
|
# And of course... you can roll your own!
|
||||||
|
|
||||||
import sys
|
import sys
|
||||||
|
import types
|
||||||
|
|
||||||
BdbQuit = 'bdb.BdbQuit' # Exception to give up completely
|
BdbQuit = 'bdb.BdbQuit' # Exception to give up completely
|
||||||
|
|
||||||
|
@ -278,9 +279,11 @@ class Bdb: # Basic Debugger
|
||||||
locals = globals
|
locals = globals
|
||||||
self.reset()
|
self.reset()
|
||||||
sys.settrace(self.trace_dispatch)
|
sys.settrace(self.trace_dispatch)
|
||||||
|
if type(cmd) <> types.CodeType:
|
||||||
|
cmd = cmd+'\n'
|
||||||
try:
|
try:
|
||||||
try:
|
try:
|
||||||
exec cmd + '\n' in globals, locals
|
exec cmd in globals, locals
|
||||||
except BdbQuit:
|
except BdbQuit:
|
||||||
pass
|
pass
|
||||||
finally:
|
finally:
|
||||||
|
@ -295,9 +298,11 @@ class Bdb: # Basic Debugger
|
||||||
locals = globals
|
locals = globals
|
||||||
self.reset()
|
self.reset()
|
||||||
sys.settrace(self.trace_dispatch)
|
sys.settrace(self.trace_dispatch)
|
||||||
|
if type(expr) <> types.CodeType:
|
||||||
|
expr = expr+'\n'
|
||||||
try:
|
try:
|
||||||
try:
|
try:
|
||||||
return eval(expr + '\n', globals, locals)
|
return eval(expr, globals, locals)
|
||||||
except BdbQuit:
|
except BdbQuit:
|
||||||
pass
|
pass
|
||||||
finally:
|
finally:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue