+ Py_ssize_t n;
+
+ n = PyTuple_GET_SIZE(arg);
+ if (n < 2) TYERR("__init__() takes at least two arguments");
+ me = PyTuple_GET_ITEM(arg, 0);
+ err = PyInt_AsLong(PyTuple_GET_ITEM(arg, 1));
+ if (err == -1 && PyErr_Occurred()) goto end;
+ if (INT_MIN > err || err > INT_MAX) OVFERR("error code out of range");
- if (!PyArg_ParseTuple(arg, "Oi:__init__", &me, &err) ||
- (x = PyInt_FromLong(err)) == 0 ||
- PyObject_SetAttrString(me, "err", x))
- goto fail;
+ x = PyInt_FromLong(err); if (!x) goto end;
+ if (PyObject_SetAttrString(me, "err", x)) goto end;
- if ((x = PyString_FromString(key_strerror(err))) == 0 ||
- PyObject_SetAttrString(me, "errstring", x))
- goto fail;
+
+ x = PyString_FromString(key_strerror(err)); if (!x) goto end;
+ if (PyObject_SetAttrString(me, "errstring", x)) goto end;
- if ((x = PySequence_GetSlice(arg, 1, PySequence_Size(arg))) == 0 ||
- PyObject_SetAttrString(me, "args", x))
- goto fail;
+
+ x = PyTuple_GetSlice(arg, 1, n); if (!x) goto end;
+ if (PyObject_SetAttrString(me, "args", x)) goto end;
- METH (__init__, "KeyError(CODE)")
- METH (__str__, "E.__str__() -> STRING")
+ METH (__init__, "KeyError(CODE)")
+ METH (__str__, "E.__str__() -> STRING")
- if (!PyArg_ParseTupleAndKeywords(arg, kw, "|O&:copy", kwlist,
+ if (!PyArg_ParseTupleAndKeywords(arg, kw, "|O&:copy", KWLIST,
- if (!PyArg_ParseTupleAndKeywords(arg, kw, "|O&:write", kwlist,
+ if (!PyArg_ParseTupleAndKeywords(arg, kw, "|O&:write", KWLIST,
- if (!PyArg_ParseTupleAndKeywords(arg, kw, "|O&:encode", kwlist,
+ if (!PyArg_ParseTupleAndKeywords(arg, kw, "|O&:encode", KWLIST,
- METH (matchp, "KD.matchp(FILTER) -> BOOL")
- METH (split, "KD.split()")
- KWMETH(write, "KD.write([filter = <any>]) -> STRING")
- KWMETH(encode, "KD.encode([filter = <any>]) -> BYTES")
- KWMETH(copy, "KD.copy([filter = <any>]) -> KD")
- METH (plock, "KD.plock(TAG) -> ENCRYPTED-KD")
- METH (lock, "KD.lock(KEY) -> ENCRYPTED-KD")
+ METH (matchp, "KD.matchp(FILTER) -> BOOL")
+ METH (split, "KD.split()")
+ KWMETH(write, "KD.write([filter = <any>]) -> STRING")
+ KWMETH(encode, "KD.encode([filter = <any>]) -> BYTES")
+ KWMETH(copy, "KD.copy([filter = <any>]) -> KD")
+ METH (plock, "KD.plock(TAG) -> ENCRYPTED-KD")
+ METH (lock, "KD.lock(KEY) -> ENCRYPTED-KD")
#undef METHNAME
{ 0 }
};
static PyGetSetDef keydata_pygetset[] = {
#define GETSETNAME(op, name) kd##op##_##name
#undef METHNAME
{ 0 }
};
static PyGetSetDef keydata_pygetset[] = {
#define GETSETNAME(op, name) kd##op##_##name
- if (!PyArg_ParseTupleAndKeywords(arg, kw, "s#|O&:new", kwlist,
+ if (!PyArg_ParseTupleAndKeywords(arg, kw, "s#|O&:new", KWLIST,
static PyGetSetDef keydatabin_pygetset[] = {
#define GETSETNAME(op, name) kdb##op##_##name
static PyGetSetDef keydatabin_pygetset[] = {
#define GETSETNAME(op, name) kdb##op##_##name
- if (!PyArg_ParseTupleAndKeywords(arg, kw, "s#|O&:new", kwlist,
+ if (!PyArg_ParseTupleAndKeywords(arg, kw, "s#|O&:new", KWLIST,
- METH (plock, "KD.plock(TAG) -> ENCRYPTED-KD")
- METH (lock, "KD.lock(KEY) -> ENCRYPTED-KD")
- METH (punlock, "KD.punlock(TAG) -> KD")
- METH (unlock, "KD.unlock(KEY) -> KD")
+ METH (plock, "KD.plock(TAG) -> ENCRYPTED-KD")
+ METH (lock, "KD.lock(KEY) -> ENCRYPTED-KD")
+ METH (punlock, "KD.punlock(TAG) -> KD")
+ METH (unlock, "KD.unlock(KEY) -> KD")
#undef METHNAME
{ 0 }
};
static PyGetSetDef keydataenc_pygetset[] = {
#define GETSETNAME(op, name) kde##op##_##name
#undef METHNAME
{ 0 }
};
static PyGetSetDef keydataenc_pygetset[] = {
#define GETSETNAME(op, name) kde##op##_##name
- if (!PyArg_ParseTupleAndKeywords(arg, kw, "O&|O&:new", kwlist,
+ if (!PyArg_ParseTupleAndKeywords(arg, kw, "O&|O&:new", KWLIST,
convmp, &x, convflags, &f))
goto end;
me = (keydata_pyobj *)ty->tp_alloc(ty, 0);
convmp, &x, convflags, &f))
goto end;
me = (keydata_pyobj *)ty->tp_alloc(ty, 0);
static PyGetSetDef keydatamp_pygetset[] = {
#define GETSETNAME(op, name) kdm##op##_##name
static PyGetSetDef keydatamp_pygetset[] = {
#define GETSETNAME(op, name) kdm##op##_##name
- if (!PyArg_ParseTupleAndKeywords(arg, kw, "s|O&:new", kwlist,
+ if (!PyArg_ParseTupleAndKeywords(arg, kw, "s|O&:new", KWLIST,
static PyGetSetDef keydatastr_pygetset[] = {
#define GETSETNAME(op, name) kds##op##_##name
static PyGetSetDef keydatastr_pygetset[] = {
#define GETSETNAME(op, name) kds##op##_##name
- if (!PyArg_ParseTupleAndKeywords(arg, kw, "O&|O&:new", kwlist,
+ if (!PyArg_ParseTupleAndKeywords(arg, kw, "O&|O&:new", KWLIST,
convecpt, &x, convflags, &f))
goto end;
me = (keydata_pyobj *)ty->tp_alloc(ty, 0);
convecpt, &x, convflags, &f))
goto end;
me = (keydata_pyobj *)ty->tp_alloc(ty, 0);
static PyGetSetDef keydataec_pygetset[] = {
#define GETSETNAME(op, name) kde##op##_##name
static PyGetSetDef keydataec_pygetset[] = {
#define GETSETNAME(op, name) kde##op##_##name
- if (!PyArg_ParseTupleAndKeywords(arg, kw, "|O:new", kwlist, &sub))
+ if (!PyArg_ParseTupleAndKeywords(arg, kw, "|O:new", KWLIST, &sub))
- static char *kwlist[] = { "keyfile", "id", "type", "exptime", 0 };
+ static const char *const kwlist[] =
+ { "keyfile", "id", "type", "exptime", 0 };
- if (!PyArg_ParseTupleAndKeywords(arg, kw, "O!O&s|O&:new", kwlist,
+ if (!PyArg_ParseTupleAndKeywords(arg, kw, "O!O&s|O&:new", KWLIST,
keyfile_pytype, &kfobj, convu32, &id,
&type, convulong, &exptime))
goto end;
keyfile_pytype, &kfobj, convu32, &id,
&type, convulong, &exptime))
goto end;
- if (!PyArg_ParseTupleAndKeywords(arg, kw, "O!|O&:extract", kwlist,
+ if (!PyArg_ParseTupleAndKeywords(arg, kw, "O!|O&:extract", KWLIST,
- if (!PyArg_ParseTupleAndKeywords(arg, kw, "O&|O&:fingerprint", kwlist,
+ if (!PyArg_ParseTupleAndKeywords(arg, kw, "O&|O&:fingerprint", KWLIST,
convghash, &h, convfilter, &f))
return (0);
return (getbool(key_fingerprint(KEY_K(me), h, &f)));
convghash, &h, convfilter, &f))
return (0);
return (getbool(key_fingerprint(KEY_K(me), h, &f)));
- static char *kwlist[] = { "file", "how", "report", 0 };
+ static const char *const kwlist[] = { "file", "how", "report", 0 };
- if (!PyArg_ParseTupleAndKeywords(arg, kw, "s|iO:new", kwlist,
+ if (!PyArg_ParseTupleAndKeywords(arg, kw, "s|iO:new", KWLIST,
- if (!PyArg_ParseTupleAndKeywords(arg, kw, "O!|O:merge", kwlist,
+ if (!PyArg_ParseTupleAndKeywords(arg, kw, "O!|O:merge", KWLIST,
&PyFile_Type, &x, &ri.func))
goto end;
if (ri.func && !PyCallable_Check(ri.func))
&PyFile_Type, &x, &ri.func))
goto end;
if (ri.func && !PyCallable_Check(ri.func))
- static char *kwlist[] = { "id", "type", "exptime", 0 };
+ static const char *const kwlist[] = { "id", "type", "exptime", 0 };
- if (!PyArg_ParseTupleAndKeywords(arg, kw, "O&s|l:newkey", kwlist,
+ if (!PyArg_ParseTupleAndKeywords(arg, kw, "O&s|l:newkey", KWLIST,
convu32, &id, &type, &exptime))
goto end;
if ((err = key_new(KEYFILE_KF(me), id, type, exptime, &k)) != 0)
convu32, &id, &type, &exptime))
goto end;
if ((err = key_new(KEYFILE_KF(me), id, type, exptime, &k)) != 0)
- if (!PyArg_ParseTupleAndKeywords(arg, kw, "s|O!:qtag", kwlist,
+ if (!PyArg_ParseTupleAndKeywords(arg, kw, "s|O!:qtag", KWLIST,
&tag, keydata_pytype, &newkdobj))
goto end;
if (key_qtag(KEYFILE_KF(me), tag, &d, &k, &kd))
&tag, keydata_pytype, &newkdobj))
goto end;
if (key_qtag(KEYFILE_KF(me), tag, &d, &k, &kd))
#define METHNAME(func) kfmeth_##func
METH (save, "KF.save()")
KWMETH(merge, "KF.merge(FILE, [report = <built-in-reporter>])")
#define METHNAME(func) kfmeth_##func
METH (save, "KF.save()")
KWMETH(merge, "KF.merge(FILE, [report = <built-in-reporter>])")
- KWMETH(newkey, "KF.newkey(ID, TYPE, "
- "[exptime = KEXP_FOREVER]) -> KEY")
+ KWMETH(newkey, "KF.newkey(ID, TYPE, [exptime = KEXP_FOREVER]) "
+ "-> KEY")
METH (byid, "KF.byid(KEYID) -> KEY|None")
METH (bytype, "KF.bytype(TYPE) -> KEY|None")
METH (bytag, "KF.bytag(TAG) -> KEY|None")
METH (byid, "KF.byid(KEYID) -> KEY|None")
METH (bytype, "KF.bytype(TYPE) -> KEY|None")
METH (bytag, "KF.bytag(TAG) -> KEY|None")
+ "KeyFile(FILE, [how = KOPEN_READ], [report = ?]): Keyring file.\n"
+ " calls REPORT(FILE, LINE, MSG) on problems",
- METH (_KeyData_readflags,
- "KeyData.readflags(STRING) -> (FLAGS, MASK, REST)")
- METH (_KeyData_writeflags, "KeyData.writeflags(FLAGS) -> STRING")
- METH (_KeyData_read, "KeyData.read(STRING) -> (KD, REST)")
- METH (_KeyData_decode, "KeyData.decode(BYTES) -> KD")
- METH (barf, "barf(ERR)")
+ METH (_KeyData_readflags, "KeyData.readflags(STRING) "
+ "-> (FLAGS, MASK, REST)")
+ METH (_KeyData_writeflags, "KeyData.writeflags(FLAGS) -> STRING")
+ METH (_KeyData_read, "KeyData.read(STRING) -> (KD, REST)")
+ METH (_KeyData_decode, "KeyData.decode(BYTES) -> KD")