| 873 | } |
| 874 | |
| 875 | PyObject* Flatten(PyObject* nested, bool expand_composites) { |
| 876 | PyObject* list = PyList_New(0); |
| 877 | const std::function<int(PyObject*)>& is_sequence_helper = |
| 878 | expand_composites ? IsSequenceOrCompositeHelper : IsSequenceHelper; |
| 879 | const std::function<ValueIteratorPtr(PyObject*)>& get_value_iterator = |
| 880 | expand_composites ? GetValueIteratorForComposite : GetValueIterator; |
| 881 | if (FlattenHelper(nested, list, is_sequence_helper, get_value_iterator)) { |
| 882 | return list; |
| 883 | } else { |
| 884 | Py_DECREF(list); |
| 885 | return nullptr; |
| 886 | } |
| 887 | } |
| 888 | |
| 889 | bool IsSequenceOrComposite(PyObject* o) { |
| 890 | return IsSequenceOrCompositeHelper(o) == 1; |
no test coverage detected