| 4460 | " 1"; |
| 4461 | |
| 4462 | static PyObject *Str_like_utf8_count(PyObject *self, PyObject *const *args, Py_ssize_t positional_args_count, |
| 4463 | PyObject *args_names_tuple) { |
| 4464 | // Check minimum arguments |
| 4465 | int is_member = self != NULL && PyObject_TypeCheck(self, &StrType); |
| 4466 | Py_ssize_t min_args = !is_member; |
| 4467 | Py_ssize_t max_args = !is_member; |
| 4468 | if (positional_args_count < min_args || positional_args_count > max_args) { |
| 4469 | PyErr_Format(PyExc_TypeError, "utf8_count() takes exactly %zd argument(s)", min_args); |
| 4470 | return NULL; |
| 4471 | } |
| 4472 | |
| 4473 | // No keyword arguments expected |
| 4474 | if (args_names_tuple && PyTuple_GET_SIZE(args_names_tuple) > 0) { |
| 4475 | PyErr_SetString(PyExc_TypeError, "utf8_count() takes no keyword arguments"); |
| 4476 | return NULL; |
| 4477 | } |
| 4478 | |
| 4479 | PyObject *text_obj = is_member ? self : args[0]; |
| 4480 | sz_string_view_t text; |
| 4481 | |
| 4482 | // Validate and convert `text` |
| 4483 | if (!sz_py_export_string_like(text_obj, &text.start, &text.length)) { |
| 4484 | wrap_current_exception("The text argument must be string-like"); |
| 4485 | return NULL; |
| 4486 | } |
| 4487 | |
| 4488 | sz_size_t count = sz_utf8_count(text.start, text.length); |
| 4489 | return PyLong_FromSize_t(count); |
| 4490 | } |
| 4491 | |
| 4492 | static char const doc_utf8_splitlines_iter[] = // |
| 4493 | "Create an iterator for splitting a string by Unicode newline characters.\n" |
nothing calls this directly
no test coverage detected
searching dependent graphs…