A klammer set's Python speaks through the log

Assembled from development commit d5f9c20b94b3. Since 5c29da5: a print() in
@eval, or in any Python a klammer set runs, is a log line -- on the
error stream under the command's name at -v 1, silent otherwise, never
in the document -- and K_log(level, text) is the builtin behind it; a
Python script using the binding keeps its own stdout. Previously such
output was lost, or on a terminal landed in the document.
This commit is contained in:
ack committed 2026-09-25 23:08:26 +02:00
1 parent 5c29da52dc
commit fc2e848e91
7 files changed
+126 -3

No files matched your search

+12
View File
@@ -5,6 +5,18 @@
#include "machine.h"
// Where a klammer set's Python may speak. Embedded Python's own stdout is
// nowhere a user looks: its buffer is never flushed (no Py_Finalize), so on
// a pipe or a file a print() vanished, and on a terminal it landed in the
// document's stream. Under a command, Eval_python routes it to the engine's
// log instead: K_log(level, text) is a builtin every module sees (kutil.msg
// uses it), and sys.stdout is replaced by a stream that logs each line at
// level 1 -- stderr under -v, silent otherwise, never the document (the
// output policy in CLAUDE.md). The switch is ON for the commands
// (set_verbose_level) and OFF for the Python binding, where sys.stdout is
// the host script's own and must not be touched.
void set_python_output_to_log(bool on);
class Eval_python
{
public: