Skip to content

Commit

Permalink
Fix some problems related to default operators
Browse files Browse the repository at this point in the history
  • Loading branch information
GrieferAtWork committed May 5, 2024
1 parent ea5c8db commit 3c6125e
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 10 deletions.
4 changes: 2 additions & 2 deletions src/deemon/compiler/asm/assembler.c
Original file line number Diff line number Diff line change
Expand Up @@ -1956,7 +1956,7 @@ relint_compare_eq(DeeRelIntObject *self, DeeRelIntObject *other) {

PRIVATE WUNUSED NONNULL((1, 2)) int DCALL
relint_trycompare_eq(DeeRelIntObject *self, DeeRelIntObject *other) {
if (DeeObject_AssertTypeExact(other, &DeeRelInt_Type))
if (!DeeObject_InstanceOfExact(other, &DeeRelInt_Type))
return -1;
return (self->ri_sym == other->ri_sym &&
self->ri_add == other->ri_add &&
Expand All @@ -1977,7 +1977,7 @@ INTERN DeeTypeObject DeeRelInt_Type = {
OBJECT_HEAD_INIT(&DeeType_Type),
/* .tp_name = */ "_RelInt",
/* .tp_doc = */ NULL,
/* .tp_flags = */ TP_FNORMAL|TP_FFINAL,
/* .tp_flags = */ TP_FNORMAL | TP_FFINAL,
/* .tp_weakrefs = */ 0,
/* .tp_features = */ TF_NONE,
/* .tp_base = */ &DeeObject_Type,
Expand Down
2 changes: 1 addition & 1 deletion src/deemon/objects/attribute.c
Original file line number Diff line number Diff line change
Expand Up @@ -1079,7 +1079,7 @@ enumattr_longjmp(DeeObject *__restrict declarator,
} else {
new_attribute->a_info.a_doc = attr_doc;
}
Dee_XIncref(declarator);
Dee_Incref(declarator);
Dee_XIncref(attr_type);
DeeObject_Init(new_attribute, &DeeAttribute_Type);

Expand Down
15 changes: 12 additions & 3 deletions src/deemon/objects/seq_functions.c
Original file line number Diff line number Diff line change
Expand Up @@ -2085,8 +2085,11 @@ DeeSeq_EqVS(DeeObject *const *lhsv, size_t lhsc,
} else {
DREF DeeObject *rhs_iter;
rhs_iter = DeeObject_Iter(rhs);
if unlikely(!rhs_iter)
if unlikely(!rhs_iter) {
if (DeeError_Catch(&DeeError_NotImplemented))
return 0;
return -1;
}
result = DeeSeq_EqVI(lhsv, lhsc, rhs_iter);
Dee_Decref(rhs_iter);
}
Expand Down Expand Up @@ -2183,8 +2186,11 @@ DeeSeq_EqFS(DeeObject *lhs, size_t lhsc, DeeObject *rhs) {
} else {
DREF DeeObject *rhs_iter;
rhs_iter = DeeObject_Iter(rhs);
if unlikely(!rhs_iter)
if unlikely(!rhs_iter) {
if (DeeError_Catch(&DeeError_NotImplemented))
return 0;
return -1;
}
result = DeeSeq_EqFI(lhs, lhsc, rhs_iter);
Dee_Decref(rhs_iter);
}
Expand Down Expand Up @@ -2300,8 +2306,11 @@ DeeSeq_EqIS(DeeObject *lhs, DeeObject *rhs) {
} else {
DREF DeeObject *rhs_iter;
rhs_iter = DeeObject_Iter(rhs);
if unlikely(!rhs_iter)
if unlikely(!rhs_iter) {
if (DeeError_Catch(&DeeError_NotImplemented))
return 0;
return -1;
}
result = DeeSeq_EqII(lhs, rhs_iter);
Dee_Decref(rhs_iter);
}
Expand Down
5 changes: 1 addition & 4 deletions src/deemon/runtime/operator.c
Original file line number Diff line number Diff line change
Expand Up @@ -1558,12 +1558,9 @@ DEFINE_INTERNAL_OPERATOR(DREF DeeObject *, DefaultStrWithPrint, (DeeObject *REST
Dee_ssize_t print_error;
struct unicode_printer printer = UNICODE_PRINTER_INIT;
LOAD_TP_SELF;
ASSERT(tp_self->tp_cast.tp_print);
ASSERT(tp_self->tp_cast.tp_print != &DeeObject_DefaultPrintWithStr);
print_error = DeeType_INVOKE_PRINTREPR_NODEFAULT(tp_self, self, &unicode_printer_print, &printer);
ASSERT(tp_self->tp_cast.tp_print &&
tp_self->tp_cast.tp_print != &DeeObject_DefaultPrintWithStr);
print_error = DeeType_INVOKE_PRINT(tp_self, self, &unicode_printer_print, &printer);
print_error = DeeType_INVOKE_PRINT_NODEFAULT(tp_self, self, &unicode_printer_print, &printer);
if unlikely(print_error < 0)
goto err;
return unicode_printer_pack(&printer);
Expand Down

0 comments on commit 3c6125e

Please sign in to comment.