MCPcopy Create free account
hub / github.com/InteractiveComputerGraphics/SPlisHSPlasH / print

Function print

extern/pybind/include/pybind11/pybind11.h:3294–3324  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3292
3293PYBIND11_NAMESPACE_BEGIN(detail)
3294PYBIND11_NOINLINE void print(const tuple &args, const dict &kwargs) {
3295 auto strings = tuple(args.size());
3296 for (size_t i = 0; i < args.size(); ++i) {
3297 strings[i] = str(args[i]);
3298 }
3299 auto sep = kwargs.contains("sep") ? kwargs["sep"] : str(" ");
3300 auto line = sep.attr("join")(std::move(strings));
3301
3302 object file;
3303 if (kwargs.contains("file")) {
3304 file = kwargs["file"].cast<object>();
3305 } else {
3306 try {
3307 file = module_::import("sys").attr("stdout");
3308 } catch (const error_already_set &) {
3309 /* If print() is called from code that is executed as
3310 part of garbage collection during interpreter shutdown,
3311 importing 'sys' can fail. Give up rather than crashing the
3312 interpreter in this case. */
3313 return;
3314 }
3315 }
3316
3317 auto write = file.attr("write");
3318 write(std::move(line));
3319 write(kwargs.contains("end") ? kwargs["end"] : str("\n"));
3320
3321 if (kwargs.contains("flush") && kwargs["flush"].cast<bool>()) {
3322 file.attr("flush")();
3323 }
3324}
3325PYBIND11_NAMESPACE_END(detail)
3326
3327template <return_value_policy policy = return_value_policy::automatic_reference, typename... Args>

Callers 6

runFunction · 0.50
libsize.pyFile · 0.50
make_changelog.pyFile · 0.50
make_global.pyFile · 0.50
print_includesFunction · 0.50
mainFunction · 0.50

Calls 10

tupleClass · 0.85
strClass · 0.85
moveFunction · 0.85
importFunction · 0.85
attrMethod · 0.80
writeFunction · 0.50
sizeMethod · 0.45
containsMethod · 0.45
argsMethod · 0.45
kwargsMethod · 0.45

Tested by

no test coverage detected