Skip to content

Commit 01777ff

Browse files
committed
Apply PyObject_TypeCheck when possible
1 parent 47f3e4b commit 01777ff

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

src/cstring.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ static void cstring_dealloc(PyObject *self) {
4949
static PyTypeObject cstring_type;
5050

5151
static int _ensure_cstring(PyObject *self) {
52-
if(Py_TYPE(self) == &cstring_type)
52+
if(PyObject_TypeCheck(self, &cstring_type))
5353
return 1;
5454
PyErr_Format(
5555
PyExc_TypeError,
@@ -201,7 +201,7 @@ static PyObject *cstring_subscript(PyObject *self, PyObject *key) {
201201
static const char *_obj_to_utf8(PyObject *o, Py_ssize_t *len_p) {
202202
if(PyUnicode_Check(o))
203203
return PyUnicode_AsUTF8AndSize(o, len_p);
204-
if(Py_TYPE(o) == &cstring_type) {
204+
if(PyObject_TypeCheck(o, &cstring_type)) {
205205
*len_p = cstring_len(o);
206206
return CSTRING_VALUE(o);
207207
}

0 commit comments

Comments
 (0)