@@ -221,37 +221,37 @@ namespace {
221221 void operator ()(intptr_t arg0, intptr_t arg1, intptr_t arg2) { callv (arg0, arg1, arg2); }
222222 };
223223
224- static std::vector<std::string> cseq (PyObject* coll)
225- {
226- if (!coll) {
227- return std::vector<std::string>{};
228- }
229-
230- // coll is guaranteed to be a list or tuple (from PySequence_Fast)
231- Py_ssize_t len = PySequence_Fast_GET_SIZE (coll);
232- std::vector<std::string> cargs;
233- cargs.reserve (static_cast <size_t >(len));
234-
235- PyObject** items = PySequence_Fast_ITEMS (coll);
236- for (Py_ssize_t i = 0 ; i < len; ++i) {
237- PyObject* item = items[i]; // borrowed reference
238- if (!PyUnicode_Check (item)) {
239- PyErr_Format (PyExc_TypeError, " item %d must be a string" , (int )i);
240- return std::vector<std::string>{}; // Error set
224+ static std::vector<std::string> cseq (PyObject* coll)
225+ {
226+ if (!coll) {
227+ return std::vector<std::string>{};
241228 }
242229
243- char const * p = PyUnicode_AsUTF8 (item);
244- if (!p) {
245- return std::vector<std::string>{}; // Error already set
230+ // coll is guaranteed to be a list or tuple (from PySequence_Fast)
231+ Py_ssize_t len = PySequence_Fast_GET_SIZE (coll);
232+ std::vector<std::string> cargs;
233+ cargs.reserve (static_cast <size_t >(len));
234+
235+ PyObject** items = PySequence_Fast_ITEMS (coll);
236+ for (Py_ssize_t i = 0 ; i < len; ++i) {
237+ PyObject* item = items[i]; // borrowed reference
238+ if (!PyUnicode_Check (item)) {
239+ PyErr_Format (PyExc_TypeError, " item %d must be a string" , (int )i);
240+ return std::vector<std::string>{}; // Error set
241+ }
242+
243+ char const * p = PyUnicode_AsUTF8 (item);
244+ if (!p) {
245+ return std::vector<std::string>{}; // Error already set
246+ }
247+
248+ Py_ssize_t sz = PyUnicode_GetLength (item);
249+ cargs.emplace_back (p, static_cast <std::string::size_type>(sz));
246250 }
247251
248- Py_ssize_t sz = PyUnicode_GetLength (item);
249- cargs.emplace_back (p, static_cast <std::string::size_type>(sz));
252+ return cargs;
250253 }
251254
252- return cargs;
253- }
254-
255255} // unnamed namespace
256256
257257namespace {
@@ -546,35 +546,35 @@ static PyObject* parse_args(PyObject* args,
546546 return nullptr ;
547547 }
548548
549- // Accept any sequence type (list, tuple, custom sequences)
550- PyObject* input_fast = PySequence_Fast (input, " input_family must be a sequence" );
551- if (!input_fast) {
552- return nullptr ; // TypeError already set by PySequence_Fast
553- }
549+ // Accept any sequence type (list, tuple, custom sequences)
550+ PyObject* input_fast = PySequence_Fast (input, " input_family must be a sequence" );
551+ if (!input_fast) {
552+ return nullptr ; // TypeError already set by PySequence_Fast
553+ }
554554
555- PyObject* output_fast = nullptr ;
556- if (output) {
557- output_fast = PySequence_Fast (output, " output_products must be a sequence" );
558- if (!output_fast) {
559- Py_DECREF (input_fast);
560- return nullptr ;
555+ PyObject* output_fast = nullptr ;
556+ if (output) {
557+ output_fast = PySequence_Fast (output, " output_products must be a sequence" );
558+ if (!output_fast) {
559+ Py_DECREF (input_fast);
560+ return nullptr ;
561+ }
561562 }
562- }
563563
564- // convert input and output declarations, to be able to pass them to Phlex
565- input_labels = cseq (input_fast);
566- output_labels = cseq (output_fast);
564+ // convert input and output declarations, to be able to pass them to Phlex
565+ input_labels = cseq (input_fast);
566+ output_labels = cseq (output_fast);
567567
568- // Clean up fast sequences
569- Py_DECREF (input_fast);
570- Py_XDECREF (output_fast);
568+ // Clean up fast sequences
569+ Py_DECREF (input_fast);
570+ Py_XDECREF (output_fast);
571571
572- if (output_labels.size () > 1 ) {
573- PyErr_SetString (PyExc_TypeError, " only a single output supported" );
574- return nullptr ;
575- }
572+ if (output_labels.size () > 1 ) {
573+ PyErr_SetString (PyExc_TypeError, " only a single output supported" );
574+ return nullptr ;
575+ }
576576
577- // retrieve C++ (matching) types from annotations
577+ // retrieve C++ (matching) types from annotations
578578 input_types.reserve (input_labels.size ());
579579
580580 PyObject* sann = PyUnicode_FromString (" __annotations__" );
0 commit comments