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

Missing conversion from StringLiteral to unicode_type #6907

Closed
2 tasks done
stuartarchibald opened this issue Apr 8, 2021 · 1 comment · Fixed by #6917
Closed
2 tasks done

Missing conversion from StringLiteral to unicode_type #6907

stuartarchibald opened this issue Apr 8, 2021 · 1 comment · Fixed by #6917
Labels
bug - incorrect behavior Bugs: incorrect behavior

Comments

@stuartarchibald
Copy link
Contributor

stuartarchibald commented Apr 8, 2021

Reporting a bug

  • I have tried using the latest released version of Numba (most recent is
    visible in the change log (https://github.com/numba/numba/blob/master/CHANGE_LOG).
  • I have included a self contained code sample to reproduce the problem.
    i.e. it's possible to run as 'python bug.py'.

This:

from numba import typeof, types
from numba.core.typing import Context

x = types.literal('string literal')
print(x, type(x))
print("conversion:", x.can_convert_to(Context(), types.unicode_type))

does this:

Literal[str](string literal) <class 'numba.core.types.misc.StringLiteral'>
conversion: None

I think it should be possible to convert a StringLiteral to a unicode_type but not the converse.

A can_convert_to() method needs adding to this class:

class StringLiteral(Literal, Dummy):
pass

xref: https://numba.discourse.group/t/how-to-pass-string-argument-to-numba-njit-python-function-from-inside-another-whilst-specifying-signature-type/663 which hits this bug.

@stuartarchibald stuartarchibald added the bug - incorrect behavior Bugs: incorrect behavior label Apr 8, 2021
@gmarkall
Copy link
Member

gmarkall commented Apr 8, 2021

Would fixing this also fix #6897?

stuartarchibald added a commit to stuartarchibald/numba that referenced this issue Apr 12, 2021
gmarkall pushed a commit to gmarkall/numba that referenced this issue May 28, 2021
gmarkall pushed a commit to gmarkall/numba that referenced this issue Aug 11, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug - incorrect behavior Bugs: incorrect behavior
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants