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 proper underscore handling to float and complex types. #5356

Merged
merged 10 commits into from
Jul 28, 2024

Conversation

dannasman
Copy link
Contributor

@dannasman dannasman commented Jul 18, 2024

Hi!

Here is a solution proposal for adding correct underscore handling to vm/src/builtins/float.rs and vm/src/builtins/complex.rs (close #5351 ).

None => Complex64::new(crate::literal::float::parse_str(s)?, 0.0),
None => {
let stripped = float::float_strip_underscores(s.as_bytes())?;
Complex64::new(crate::literal::float::parse_bytes(&stripped)?, 0.0)
Copy link
Member

Choose a reason for hiding this comment

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

is there any case parse_bytes is called without float_strip_underscores?
How about put it in parse_bytes if it is necessary?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I did not come across any cases where parse_bytes calls needed to or could be performed without underscore handling. I'll look into putting this directly in parse_bytes 👍

@youknowone
Copy link
Member

Thank you! Does parser updated need to be applied here too or separatedly updatable?

@dannasman
Copy link
Contributor Author

dannasman commented Jul 23, 2024

Thank you! Does parser updated need to be applied here too or separatedly updatable?

The underline handling is now completely in parser. I removed all changes in this PR made to complex.rs and float.rs since they are no longer needed.

Copy link
Member

@youknowone youknowone left a comment

Choose a reason for hiding this comment

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

I added a commit to change parser version, thank you!

@youknowone youknowone merged commit 2335ca0 into RustPython:main Jul 28, 2024
11 checks passed
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

Successfully merging this pull request may close these issues.

test_complex.test_underscores
2 participants