| 674 | } |
| 675 | |
| 676 | static PyObject * |
| 677 | record_get(PyObject *self, PyTypeObject *defcls, PyObject *const *args, |
| 678 | size_t nargsf, PyObject *kwnames) |
| 679 | { |
| 680 | Py_ssize_t nargs = PyVectorcall_NARGS(nargsf); |
| 681 | PyObject *key; |
| 682 | PyObject *defval = Py_None; |
| 683 | PyObject *val = NULL; |
| 684 | int res; |
| 685 | |
| 686 | if (nargs == 2) { |
| 687 | key = args[0]; |
| 688 | defval = args[1]; |
| 689 | } else if (nargs == 1) { |
| 690 | key = args[0]; |
| 691 | } else { |
| 692 | PyErr_Format(PyExc_TypeError, |
| 693 | "Record.get() expected 1 or 2 arguments, got %zd", |
| 694 | nargs); |
| 695 | return NULL; |
| 696 | } |
| 697 | |
| 698 | if (kwnames != NULL && PyTuple_GET_SIZE(kwnames) != 0) { |
| 699 | PyErr_SetString(PyExc_TypeError, "Record.get() takes no keyword arguments"); |
| 700 | return NULL; |
| 701 | } |
| 702 | |
| 703 | res = record_item_by_name((ApgRecordObject *)self, key, &val); |
| 704 | if (res == APG_ITEM_NOT_FOUND) { |
| 705 | PyErr_Clear(); |
| 706 | Py_INCREF(defval); |
| 707 | val = defval; |
| 708 | } |
| 709 | |
| 710 | return val; |
| 711 | } |
| 712 | |
| 713 | static PyObject * |
| 714 | record_new(PyTypeObject *type, PyObject *args, PyObject *kwargs) |
nothing calls this directly
no test coverage detected