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:
1 parent
5c29da52dc
commit
fc2e848e91
7 files changed
+126
-3
No files matched your search
@@ -276,6 +276,17 @@ except kt.Error as e:
|
||||
EOF
|
||||
expect "12a. an error inside a klammer body is located at the application" 'error 3 1 True'
|
||||
|
||||
# The binding does NOT redirect sys.stdout: a print() in a document's @eval
|
||||
# is the host script's own stdout (under ktext it is a log line instead).
|
||||
run <<'EOF'
|
||||
import klammertext as kt
|
||||
M = kt.Machine(klammersets="none")
|
||||
M.read("@eval print('host stdout'); 1 @")
|
||||
print("result", M.apply())
|
||||
EOF
|
||||
expect "12b. a print() in @eval reaches the host script's stdout" 'host stdout
|
||||
result 1'
|
||||
|
||||
run <<'EOF'
|
||||
import klammertext as kt
|
||||
try:
|
||||
|
||||
Reference in new issue
Block a user