Allow taking None in Abi.fromStr

This commit is contained in:
Angie 2022-07-12 19:01:36 -04:00
parent a5ef766311
commit 9300da772e
3 changed files with 3 additions and 3 deletions

View File

@ -15,7 +15,7 @@ class Abi:
N64: Enum
@staticmethod
def fromStr(name: str) -> Enum: ...
def fromStr(name: str | None) -> Enum: ...
class _RabbitizerConfig:

View File

@ -24,7 +24,7 @@ static PyObject *rabbitizer_enum_Abi_fromStr(UNUSED PyObject *self, PyObject *ar
RabbitizerAbi abi;
PyObject *ret;
if (!PyArg_ParseTupleAndKeywords(args, kwds, "s", kwlist, &name)) {
if (!PyArg_ParseTupleAndKeywords(args, kwds, "z", kwlist, &name)) {
return NULL;
}

View File

@ -6,7 +6,7 @@
#include <string.h>
RabbitizerAbi RabbitizerAbi_fromStr(const char *name) {
if (strcmp(name, "32") == 0 || strcmp(name, "o32") == 0 || strcmp(name, "O32") == 0) {
if (name == NULL || strcmp(name, "32") == 0 || strcmp(name, "o32") == 0 || strcmp(name, "O32") == 0) {
return RABBITIZER_ABI_O32;
}
if (strcmp(name, "n32") == 0 || strcmp(name, "N32") == 0) {