mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Fixed pydev.debugger tests.
This commit is contained in:
@@ -101,6 +101,7 @@ class PyDBAdditionalThreadInfoWithoutCurrentFramesSupport(AbstractPyDBAdditional
|
||||
#1. we can't have weak-references to python frame object
|
||||
#2. only from 2.5 onwards we have _current_frames support from the interpreter
|
||||
db_frame = PyDBFrame(args)
|
||||
db_frame.frame = args[-1]
|
||||
self._AddDbFrame(db_frame)
|
||||
return db_frame
|
||||
|
||||
|
||||
@@ -44,7 +44,6 @@ class PyDBFrame:
|
||||
def __init__(self, args):
|
||||
#args = mainDebugger, filename, base, info, t, frame
|
||||
#yeap, much faster than putting in self and then getting it from self later on
|
||||
self.frame = args[-1]
|
||||
self._args = args[:-1]
|
||||
|
||||
def setSuspend(self, *args, **kwargs):
|
||||
@@ -84,7 +83,7 @@ class PyDBFrame:
|
||||
flag = False
|
||||
else:
|
||||
try:
|
||||
result = mainDebugger.plugin_exception_break(self, self._args, arg)
|
||||
result = mainDebugger.plugin_exception_break(self, frame, self._args, arg)
|
||||
if result:
|
||||
(flag, frame) = result
|
||||
|
||||
@@ -271,7 +270,7 @@ class PyDBFrame:
|
||||
or (step_cmd in (CMD_STEP_RETURN, CMD_STEP_OVER) and stop_frame is not frame)
|
||||
|
||||
if can_skip:
|
||||
can_skip = main_debugger.plugin_can_skip(self)
|
||||
can_skip = not main_debugger.plugin_can_not_skip(self, frame)
|
||||
|
||||
# Let's check to see if we are in a function that has a breakpoint. If we don't have a breakpoint,
|
||||
# we will return nothing for the next trace
|
||||
@@ -322,11 +321,10 @@ class PyDBFrame:
|
||||
and DictContains(breakpoints_for_file, line):
|
||||
breakpoint = breakpoints_for_file[line]
|
||||
stop_info['stop'] = True
|
||||
new_frame = frame
|
||||
if info.pydev_step_cmd == CMD_STEP_OVER and info.pydev_step_stop is frame and event in ('line', 'return'):
|
||||
if step_cmd == CMD_STEP_OVER and stop_frame is frame and event in ('line', 'return'):
|
||||
stop_info['stop'] = False #we don't stop on breakpoint if we have to stop by step-over (it will be processed later)
|
||||
else:
|
||||
result = main_debugger.plugin_get_breakpoint(self, event, self._args)
|
||||
result = main_debugger.plugin_get_breakpoint(self, frame, event, self._args)
|
||||
if result:
|
||||
exist_result = True
|
||||
(flag, breakpoint, new_frame) = result
|
||||
@@ -335,29 +333,61 @@ class PyDBFrame:
|
||||
#ok, hit breakpoint, now, we have to discover if it is a conditional breakpoint
|
||||
# lets do the conditional stuff here
|
||||
if stop_info['stop'] or exist_result:
|
||||
if breakpoint.condition is not None:
|
||||
condition = breakpoint.condition
|
||||
if condition is not None:
|
||||
try:
|
||||
val = eval(breakpoint.condition, new_frame.f_globals, new_frame.f_locals)
|
||||
val = eval(condition, new_frame.f_globals, new_frame.f_locals)
|
||||
if not val:
|
||||
return self.trace_dispatch
|
||||
|
||||
except:
|
||||
pydev_log.info('Error while evaluating condition \'%s\': %s\n' % (breakpoint.condition, sys.exc_info()[1]))
|
||||
return self.trace_dispatch
|
||||
if type(condition) != type(''):
|
||||
if hasattr(condition, 'encode'):
|
||||
condition = condition.encode('utf-8')
|
||||
|
||||
if breakpoint.expression is not None:
|
||||
try:
|
||||
msg = 'Error while evaluating expression: %s\n' % (condition,)
|
||||
sys.stderr.write(msg)
|
||||
traceback.print_exc()
|
||||
if not main_debugger.suspend_on_breakpoint_exception:
|
||||
return self.trace_dispatch
|
||||
else:
|
||||
stop_info['stop'] = True
|
||||
try:
|
||||
additional_info = None
|
||||
try:
|
||||
additional_info = thread.additionalInfo
|
||||
except AttributeError:
|
||||
pass #that's ok, no info currently set
|
||||
|
||||
if additional_info is not None:
|
||||
# add exception_type and stacktrace into thread additional info
|
||||
etype, value, tb = sys.exc_info()
|
||||
try:
|
||||
error = ''.join(traceback.format_exception_only(etype, value))
|
||||
stack = traceback.extract_stack(f=tb.tb_frame.f_back)
|
||||
|
||||
# On self.setSuspend(thread, CMD_SET_BREAK) this info will be
|
||||
# sent to the client.
|
||||
additional_info.conditional_breakpoint_exception = \
|
||||
('Condition:\n' + condition + '\n\nError:\n' + error, stack)
|
||||
finally:
|
||||
etype, value, tb = None, None, None
|
||||
except:
|
||||
traceback.print_exc()
|
||||
|
||||
if breakpoint.expression is not None:
|
||||
try:
|
||||
val = eval(breakpoint.expression, new_frame.f_globals, new_frame.f_locals)
|
||||
except:
|
||||
val = sys.exc_info()[1]
|
||||
finally:
|
||||
if val is not None:
|
||||
thread.additionalInfo.message = val
|
||||
try:
|
||||
val = eval(breakpoint.expression, new_frame.f_globals, new_frame.f_locals)
|
||||
except:
|
||||
val = sys.exc_info()[1]
|
||||
finally:
|
||||
if val is not None:
|
||||
thread.additionalInfo.message = val
|
||||
if stop_info['stop']:
|
||||
self.setSuspend(thread, CMD_SET_BREAK)
|
||||
elif flag:
|
||||
result = main_debugger.plugin_suspend(self, thread, frame)
|
||||
result = main_debugger.plugin_suspend(thread, frame)
|
||||
if result:
|
||||
frame = result
|
||||
|
||||
@@ -390,7 +420,7 @@ class PyDBFrame:
|
||||
main_debugger.plugin_cmd_step_into(frame, event, self._args, stop_info)
|
||||
|
||||
elif step_cmd == CMD_STEP_OVER:
|
||||
stop_info['stop'] = info.pydev_step_stop is frame and event in ('line', 'return')
|
||||
stop_info['stop'] = stop_frame is frame and event in ('line', 'return')
|
||||
main_debugger.plugin_cmd_step_over(frame, event, self._args, stop_info)
|
||||
|
||||
elif step_cmd == CMD_SMART_STEP_INTO:
|
||||
|
||||
@@ -2,7 +2,7 @@ import os
|
||||
import types
|
||||
|
||||
import pydev_log
|
||||
from pluginbase import PluginBase
|
||||
from third_party.pluginbase import PluginBase
|
||||
|
||||
|
||||
def load_plugins(package):
|
||||
@@ -25,7 +25,7 @@ class NullProxy(object):
|
||||
def __init__(self):
|
||||
def foo(*args, **kwargs):
|
||||
return None
|
||||
self.null_func = foo
|
||||
self.null_func = types.MethodType(foo, self)
|
||||
|
||||
def __getattr__(self, name):
|
||||
return self.null_func
|
||||
|
||||
@@ -123,7 +123,7 @@ def is_django_suspended(thread):
|
||||
return thread.additionalInfo.suspend_type == DJANGO_SUSPEND
|
||||
|
||||
|
||||
def suspend_django(py_db_frame, mainDebugger, thread, frame, cmd=CMD_SET_BREAK):
|
||||
def suspend_django(mainDebugger, thread, frame, cmd=CMD_SET_BREAK):
|
||||
frame = DjangoTemplateFrame(frame)
|
||||
|
||||
if frame.f_lineno is None:
|
||||
@@ -137,7 +137,7 @@ def suspend_django(py_db_frame, mainDebugger, thread, frame, cmd=CMD_SET_BREAK):
|
||||
|
||||
pydevd_vars.addAdditionalFrameById(GetThreadId(thread), {id(frame): frame})
|
||||
|
||||
py_db_frame.setSuspend(thread, cmd)
|
||||
mainDebugger.setSuspend(thread, cmd)
|
||||
thread.additionalInfo.suspend_type = DJANGO_SUSPEND
|
||||
|
||||
thread.additionalInfo.filename = frame.f_code.co_filename
|
||||
@@ -264,14 +264,13 @@ def is_django_exception_break_context(frame):
|
||||
# Django Step Commands
|
||||
#=======================================================================================================================
|
||||
|
||||
def can_skip(mainDebugger, pydb_frame):
|
||||
frame = pydb_frame.frame
|
||||
def can_not_skip(mainDebugger, pydb_frame, frame):
|
||||
if hasattr(mainDebugger, 'django_breakpoints') and mainDebugger.django_breakpoints and cached_call(pydb_frame, is_django_render_call, frame):
|
||||
filename = get_template_file_name(frame)
|
||||
django_breakpoints_for_file = mainDebugger.django_breakpoints.get(filename)
|
||||
if django_breakpoints_for_file:
|
||||
return False
|
||||
return True
|
||||
return True
|
||||
return False
|
||||
|
||||
def has_exception_breaks(mainDebugger):
|
||||
return hasattr(mainDebugger, 'django_exception_break') and mainDebugger.django_exception_break
|
||||
@@ -306,16 +305,15 @@ def cmd_step_over(mainDebugger, frame, event, args, stop_info):
|
||||
def stop(mainDebugger, frame, event, args, stop_info, arg, step_cmd):
|
||||
mainDebugger, filename, info, thread = args
|
||||
if DictContains(stop_info, 'django_stop') and stop_info['django_stop']:
|
||||
frame = suspend_django(mainDebugger, mainDebugger, thread, frame, step_cmd)
|
||||
frame = suspend_django(mainDebugger, thread, frame, step_cmd)
|
||||
if frame:
|
||||
mainDebugger.doWaitSuspend(thread, frame, event, arg)
|
||||
return True
|
||||
return False
|
||||
|
||||
|
||||
def get_breakpoint(mainDebugger, pydb_frame, event, args):
|
||||
def get_breakpoint(mainDebugger, pydb_frame, frame, event, args):
|
||||
mainDebugger, filename, info, thread = args
|
||||
frame = pydb_frame.frame
|
||||
flag = False
|
||||
django_breakpoint = None
|
||||
new_frame = None
|
||||
@@ -337,19 +335,18 @@ def get_breakpoint(mainDebugger, pydb_frame, event, args):
|
||||
return flag, django_breakpoint, new_frame
|
||||
|
||||
|
||||
def suspend(mainDebugger, pydb_frame, thread, frame):
|
||||
return suspend_django(pydb_frame, mainDebugger, thread, frame)
|
||||
def suspend(mainDebugger, thread, frame):
|
||||
return suspend_django(mainDebugger, thread, frame)
|
||||
|
||||
def exception_break(mainDebugger, pydb_frame, args, arg):
|
||||
def exception_break(mainDebugger, pydb_frame, frame, args, arg):
|
||||
mainDebugger, filename, info, thread = args
|
||||
frame = pydb_frame.frame
|
||||
exception, value, trace = arg
|
||||
if hasattr(mainDebugger, 'django_exception_break') and mainDebugger.django_exception_break and \
|
||||
get_exception_name(exception) in ['VariableDoesNotExist', 'TemplateDoesNotExist', 'TemplateSyntaxError'] and \
|
||||
just_raised(trace) and is_django_exception_break_context(frame):
|
||||
render_frame = find_django_render_frame(frame)
|
||||
if render_frame:
|
||||
suspend_frame = suspend_django(pydb_frame, mainDebugger, thread, render_frame, CMD_ADD_EXCEPTION_BREAK)
|
||||
suspend_frame = suspend_django(mainDebugger, thread, render_frame, CMD_ADD_EXCEPTION_BREAK)
|
||||
if suspend_frame:
|
||||
add_exception_to_frame(suspend_frame, (exception, value, trace))
|
||||
flag = True
|
||||
|
||||
@@ -66,14 +66,14 @@ def is_jinja2_render_call(frame):
|
||||
return False
|
||||
|
||||
|
||||
def suspend_jinja2(py_db_frame, mainDebugger, thread, frame, cmd=CMD_SET_BREAK):
|
||||
def suspend_jinja2(mainDebugger, thread, frame, cmd=CMD_SET_BREAK):
|
||||
frame = Jinja2TemplateFrame(frame)
|
||||
|
||||
if frame.f_lineno is None:
|
||||
return None
|
||||
|
||||
pydevd_vars.addAdditionalFrameById(GetThreadId(thread), {id(frame): frame})
|
||||
py_db_frame.setSuspend(thread, cmd)
|
||||
mainDebugger.setSuspend(thread, cmd)
|
||||
|
||||
thread.additionalInfo.suspend_type = JINJA2_SUSPEND
|
||||
thread.additionalInfo.filename = frame.f_code.co_filename
|
||||
@@ -194,14 +194,13 @@ def get_jinja2_template_filename(frame):
|
||||
def has_exception_breaks(mainDebugger):
|
||||
return hasattr(mainDebugger, 'jinja2_exception_break') and mainDebugger.jinja2_exception_break
|
||||
|
||||
def can_skip(mainDebugger, pydb_frame):
|
||||
frame = pydb_frame.frame
|
||||
def can_not_skip(mainDebugger, pydb_frame, frame):
|
||||
if hasattr(mainDebugger, 'jinja2_breakpoints') and mainDebugger.jinja2_breakpoints and cached_call(pydb_frame, is_jinja2_render_call, frame):
|
||||
filename = get_jinja2_template_filename(frame)
|
||||
jinja2_breakpoints_for_file = mainDebugger.jinja2_breakpoints.get(filename)
|
||||
if jinja2_breakpoints_for_file:
|
||||
return False
|
||||
return True
|
||||
return True
|
||||
return False
|
||||
|
||||
|
||||
def cmd_step_into(mainDebugger, frame, event, args, stop_info):
|
||||
@@ -281,16 +280,15 @@ def cmd_step_over(mainDebugger, frame, event, args, stop_info):
|
||||
def stop(mainDebugger, frame, event, args, stop_info, arg, step_cmd):
|
||||
mainDebugger, filename, info, thread = args
|
||||
if DictContains(stop_info, 'jinja2_stop') and stop_info['jinja2_stop']:
|
||||
frame = suspend_jinja2(mainDebugger, mainDebugger, thread, frame, step_cmd)
|
||||
frame = suspend_jinja2(mainDebugger, thread, frame, step_cmd)
|
||||
if frame:
|
||||
mainDebugger.doWaitSuspend(thread, frame, event, arg)
|
||||
return True
|
||||
return False
|
||||
|
||||
|
||||
def get_breakpoint(mainDebugger, pydb_frame, event, args):
|
||||
def get_breakpoint(mainDebugger, pydb_frame, frame, event, args):
|
||||
mainDebugger, filename, info, thread = args
|
||||
frame = pydb_frame.frame
|
||||
new_frame = None
|
||||
jinja2_breakpoint = None
|
||||
flag = False
|
||||
@@ -311,20 +309,19 @@ def get_breakpoint(mainDebugger, pydb_frame, event, args):
|
||||
return flag, jinja2_breakpoint, new_frame
|
||||
|
||||
|
||||
def suspend(mainDebugger, pydb_frame, thread, frame):
|
||||
return suspend_jinja2(pydb_frame, mainDebugger, thread, frame)
|
||||
def suspend(mainDebugger, thread, frame):
|
||||
return suspend_jinja2(mainDebugger, thread, frame)
|
||||
|
||||
|
||||
def exception_break(mainDebugger, pydb_frame, args, arg):
|
||||
def exception_break(mainDebugger, pydb_frame, frame, args, arg):
|
||||
mainDebugger, filename, info, thread = args
|
||||
frame = pydb_frame.frame
|
||||
exception, value, trace = arg
|
||||
if hasattr(mainDebugger, 'jinja2_exception_break') and mainDebugger.jinja2_exception_break:
|
||||
if get_exception_name(exception) in ('UndefinedError', 'TemplateNotFound', 'TemplatesNotFound'):
|
||||
#errors in rendering
|
||||
render_frame = find_jinja2_render_frame(frame)
|
||||
if render_frame:
|
||||
suspend_frame = suspend_jinja2(pydb_frame, mainDebugger, thread, render_frame, CMD_ADD_EXCEPTION_BREAK)
|
||||
suspend_frame = suspend_jinja2(mainDebugger, thread, render_frame, CMD_ADD_EXCEPTION_BREAK)
|
||||
if suspend_frame:
|
||||
add_exception_to_frame(suspend_frame, (exception, value, trace))
|
||||
flag = True
|
||||
|
||||
+1
-1
@@ -16,7 +16,7 @@ from pydevd_constants import IS_PY24, IS_PY3K
|
||||
|
||||
|
||||
if IS_PY24:
|
||||
from uuid_old import uuid4
|
||||
from third_party.uuid_old import uuid4
|
||||
else:
|
||||
from uuid import uuid4
|
||||
|
||||
Reference in New Issue
Block a user