Python error handling compiler shenanigans

bpy_interface_run.c within the BPY_run_string_as_string_and_size function.

The arguments are swapped - a boolean is being passed to a char* parameter and report_prefix (a char*) is being passed to a bool parameter. Compiler happily proceeds - I don’t see any overloads/macros/etc.

Anyone want to explain to me how that even remotely compiles? Unless I’m missing something, if that code runs… kaboomie.

Other calls to the same function have report prefix as second arg, and false as last two. So looks like a typo.

As to why that happens, implicit promotions/conversions probably ?

It’s a long list but bet it’s somewhere in there.

false -> 0 -> NULL -> char *

Pointers act as boolean all the time, in all the null-checks. if(!report_prefix){return; }

Using a named variable might have saved that, I guess.

That’s amazing, thanks for the detailed explanation. I figured it had to have been an implicit conversion but it’s been awhile since I’ve seen one that deep.

I’ll see if I can find a way to trigger the codepath that leads to that function and look at tossing in a diff to fix it.

Got bit by a nice one today
std::string s = 0;