Closed oscarbenjamin closed 2 years ago
Thanks for the report. I did not yet start testing with 3.11. I hope to get to it soon though.
This seems to be an issue with type casts with the new inline functions included in 3.11.x. I've created a CPython bug since I don't know if it is a bug with CPython or a bug with the kiwisolver code. See:
https://github.com/python/cpython/issues/93442
Using PyTuple_SetItem
fixes the issue but I don't know if the new PyTuple_SET_ITEM
is buggy or if the kiwi C++ source code is doing something not quite correct. I'm not a C++ expert.
The issue can be worked around by using nullptr, as per change below. However, I think the PyTuple_SET_ITEM()
and similar macros in CPython 3.11 should be changed to accept NULL/0 as null arguments.
diff --git a/py/src/symbolics.h b/py/src/symbolics.h
index 69ea540..1558063 100644
--- a/py/src/symbolics.h
+++ b/py/src/symbolics.h
@@ -123,7 +123,7 @@ PyObject* BinaryMul::operator()( Expression* first, double second )
return 0;
Py_ssize_t end = PyTuple_GET_SIZE( first->terms );
for( Py_ssize_t i = 0; i < end; ++i ) // memset 0 for safe error return
- PyTuple_SET_ITEM( terms.get(), i, 0 );
+ PyTuple_SET_ITEM( terms.get(), i, nullptr );
for( Py_ssize_t i = 0; i < end; ++i )
{
PyObject* item = PyTuple_GET_ITEM( first->terms, i );
diff --git a/py/src/util.h b/py/src/util.h
index 4b00fa7..1f40dc9 100644
--- a/py/src/util.h
+++ b/py/src/util.h
@@ -117,7 +117,7 @@ make_terms( const std::map<PyObject*, double>& coeffs )
return 0;
Py_ssize_t size = PyTuple_GET_SIZE( terms.get() );
for( Py_ssize_t i = 0; i < size; ++i ) // zero tuple for safe early return
- PyTuple_SET_ITEM( terms.get(), i, 0 );
+ PyTuple_SET_ITEM( terms.get(), i, nullptr );
Py_ssize_t i = 0;
iter_t it = coeffs.begin();
iter_t end = coeffs.end();
Thanks for investigating. I will make a PR with those changes while waiting to see if a fix lands in CPython and add 3.11 to the test matrix.
PR is at #142 and appears to work just fine. I will merge sometimes next week if nothing happens in the meantime.
Thanks!
The release process has started but the aarch build is real slow. Hopefully the wheels will appear on PyPI later today
The build is much longer than the typical duration I can see in the history. Maybe it's just randomly hanging ?
Right I will trig it again
The discussed fix appears to fail on MacOS ARM (see #144). I would appreciate if anybody with more C++ background has an idea on how to fix this for all compilers and architectures.
I think the following CPython patch may have made #142 unecessary : https://github.com/python/cpython/commit/8bcc3fa3453e28511d04eaa0aa7d8e1a3495d518
This patch was not yet shipped, and will (likely) be included only in Python 3.11.0b4 (scheduled for this Thursday). I hope this helps.
Thanks I will look into reverting the change once the beta is out.
@MatthieuDartiailh FYI Python 3.11.0b4 is now available after a couple weeks of delay :)
Thanks I am waiting for it to be available on GHA to merge the relevant PR.
It's been available on GHA for a couple hours
Everything seems to be installing fine for SymPy with 3.11b4: https://github.com/sympy/sympy/runs/7318381460
There is a test failure but it's unrelated to kiwi.
I merged the PR and will try to cut a new release soon.
This is from SymPy's CI: https://github.com/sympy/sympy/runs/6711439310?check_suite_focus=true
You can see the build steps here: https://github.com/sympy/sympy/blob/ff00553cf2a03ce048bf46c25c8a3cbe2a636c2c/.github/workflows/runtests.yml#L186-L200
I'm not sure which dependency pulls in kiwisolver but pip fails to build it on Ubuntu with Python 3.11b3 from these steps:
This was all working a week or so ago with Python 3.11b1 so I'm not sure what has changed.
The relevant part of the error message: