Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#5425 continued #6165

Merged
merged 3 commits into from
Aug 31, 2020
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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