Skip to content

Commit f0893b7

Browse files
committed
simpler checks
1 parent 2583095 commit f0893b7

File tree

1 file changed

+2
-5
lines changed

1 file changed

+2
-5
lines changed

Objects/exceptions.c

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2680,10 +2680,7 @@ as_unicode_error_attribute(PyObject *attr, const char *name, int as_bytes)
26802680
PyErr_Format(PyExc_TypeError, "%.200s attribute not set", name);
26812681
return NULL;
26822682
}
2683-
if (!PyType_FastSubclass(
2684-
Py_TYPE(attr),
2685-
as_bytes ? Py_TPFLAGS_BYTES_SUBCLASS : Py_TPFLAGS_UNICODE_SUBCLASS
2686-
)) {
2683+
if (!(as_bytes ? PyBytes_Check(attr) : PyUnicode_Check(attr))) {
26872684
PyErr_Format(PyExc_TypeError,
26882685
"%.200s attribute must be %s, not %T",
26892686
name, as_bytes ? "bytes" : "unicode");
@@ -2793,7 +2790,7 @@ unicode_error_get_object_and_size(PyObject *self,
27932790
return -1;
27942791
}
27952792
if (size != NULL) {
2796-
*size = as_bytes ? PyBytes_GET_SIZE(obj) : PyUnicode_GetLength(obj);
2793+
*size = as_bytes ? PyBytes_GET_SIZE(obj) : PyUnicode_GET_LENGTH(obj);
27972794
}
27982795
if (result != NULL) {
27992796
*result = obj;

0 commit comments

Comments
 (0)