Skip to content

Commit

Permalink
Merge pull request numba#6165 from stuartarchibald/fix/pr5425
Browse files Browse the repository at this point in the history
numba#5425 continued
  • Loading branch information
sklam authored Aug 31, 2020
2 parents 0db523e + 210a8f2 commit 900a2d8
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 7 deletions.
9 changes: 7 additions & 2 deletions numba/core/withcontexts.py
Original file line number Diff line number Diff line change
Expand Up @@ -225,8 +225,13 @@ def strip_var_ver(x):
# Verify that all outputs are annotated
not_annotated = set(stripped_outs) - set(typeanns)
if not_annotated:
msg = 'missing type annotation on outgoing variables: {}'
raise errors.TypingError(msg.format(not_annotated))
msg = (
'Missing type annotation on outgoing variable(s): {0}\n\n'
'Example code: with objmode({1}=\'<'
'add_type_as_string_here>\')\n'
)
stable_ann = sorted(not_annotated)
raise errors.TypingError(msg.format(stable_ann, stable_ann[0]))

# Get output types
outtup = types.Tuple([typeanns[v] for v in stripped_outs])
Expand Down
16 changes: 11 additions & 5 deletions numba/tests/test_withlifting.py
Original file line number Diff line number Diff line change
Expand Up @@ -522,15 +522,21 @@ def test_case07_mystery_key_error(self):
def foo(x):
with objmode_context():
t = {'a': x}
return x, t
u = 3
return x, t, u
x = np.array([1, 2, 3])
cfoo = njit(foo)

with self.assertRaises(errors.TypingError) as raises:
cfoo(x)
self.assertIn(
"missing type annotation on outgoing variables",
str(raises.exception),
)

exstr = str(raises.exception)
self.assertIn("Missing type annotation on outgoing variable(s): "
"['t', 'u']",
exstr)
self.assertIn("Example code: with objmode"
"(t='<add_type_as_string_here>')",
exstr)

def test_case08_raise_from_external(self):
# this segfaults, expect its because the dict needs to raise as '2' is
Expand Down

0 comments on commit 900a2d8

Please sign in to comment.