From 6d20807d1ac95feef1dc24712e16f63007311c94 Mon Sep 17 00:00:00 2001 From: Andy Clayton Date: Wed, 25 Mar 2020 19:46:23 -0500 Subject: py3: ensure python output is not lost Unbuffer python's stdio to avoid output getting stuck in buffer when stdout is not a TTY. Normally buffers are flushed by `Py_Finalize` but Boost has a long-standing issue preventing the proper shutdown of the interpreter with `Py_Finalize` when embedded [1]. This applies the same fix as 139beba but to any ledger usage rather than only the test suite. I removed `PYTHONUNBUFFERED=1` from tests as there is no expectation that users should need to have this set for ledger to function. For example without this fix piping ledger into cat usually loses any output (unless the output is large enough to cause the buffer to flush): $ ./ledger -f "test/baseline/feat-value_py3.test" reg True [...] $ ./ledger -f "test/baseline/feat-value_py3.test" reg | cat $ Interestingly `--verify` causes `python_interpreter_t` to be destroyed -- it doesn't appear to be otherwise -- which does call `Py_Finalize`. As expected this fixes the issue but can also crash due to the boost issue mentioned above: $ ./ledger -f "test/baseline/feat-value_py3.test" --verify reg True [...] Segmentation fault (core dumped) $ ./ledger -f "test/baseline/feat-value_py3.test" --verify reg | cat True [...] $ 1. https://www.boost.org/doc/libs/1_62_0/libs/python/doc/html/tutorial/tutorial/embedding.html --- test/unit/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'test/unit') diff --git a/test/unit/CMakeLists.txt b/test/unit/CMakeLists.txt index 4a9911c5..1bd5e4b3 100644 --- a/test/unit/CMakeLists.txt +++ b/test/unit/CMakeLists.txt @@ -2,7 +2,7 @@ macro(add_ledger_test _name) target_link_libraries(${_name} libledger) add_test(Ledger${_name} ${PROJECT_BINARY_DIR}/${_name}) set_tests_properties(Ledger${_name} - PROPERTIES ENVIRONMENT "PYTHONUNBUFFERED=1;TZ=${Ledger_TEST_TIMEZONE}") + PROPERTIES ENVIRONMENT "TZ=${Ledger_TEST_TIMEZONE}") endmacro(add_ledger_test _name) include_directories(${PROJECT_SOURCE_DIR}/src) -- cgit v1.2.3