Skip to content
Browse files

Slightly experimental syntax refactoring for exceptions

This is to provide more universal compatibility between python versions.
  • Loading branch information...
1 parent 44f69d8 commit b43356072890fb61526eac5a3a8df765fb7aa469 @joonty committed Dec 21, 2012
View
1 .travis.xml
@@ -2,7 +2,6 @@ language: python
python:
- "2.6"
- "2.7"
- - "3.2"
# command to install dependencies
install: "pip install -r requirements.txt --use-mirrors"
# command to run tests
View
30 plugin/python/start_vdebug.py
@@ -28,111 +28,111 @@ def run(self):
"""
try:
self.runner.run()
- except Exception, e:
+ except Exception as e:
self.handle_exception(e)
def run_to_cursor(self):
"""Run to the current VIM cursor position.
"""
try:
self.runner.run_to_cursor()
- except Exception, e:
+ except Exception as e:
self.handle_exception(e)
def step_over(self):
"""Step over to the next statement.
"""
try:
self.runner.step_over()
- except Exception, e:
+ except Exception as e:
self.handle_exception(e)
def step_into(self):
"""Step into a statement on the current line.
"""
try:
self.runner.step_into()
- except Exception, e:
+ except Exception as e:
self.handle_exception(e)
def step_out(self):
"""Step out of the current statement.
"""
try:
self.runner.step_out()
- except Exception, e:
+ except Exception as e:
self.handle_exception(e)
def handle_return_keypress(self):
"""React to a <enter> keypress event.
"""
try:
return self.event_dispatcher.by_position()
- except Exception, e:
+ except Exception as e:
self.handle_exception(e)
def handle_double_click(self):
"""React to a mouse double click event.
"""
try:
return self.event_dispatcher.by_position()
- except Exception, e:
+ except Exception as e:
self.handle_exception(e)
def handle_visual_eval(self):
"""React to eval during visual selection.
"""
try:
return self.event_dispatcher.visual_eval()
- except Exception, e:
+ except Exception as e:
self.handle_exception(e)
def handle_eval(self,args):
"""Evaluate a code snippet specified by args.
"""
try:
return self.runner.eval(args)
- except Exception, e:
+ except Exception as e:
self.handle_exception(e)
def eval_under_cursor(self):
"""Evaluate the property under the cursor.
"""
try:
return self.event_dispatcher.eval_under_cursor()
- except Exception, e:
+ except Exception as e:
self.handle_exception(e)
def toggle_breakpoint_window(self):
"""Open or close the breakpoint window.
"""
try:
return self.runner.toggle_breakpoint_window()
- except Exception, e:
+ except Exception as e:
self.handle_exception(e)
def set_breakpoint(self,args = None):
"""Set a breakpoint, specified by args.
"""
try:
self.runner.set_breakpoint(args)
- except Exception, e:
+ except Exception as e:
self.handle_exception(e)
def remove_breakpoint(self,args = None):
"""Remove one or more breakpoints, specified by args.
"""
try:
self.runner.remove_breakpoint(args)
- except Exception, e:
+ except Exception as e:
self.handle_exception(e)
def get_context(self):
"""Get all the variables in the default context
"""
try:
self.runner.get_context()
- except Exception, e:
+ except Exception as e:
self.handle_exception(e)
@@ -141,7 +141,7 @@ def detach(self):
"""
try:
self.runner.detach()
- except Exception, e:
+ except Exception as e:
self.handle_exception(e)
def close(self):
View
28 plugin/python/vdebug/breakpoint.py
@@ -34,7 +34,7 @@ def remove_breakpoint(self,breakpoint):
def remove_breakpoint_by_id(self,id):
id = str(id)
if id not in self.breakpoints:
- raise BreakpointError, "No breakpoint matching ID %s" % id
+ raise BreakpointError("No breakpoint matching ID %s" % id)
vdebug.log.Log("Removing breakpoint id %s" % id)
if self.api is not None:
dbg_id = self.breakpoints[id].get_debugger_id()
@@ -107,7 +107,7 @@ def parse(self,ui,args):
try:
file = ui.get_current_file()
except vdebug.util.FilePathError:
- raise BreakpointError, 'No file, cannot set breakpoint'
+ raise BreakpointError('No file, cannot set breakpoint')
return LineBreakpoint(ui,file,row)
else:
arg_parts = args.split(' ')
@@ -117,38 +117,38 @@ def parse(self,ui,args):
row = ui.get_current_row()
file = ui.get_current_file()
if len(arg_parts) == 0:
- raise BreakpointError, "Conditional breakpoints " +\
- "require a condition to be specified"
+ raise BreakpointError("Conditional breakpoints " +\
+ "require a condition to be specified")
cond = " ".join(arg_parts)
return ConditionalBreakpoint(ui,file,row,cond)
elif type == 'watch':
if len(arg_parts) == 0:
- raise BreakpointError, "Watch breakpoints " +\
- "require a condition to be specified"
+ raise BreakpointError("Watch breakpoints " +\
+ "require a condition to be specified")
expr = " ".join(arg_parts)
vdebug.log.Log("Expression: %s"%expr)
return WatchBreakpoint(ui,expr)
elif type == 'exception':
if len(arg_parts) == 0:
- raise BreakpointError, "Exception breakpoints " +\
- "require an exception name to be specified"
+ raise BreakpointError("Exception breakpoints " +\
+ "require an exception name to be specified")
return ExceptionBreakpoint(ui,arg_parts[0])
elif type == 'return':
l = len(arg_parts)
if l == 0:
- raise BreakpointError, "Return breakpoints " +\
- "require a function name to be specified"
+ raise BreakpointError("Return breakpoints " +\
+ "require a function name to be specified")
return ReturnBreakpoint(ui,arg_parts[0])
elif type == 'call':
l = len(arg_parts)
if l == 0:
- raise BreakpointError, "Call breakpoints " +\
- "require a function name to be specified"
+ raise BreakpointError("Call breakpoints " +\
+ "require a function name to be specified")
return CallBreakpoint(ui,arg_parts[0])
else:
- raise BreakpointError, "Unknown breakpoint type, " +\
+ raise BreakpointError("Unknown breakpoint type, " +\
"please choose one of: conditional, exception,"+\
- "call or return"
+ "call or return")
def get_cmd(self):
pass
View
12 plugin/python/vdebug/dbgp.py
@@ -124,9 +124,9 @@ class EvalResponse(ContextGetResponse):
def __init__(self,response,cmd,cmd_args,api):
try:
ContextGetResponse.__init__(self,response,cmd,cmd_args,api)
- except DBGPError, e:
+ except DBGPError as e:
if int(e.args[1]) == 206:
- raise EvalError
+ raise EvalError()
else:
raise e
@@ -416,7 +416,7 @@ def open(self):
self.sock.settimeout(None)
except socket.timeout:
serv.close()
- raise TimeoutError,"Timeout waiting for connection"
+ raise TimeoutError("Timeout waiting for connection")
except:
serv.close()
raise
@@ -458,7 +458,7 @@ def __recv_length(self):
c = self.sock.recv(1)
if c == '':
self.close()
- raise EOFError, 'Socket Closed'
+ raise EOFError('Socket Closed')
if c == '\0':
return int(length)
if c.isdigit():
@@ -470,7 +470,7 @@ def __recv_null(self):
c = self.sock.recv(1)
if c == '':
self.close()
- raise EOFError, 'Socket Closed'
+ raise EOFError('Socket Closed')
if c == '\0':
return
@@ -484,7 +484,7 @@ def __recv_body(self, to_recv):
buf = self.sock.recv(to_recv)
if buf == '':
self.close()
- raise EOFError, 'Socket Closed'
+ raise EOFError('Socket Closed')
to_recv -= len(buf)
body = body + buf
return body
View
6 plugin/python/vdebug/event.py
@@ -156,7 +156,7 @@ def execute(self,runner):
eq_index = line.find('=')
if eq_index == -1:
- raise EventError, "Cannot read the selected property"
+ raise EventError("Cannot read the selected property")
name = line[pointer_index+step:eq_index-1]
context_res = runner.api.property_get(name)
@@ -210,7 +210,7 @@ def execute(self,runner):
if tab_end_pos == -1 or \
tab_start_pos == -1:
- raise EventError, "Failed to find context name under cursor"
+ raise EventError("Failed to find context name under cursor")
context_name = line[tab_start_pos:tab_end_pos]
vdebug.log.Log("Context name: %s" % context_name,\
@@ -223,7 +223,7 @@ def execute(self,runner):
runner.context_names,context_name)
if context_id == -1:
- raise EventError, "Could not resolve context name"
+ raise EventError("Could not resolve context name")
return False
else:
runner.get_context(context_id)
View
10 plugin/python/vdebug/log.py
@@ -71,12 +71,12 @@ def __init__(self,debug_level,filename):
def __open(self):
try:
self.f = open(self.filename,'w')
- except IOError, e:
- raise LogError, "Invalid file name '%s' for log file: %s" \
- %(self.filename,str(e))
+ except IOError as e:
+ raise LogError("Invalid file name '%s' for log file: %s" \
+ %(self.filename,str(e)))
except:
- raise LogError, "Error using file '%s' as a log file: %s" \
- %(self.filename,sys.exc_info()[0])
+ raise LogError("Error using file '%s' as a log file: %s" \
+ %(self.filename,sys.exc_info()[0]))
def shutdown(self):
View
4 plugin/python/vdebug/opts.py
@@ -16,7 +16,7 @@ def inst(cls):
"""Get the Options instance.
"""
if cls.instance is None:
- raise OptionsError, "No options have been set"
+ raise OptionsError("No options have been set")
return cls.instance
@classmethod
@@ -29,7 +29,7 @@ def get(cls,name,as_type = str):
if name in inst.options:
return as_type(inst.options[name])
else:
- raise OptionsError, "No option with key '%s'" % name
+ raise OptionsError("No option with key '%s'" % name)
@classmethod
def overwrite(cls,name,value):
View
4 plugin/python/vdebug/util.py
@@ -59,7 +59,7 @@ class FilePath:
def __init__(self,filename):
if filename is None or \
len(filename) == 0:
- raise FilePathError, "Missing or invalid file name"
+ raise FilePathError("Missing or invalid file name")
filename = urllib.unquote(filename)
if filename.startswith('file://'):
filename = filename[7:]
@@ -159,7 +159,7 @@ def probe(self):
try:
vim.eval("getchar(0)")
except vim.error:
- raise UserInterrupt
+ raise UserInterrupt()
class UserInterrupt(Exception):
"""Raised when a user interrupts connection wait."""

0 comments on commit b433560

Please sign in to comment.
Something went wrong with that request. Please try again.