Skip to content

Commit c7c1e35

Browse files
committed
build in release mode by default; fix bugs revealed
1 parent ebbedec commit c7c1e35

File tree

4 files changed

+31
-8
lines changed

4 files changed

+31
-8
lines changed

stringdtype/pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,6 @@ per-file-ignores = {"__init__.py" = ["F401"]}
3535

3636
[tool.meson-python.args]
3737
dist = []
38-
setup = ["-Dbuildtype=debug"]
38+
setup = []
3939
compile = []
4040
install = []

stringdtype/stringdtype/src/casts.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -388,6 +388,7 @@ string_to_unicode(PyArrayMethod_Context *context, char *const data[],
388388
}
389389
else {
390390
this_string = (unsigned char *)(default_string.buf);
391+
n_bytes = default_string.len;
391392
}
392393
}
393394
else {

stringdtype/stringdtype/src/dtype.c

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -661,7 +661,7 @@ StringDType_richcompare(PyObject *self, PyObject *other, int op)
661661
StringDTypeObject *sself = (StringDTypeObject *)self;
662662
StringDTypeObject *sother = (StringDTypeObject *)other;
663663

664-
int eq;
664+
int eq = 0;
665665
PyObject *sna = sself->na_object;
666666
PyObject *ona = sother->na_object;
667667

@@ -706,6 +706,22 @@ StringDType_richcompare(PyObject *self, PyObject *other, int op)
706706
return ret;
707707
}
708708

709+
static Py_hash_t
710+
StringDType_hash(StringDTypeObject *self)
711+
{
712+
PyObject *hash_tup = NULL;
713+
if (self->na_object != NULL) {
714+
hash_tup = Py_BuildValue("(iO)", self->coerce, self->na_object);
715+
}
716+
else {
717+
hash_tup = Py_BuildValue("(i)", self->coerce);
718+
}
719+
720+
Py_hash_t ret = PyObject_Hash(hash_tup);
721+
Py_DECREF(hash_tup);
722+
return ret;
723+
}
724+
709725
/*
710726
* This is the basic things that you need to create a Python Type/Class in C.
711727
* However, there is a slight difference here because we create a
@@ -724,6 +740,7 @@ StringDType_type StringDType = {
724740
.tp_methods = StringDType_methods,
725741
.tp_members = StringDType_members,
726742
.tp_richcompare = StringDType_richcompare,
743+
.tp_hash = StringDType_hash,
727744
}}},
728745
/* rest, filled in during DTypeMeta initialization */
729746
};

stringdtype/stringdtype/src/umath.c

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -871,17 +871,22 @@ init_ufunc(PyObject *numpy, const char *ufunc_name, PyArray_DTypeMeta **dtypes,
871871
.casting = casting,
872872
.flags = flags,
873873
.dtypes = dtypes,
874+
.slots = NULL,
874875
};
875876

877+
PyType_Slot resolve_slots[] = {
878+
{NPY_METH_resolve_descriptors, resolve_func},
879+
{NPY_METH_strided_loop, loop_func},
880+
{0, NULL}};
881+
882+
PyType_Slot strided_slots[] = {{NPY_METH_strided_loop, loop_func},
883+
{0, NULL}};
884+
876885
if (resolve_func == NULL) {
877-
PyType_Slot slots[] = {{NPY_METH_strided_loop, loop_func}, {0, NULL}};
878-
spec.slots = slots;
886+
spec.slots = strided_slots;
879887
}
880888
else {
881-
PyType_Slot slots[] = {{NPY_METH_resolve_descriptors, resolve_func},
882-
{NPY_METH_strided_loop, loop_func},
883-
{0, NULL}};
884-
spec.slots = slots;
889+
spec.slots = resolve_slots;
885890
}
886891

887892
if (PyUFunc_AddLoopFromSpec(ufunc, &spec) < 0) {

0 commit comments

Comments
 (0)