@@ -897,7 +897,7 @@ _textiowrapper_decode(PyObject *decoder, PyObject *bytes, int eof)
897897{
898898 PyObject *chars;
899899
900- if (Py_TYPE (decoder) == &PyIncrementalNewlineDecoder_Type)
900+ if (Py_IS_TYPE (decoder, &PyIncrementalNewlineDecoder_Type) )
901901 chars = _PyIncrementalNewlineDecoder_decode(decoder, bytes, eof);
902902 else
903903 chars = PyObject_CallMethodObjArgs(decoder, _PyIO_str_decode, bytes,
@@ -1226,15 +1226,15 @@ _io_TextIOWrapper___init___impl(textio *self, PyObject *buffer,
12261226 /* Finished sorting out the codec details */
12271227 Py_CLEAR(codec_info);
12281228
1229- if (Py_TYPE (buffer) == &PyBufferedReader_Type ||
1230- Py_TYPE (buffer) == &PyBufferedWriter_Type ||
1231- Py_TYPE (buffer) == &PyBufferedRandom_Type)
1229+ if (Py_IS_TYPE (buffer, &PyBufferedReader_Type) ||
1230+ Py_IS_TYPE (buffer, &PyBufferedWriter_Type) ||
1231+ Py_IS_TYPE (buffer, &PyBufferedRandom_Type) )
12321232 {
12331233 if (_PyObject_LookupAttrId(buffer, &PyId_raw, &raw) < 0)
12341234 goto error;
12351235 /* Cache the raw FileIO object to speed up 'closed' checks */
12361236 if (raw != NULL) {
1237- if (Py_TYPE (raw) == &PyFileIO_Type)
1237+ if (Py_IS_TYPE (raw, &PyFileIO_Type) )
12381238 self->raw = raw;
12391239 else
12401240 Py_DECREF(raw);
@@ -1466,7 +1466,7 @@ textiowrapper_closed_get(textio *self, void *context);
14661466 do { \
14671467 int r; \
14681468 PyObject *_res; \
1469- if (Py_TYPE (self) == &PyTextIOWrapper_Type) { \
1469+ if (Py_IS_TYPE (self, &PyTextIOWrapper_Type) ) { \
14701470 if (self->raw != NULL) \
14711471 r = _PyFileIO_closed(self->raw); \
14721472 else { \
@@ -1937,7 +1937,7 @@ _io_TextIOWrapper_read_impl(textio *self, Py_ssize_t n)
19371937 if (bytes == NULL)
19381938 goto fail;
19391939
1940- if (Py_TYPE (self->decoder) == &PyIncrementalNewlineDecoder_Type)
1940+ if (Py_IS_TYPE (self->decoder, &PyIncrementalNewlineDecoder_Type) )
19411941 decoded = _PyIncrementalNewlineDecoder_decode(self->decoder,
19421942 bytes, 1);
19431943 else
@@ -3079,7 +3079,7 @@ textiowrapper_iternext(textio *self)
30793079 CHECK_ATTACHED(self);
30803080
30813081 self->telling = 0;
3082- if (Py_TYPE (self) == &PyTextIOWrapper_Type) {
3082+ if (Py_IS_TYPE (self, &PyTextIOWrapper_Type) ) {
30833083 /* Skip method call overhead for speed */
30843084 line = _textiowrapper_readline(self, -1);
30853085 }
0 commit comments