Repository navigation
Expand file tree
/
Copy patherror.py
More file actions
53 lines (41 loc) · 1.48 KB
/
Copy patherror.py
File metadata and controls
53 lines (41 loc) · 1.48 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# -*- coding: utf-8 -*-
from __future__ import print_function, division, absolute_import
import traceback
__all__ = ["NumbaError", "InternalError", "InvalidTemplateError"]
def format_pos(node):
if node is not None and hasattr(node, 'lineno'):
return format_postup((node.lineno, node.col_offset))
else:
return ""
def format_postup(tup):
lineno, col_offset = tup
return "%s:%s: " % (lineno, col_offset)
class NumbaError(Exception):
"Some error happened during compilation"
def __init__(self, node, msg=None, *args, **kwds):
if msg is None:
node, msg = None, node
self.node = node
self.msg = msg
self.args = args
self.has_report = kwds.get("has_report", False)
def __str__(self):
try:
if self.has_report:
return self.msg.strip()
pos = format_pos(self.node)
msg = "%s%s %s" % (pos, self.msg, " ".join(map(str, self.args)))
return msg.rstrip()
except:
traceback.print_exc()
return "<internal error creating numba error message>"
class InternalError(Exception):
"Indicates a compiler bug"
class _UnknownAttribute(Exception):
pass
class InvalidTemplateError(Exception):
"Raised for invalid template type specifications"
class UnpromotableTypeError(TypeError):
"Raised when we can't promote two given types"
def __str__(self):
return "Cannot promote types %s and %s" % self.args[0]