Skip to content
Merged
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
29 changes: 8 additions & 21 deletions com/win32comext/axscript/client/error.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,35 +98,22 @@ def __BuildFromException(self, site, type, value, tb):
linecache.clearcache()
try:
if issubclass(type, SyntaxError):
self._BuildFromSyntaxError(site, value, tb)
self._BuildFromSyntaxError(value)
else:
self._BuildFromOther(site, type, value, tb)
except: # Error extracting traceback info!!!
traceback.print_exc()
# re-raise.
raise

def _BuildFromSyntaxError(self, site, exc, tb):
value = exc.args
# All syntax errors should have a message as element 0
try:
msg = value[0]
except:
msg = f"Unknown Error ({value})"
try:
(filename, lineno, offset, line) = value[1]
# Some of these may be None, which upsets us!
if offset is None:
offset = 0
if line is None:
line = ""
except:
msg = "Unknown"
lineno = 0
offset = 0
line = "Unknown"
def _BuildFromSyntaxError(self, exc: SyntaxError):
# Some of these may be None, which upsets us!
msg = exc.msg or "Unknown Error"
offset = exc.offset or 0
line = exc.text or ""

self.description = FormatForAX(msg)
self.lineno = lineno
self.lineno = exc.lineno
self.colno = offset - 1
self.linetext = ExpandTabs(line.rstrip())

Expand Down