Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion compiler/ksp_ast.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
import sys, types
import ply.lex as lex
import copy
import utils

from decimal import Decimal
from ksp_builtins import functions_with_forced_parentheses

Expand Down Expand Up @@ -106,6 +108,8 @@ class ParseException(SyntaxError):
'''Parse Exceptions for parse errors after AST lex/yacc parsing'''

def __init__(self, node, msg=None):
utils.disable_traceback()

if msg is None:
msg = 'Syntax Error'

Expand All @@ -118,7 +122,7 @@ def __init__(self, node, msg=None):
lineno = child.lineno
break

self.lineno = lineno
self.lineno = None if utils.DISABLE_TRACEBACK_IN_EXCEPTIONS else lineno
self.node = node
self.msg = msg

Expand Down
5 changes: 2 additions & 3 deletions compiler/ksp_compiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -210,9 +210,8 @@ def _set_message(self, value):
class ParseException(ExceptionWithMessage):
'''Parse Exceptions for parse errors raised before AST lex/yacc parsing'''

def __init__(self, line, message, no_traceback = False):
if no_traceback:
utils.disable_traceback()
def __init__(self, line, message):
utils.disable_traceback()

if line.calling_lines:
macro_chain = '\n'.join(['=> {}'.format(l.command.strip()) for l in line.calling_lines])
Expand Down
16 changes: 12 additions & 4 deletions compiler/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,25 @@
import os.path
import ctypes


DISABLE_TRACEBACK_IN_EXCEPTIONS = True


try:
from sublime import status_message
has_sublime_api = True
except ImportError:
has_sublime_api = False


def disable_traceback():
if sys.version_info < (3, 6, 2):
sys.tracebacklimit = None
else:
sys.tracebacklimit = 0
if DISABLE_TRACEBACK_IN_EXCEPTIONS:
__suppress_context__ = True

if sys.version_info < (3, 6, 2):
sys.tracebacklimit = None
else:
sys.tracebacklimit = 0

def split_args(arg_string, line):
'''converts eg. "x, y*(1+z), z" into a list ['x', 'y*(1+z)', 'z']'''
Expand Down