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

Fix Binary_Add for Python Strings #79

Closed
daytonjallen opened this issue Jan 31, 2022 · 2 comments
Closed

Fix Binary_Add for Python Strings #79

daytonjallen opened this issue Jan 31, 2022 · 2 comments
Assignees
Labels
bug Something isn't working invalid This doesn't seem right
Milestone

Comments

@daytonjallen
Copy link
Contributor

We're currently including the addition of strings in our Number Protocol call PyNumber_Add, however Python has a separate way of adding strings.

From their handling of the Binary_Add bytecode:

// code ...
if (PyUnicode_CheckExact(left) &&
         PyUnicode_CheckExact(right)) {
    sum = unicode_concatenate(tstate, left, right, f, next_instr);
    /* unicode_concatenate consumed the ref to left */
}
else {
    sum = PyNumber_Add(left, right);
    Py_DECREF(left);
}
// ... code
@daytonjallen daytonjallen added the bug Something isn't working label Jan 31, 2022
@ALavallee ALavallee added this to the Beta milestone Feb 4, 2022
@ALavallee
Copy link
Contributor

Make sure it works for add on all others objects.

we might change something CPython if string still doesn't after.

@ALavallee
Copy link
Contributor

We're not going to take any actions on that one. Unclear why CPython does it that way. It's probably faster for a very string intensive program but still.

@ALavallee ALavallee added the invalid This doesn't seem right label Apr 1, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working invalid This doesn't seem right
Projects
None yet
Development

No branches or pull requests

2 participants