diff --git a/kernel/log.h b/kernel/log.h index 78b202159..bd5788758 100644 --- a/kernel/log.h +++ b/kernel/log.h @@ -153,6 +153,11 @@ inline void log_warning(FmtString...> fmt, const Args &... ar { log_formatted_warning("Warning: ", fmt.format(args...)); } + +inline void log_formatted_warning_noprefix(std::string str) +{ + log_formatted_warning("", str); +} template inline void log_warning_noprefix(FmtString...> fmt, const Args &... args) { diff --git a/misc/py_wrap_generator.py b/misc/py_wrap_generator.py index e695d1ef0..aa1406f9b 100644 --- a/misc/py_wrap_generator.py +++ b/misc/py_wrap_generator.py @@ -632,12 +632,17 @@ class Attribute: arg.wtype.attr_type = attr_types.amp arg.varname = arg.varname[1:] - # special exception: format strings + # handle string views if arg.wtype.name in ["std::string_view", "string_view"]: - if arg.varname == "format": + if arg.varname == "format" and owner_fn_name.startswith("log_"): + # coerce format strings to "%s" (not bridgable) arg.coerce_arg = '"%s"' elif arg.varname == "prefix" and "warning" in owner_fn_name: + # coerce warning prefix to "warning:" arg.coerce_arg = '"Warning: "' + else: + # boost::python can't bridge string views, so just copy them + arg.wtype.name = "string" return arg