/* forward declaration */
static PyTypeObject UCD_Type;
-#define UCD_Check(o) Py_IS_TYPE(o, &UCD_Type)
+
+// Check if self is an instance of UCD_Type.
+// Return 0 if self is NULL (when the PyCapsule C API is used).
+#define UCD_Check(self, ucd_type) (self != NULL && Py_IS_TYPE(self, ucd_type))
static PyObject*
new_previous_version(const char*name, const change_record* (*getrecord)(Py_UCS4),
long rc;
Py_UCS4 c = (Py_UCS4)chr;
- if (self && UCD_Check(self)) {
+ if (UCD_Check(self, &UCD_Type)) {
const change_record *old = get_old_record(self, c);
if (old->category_changed == 0) {
/* unassigned */
double rc;
Py_UCS4 c = (Py_UCS4)chr;
- if (self && UCD_Check(self)) {
+ if (UCD_Check(self, &UCD_Type)) {
const change_record *old = get_old_record(self, c);
if (old->category_changed == 0) {
/* unassigned */
int index;
Py_UCS4 c = (Py_UCS4)chr;
index = (int) _getrecord_ex(c)->category;
- if (self && UCD_Check(self)) {
+ if (UCD_Check(self, &UCD_Type)) {
const change_record *old = get_old_record(self, c);
if (old->category_changed != 0xFF)
index = old->category_changed;
int index;
Py_UCS4 c = (Py_UCS4)chr;
index = (int) _getrecord_ex(c)->bidirectional;
- if (self && UCD_Check(self)) {
+ if (UCD_Check(self, &UCD_Type)) {
const change_record *old = get_old_record(self, c);
if (old->category_changed == 0)
index = 0; /* unassigned */
int index;
Py_UCS4 c = (Py_UCS4)chr;
index = (int) _getrecord_ex(c)->combining;
- if (self && UCD_Check(self)) {
+ if (UCD_Check(self, &UCD_Type)) {
const change_record *old = get_old_record(self, c);
if (old->category_changed == 0)
index = 0; /* unassigned */
int index;
Py_UCS4 c = (Py_UCS4)chr;
index = (int) _getrecord_ex(c)->mirrored;
- if (self && UCD_Check(self)) {
+ if (UCD_Check(self, &UCD_Type)) {
const change_record *old = get_old_record(self, c);
if (old->category_changed == 0)
index = 0; /* unassigned */
int index;
Py_UCS4 c = (Py_UCS4)chr;
index = (int) _getrecord_ex(c)->east_asian_width;
- if (self && UCD_Check(self)) {
+ if (UCD_Check(self, &UCD_Type)) {
const change_record *old = get_old_record(self, c);
if (old->category_changed == 0)
index = 0; /* unassigned */
code = (int)c;
- if (self && UCD_Check(self)) {
+ if (UCD_Check(self, &UCD_Type)) {
const change_record *old = get_old_record(self, c);
if (old->category_changed == 0)
return PyUnicode_FromString(""); /* unassigned */
{
if (code >= 0x110000) {
*index = 0;
- } else if (self && UCD_Check(self) &&
+ } else if (UCD_Check(self, &UCD_Type) &&
get_old_record(self, code)->category_changed==0) {
/* unassigned in old version */
*index = 0;
continue;
}
/* normalization changes */
- if (self && UCD_Check(self)) {
+ if (UCD_Check(self, &UCD_Type)) {
Py_UCS4 value = ((PreviousDBVersion*)self)->normalization(code);
if (value != 0) {
stack[stackptr++] = value;
{
/* An older version of the database is requested, quickchecks must be
disabled. */
- if (self && UCD_Check(self))
+ if (UCD_Check(self, &UCD_Type))
return NO;
Py_ssize_t i, len;
if (!with_alias_and_seq && (IS_ALIAS(code) || IS_NAMED_SEQ(code)))
return 0;
- if (self && UCD_Check(self)) {
+ if (UCD_Check(self, &UCD_Type)) {
/* in 3.2.0 there are no aliases and named sequences */
const change_record *old;
if (IS_ALIAS(code) || IS_NAMED_SEQ(code))