char sha[20];
int i;
- if (!PyString_Check(py_hexsha)) {
+ if (!PyString_CheckExact(py_hexsha)) {
PyErr_SetString(PyExc_TypeError, "hex sha is not a string");
return NULL;
}
static PyObject *py_sha_to_hex(PyObject *self, PyObject *py_sha)
{
- if (!PyString_Check(py_sha)) {
+ if (!PyString_CheckExact(py_sha)) {
PyErr_SetString(PyExc_TypeError, "sha is not a string");
return NULL;
}
Py_DECREF(name);
return NULL;
}
- PyDict_SetItem(ret, name, item);
+ if (PyDict_SetItem(ret, name, item) == -1) {
+ Py_DECREF(ret);
+ Py_DECREF(item);
+ return NULL;
+ }
Py_DECREF(name);
Py_DECREF(item);
static int py_is_sha(PyObject *sha)
{
- if (!PyString_Check(sha))
+ if (!PyString_CheckExact(sha))
return 0;
if (PyString_Size(sha) != 20)