MCPcopy Create free account
hub / github.com/MagicStack/asyncpg / record_get

Function record_get

asyncpg/protocol/record/recordobj.c:676–711  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

674}
675
676static PyObject *
677record_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
713static PyObject *
714record_new(PyTypeObject *type, PyObject *args, PyObject *kwargs)

Callers

nothing calls this directly

Calls 2

PyVectorcall_NARGSFunction · 0.85
record_item_by_nameFunction · 0.85

Tested by

no test coverage detected