Skip to content

Commit ca52fd2

Browse files
committed
fix: reject None data in tp_init, matching hashlib
Remove data_obj != Py_None check so None triggers _get_buffer_or_str which raises TypeError via PyObject_GetBuffer, consistent with hashlib.md5(None) behavior.
1 parent 781ac15 commit ca52fd2

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

src/_xxhash.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -529,7 +529,7 @@ static int PYXXH32_init(PYXXH32Object *self, PyObject *args, PyObject *kwargs)
529529
return -1;
530530
}
531531

532-
if (data_obj && data_obj != Py_None) {
532+
if (data_obj) {
533533
if (_get_buffer_or_str(data_obj, &buf) < 0)
534534
return -1;
535535
}
@@ -884,7 +884,7 @@ static int PYXXH64_init(PYXXH64Object *self, PyObject *args, PyObject *kwargs)
884884
return -1;
885885
}
886886

887-
if (data_obj && data_obj != Py_None) {
887+
if (data_obj) {
888888
if (_get_buffer_or_str(data_obj, &buf) < 0)
889889
return -1;
890890
}
@@ -1238,7 +1238,7 @@ static int PYXXH3_64_init(PYXXH3_64Object *self, PyObject *args, PyObject *kwarg
12381238
return -1;
12391239
}
12401240

1241-
if (data_obj && data_obj != Py_None) {
1241+
if (data_obj) {
12421242
if (_get_buffer_or_str(data_obj, &buf) < 0)
12431243
return -1;
12441244
}
@@ -1601,7 +1601,7 @@ static int PYXXH3_128_init(PYXXH3_128Object *self, PyObject *args, PyObject *kwa
16011601
return -1;
16021602
}
16031603

1604-
if (data_obj && data_obj != Py_None) {
1604+
if (data_obj) {
16051605
if (_get_buffer_or_str(data_obj, &buf) < 0)
16061606
return -1;
16071607
}

0 commit comments

Comments
 (0)