Changed to sequence check
Changed _python2js_deep
Sequence types for example numpy arrays of objects are treated as buffers. Sequences in Python are Iterable and have len (sq_length) and get (sq_item). By checking that the PyObject* passed in is not a dictionary first only valid sequences will be converted as expected.
// One might consider trying to convert things that satisfy PyMapping_Check to // maps and things that satisfy PySequence_Check to lists. However // PyMapping_Check "returns 1 for Python classes with a __getitem__() method" // and PySequence_Check returns 1 for classes with a __getitem__ method that // don't subclass dict. For this reason, I think we should stick to subclasses.
However, by only checking PySequence_Check and checking PyDict_Check before ensures this is not the case.
Addresses issue: https://github.com/pyodide/pyodide/issues/4051
This is an interesting suggestion. I wonder why I originally put in the stricter check, I'll try and look at the git blame and see if we discussed this. We'll need a test and a change log entry.
Thanks @MatthewAndreTaylor!