From 015bb4fa79d01a1e2d4887cba96d150c7e1dd3bb Mon Sep 17 00:00:00 2001 From: Glenn Smith Date: Wed, 12 Jun 2024 21:59:50 -0400 Subject: [Enterprise] Clean up initialization flow --- python/generator.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'python/generator.cpp') diff --git a/python/generator.cpp b/python/generator.cpp index 3fdf1fc1..c40d8d08 100644 --- a/python/generator.cpp +++ b/python/generator.cpp @@ -567,7 +567,10 @@ int main(int argc, char* argv[]) // Emit wrapper to get Python string and free native memory fprintf(out, "\tresult = "); fprintf(out, "%s\n", stringArgFuncCall.c_str()); - fprintf(out, "\tstring = str(pyNativeStr(ctypes.cast(result, ctypes.c_char_p).value))\n"); + fprintf(out, "\tcasted = ctypes.cast(result, ctypes.c_char_p).value\n"); + fprintf(out, "\tif casted is None:\n"); + fprintf(out, "\t\treturn None\n"); + fprintf(out, "\tstring = str(pyNativeStr(casted))\n"); fprintf(out, "\tBNFreeString(result)\n"); fprintf(out, "\treturn string\n"); } -- cgit v1.3.1