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

text() throws TypeError when giving a non-string value to it's s parameter #376

Closed
notbored opened this issue Feb 1, 2022 · 2 comments
Closed

Comments

@notbored
Copy link

notbored commented Feb 1, 2022

pyxel.text(50, 50, pyxel.frame_count, 1)

Causes:

TypeError: argument 's': 'int' object cannot be converted to 'PyString'

Works fine if you explicitly convert integer/non-string values to a string using str():

pyxel.text(50, 50, str(pyxel.frame_count), 1)

Would it be possible for text() to behave similarly to print() and convert all arguments to strings where necessary.

@notbored notbored changed the title text() throws TypeError when giving a non-string value to it's string parameter text() throws TypeError when giving a non-string value to it's s parameter Feb 1, 2022
@kitao
Copy link
Owner

kitao commented Apr 30, 2022

It's a good idea, but due to the Rust module for making Python interface, it's difficult to implement without dirty hack on Python side. When I found the way of automatic casting on pyo3 (it's the name of the rust module), I'll implement this feature.

@kitao kitao closed this as completed Apr 30, 2022
@merwok
Copy link
Contributor

merwok commented Apr 30, 2022

Can rust code call the Python function str, or its equivalent in the Rust API?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants