From 9300da772e8a63f143d46302586c670c5c5f5f49 Mon Sep 17 00:00:00 2001 From: Angie Date: Tue, 12 Jul 2022 19:01:36 -0400 Subject: [PATCH] Allow taking `None` in `Abi.fromStr` --- rabbitizer/Config.pyi | 2 +- rabbitizer/enums/rabbitizer_enum_Abi.c | 2 +- src/common/RabbitizerConfig.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/rabbitizer/Config.pyi b/rabbitizer/Config.pyi index 4894310..786642f 100644 --- a/rabbitizer/Config.pyi +++ b/rabbitizer/Config.pyi @@ -15,7 +15,7 @@ class Abi: N64: Enum @staticmethod - def fromStr(name: str) -> Enum: ... + def fromStr(name: str | None) -> Enum: ... class _RabbitizerConfig: diff --git a/rabbitizer/enums/rabbitizer_enum_Abi.c b/rabbitizer/enums/rabbitizer_enum_Abi.c index 634058f..a0d5fb0 100644 --- a/rabbitizer/enums/rabbitizer_enum_Abi.c +++ b/rabbitizer/enums/rabbitizer_enum_Abi.c @@ -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; } diff --git a/src/common/RabbitizerConfig.c b/src/common/RabbitizerConfig.c index a6756dc..37d43e2 100644 --- a/src/common/RabbitizerConfig.c +++ b/src/common/RabbitizerConfig.c @@ -6,7 +6,7 @@ #include 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) {