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

Add a newline in patched errors #4464

Merged
merged 2 commits into from Aug 29, 2019

Conversation

jcrist
Copy link
Contributor

@jcrist jcrist commented Aug 19, 2019

Adds a blankline between the original error message and the help
message. This makes it easier to read as a user.

Changes

TypingError: `a` must be a NumPy ndarray
This is not usually a problem with Numba itself but instead often caused by
the use of unsupported features or an issue in resolving types.

To see Python/NumPy features supported by the latest release of Numba visit:
http://numba.pydata.org/numba-doc/latest/reference/pysupported.html
and
http://numba.pydata.org/numba-doc/latest/reference/numpysupported.html

For more information about typing errors and how to debug them visit:
http://numba.pydata.org/numba-doc/latest/user/troubleshoot.html#my-code-doesn-t-compile

If you think your code should work with Numba, please report the error message
and traceback, along with a minimal reproducer at:
https://github.com/numba/numba/issues/new

to

TypingError: `a` must be a NumPy ndarray

This is not usually a problem with Numba itself but instead often caused by
the use of unsupported features or an issue in resolving types.

To see Python/NumPy features supported by the latest release of Numba visit:
http://numba.pydata.org/numba-doc/latest/reference/pysupported.html
and
http://numba.pydata.org/numba-doc/latest/reference/numpysupported.html

For more information about typing errors and how to debug them visit:
http://numba.pydata.org/numba-doc/latest/user/troubleshoot.html#my-code-doesn-t-compile

If you think your code should work with Numba, please report the error message
and traceback, along with a minimal reproducer at:
https://github.com/numba/numba/issues/new

Adds a blankline between the original error message and the help
message. This makes it easier to read as a user.
Some error messages in numba already have a trailing newline.
@stuartarchibald
Copy link
Contributor

Thanks for the patch. Please could you share the example that was creating this problem in the first place? Locally I have a module of things that cause TypingErrors for the purposes of looking at error message changes and none of them seem to trip it. Thanks.

@jcrist
Copy link
Contributor Author

jcrist commented Aug 20, 2019

This happens if you ever raise a TypingError manually, e.g. in generated_jit. Contrived fake example:

In [1]: import numba as nb

In [2]: @nb.generated_jit
   ...: def int_only_add(a, b):
   ...:     if not (isinstance(a, nb.types.Integer) and isinstance(b, nb.types.Integer)):
   ...:         raise nb.errors.TypingError("Only ints allowed!")
   ...:     return lambda a, b: a + b
   ...:

In [3]: int_only_add(1, 2)
Out[3]: 3

In [4]: int_only_add(1.0, 2.0)
---------------------------------------------------------------------------
TypingError                               Traceback (most recent call last)
<ipython-input-4-7f86f89ddb41> in <module>
----> 1 int_only_add(1.0, 2.0)

~/miniconda3/envs/numba-blis/lib/python3.7/site-packages/numba/dispatcher.py in _compile_for_args(self, *args, **kws)
    374                 e.patch_message(msg)
    375
--> 376             error_rewrite(e, 'typing')
    377         except errors.UnsupportedError as e:
    378             # Something unsupported is present in the user code, add help info

~/miniconda3/envs/numba-blis/lib/python3.7/site-packages/numba/dispatcher.py in error_rewrite(e, issue_type)
    341                 raise e
    342             else:
--> 343                 reraise(type(e), e, None)
    344
    345         argtypes = []

~/miniconda3/envs/numba-blis/lib/python3.7/site-packages/numba/six.py in reraise(tp, value, tb)
    656             value = tp()
    657         if value.__traceback__ is not tb:
--> 658             raise value.with_traceback(tb)
    659         raise value
    660

TypingError: Only ints allowed!
This is not usually a problem with Numba itself but instead often caused by
the use of unsupported features or an issue in resolving types.

To see Python/NumPy features supported by the latest release of Numba visit:
http://numba.pydata.org/numba-doc/latest/reference/pysupported.html
and
http://numba.pydata.org/numba-doc/latest/reference/numpysupported.html

For more information about typing errors and how to debug them visit:
http://numba.pydata.org/numba-doc/latest/user/troubleshoot.html#my-code-doesn-t-compile

If you think your code should work with Numba, please report the error message
and traceback, along with a minimal reproducer at:
https://github.com/numba/numba/issues/new

@stuartarchibald
Copy link
Contributor

Ah, thanks, the extra line is welcomed there!

Copy link
Contributor

@stuartarchibald stuartarchibald left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the patch.

@stuartarchibald stuartarchibald added 5 - Ready to merge Review and testing done, is ready to merge and removed 3 - Ready for Review labels Aug 27, 2019
@seibert seibert merged commit 196fb2c into numba:master Aug 29, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
5 - Ready to merge Review and testing done, is ready to merge
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants