| Commit message (Collapse) | Author | Age | Files | Lines |
|
|
|
|
|
| |
as "the global configuration variable Py_UnbufferedStdioFlag was
deprecated in Python 3.12 and using PyConfig.buffered_stdio is
recommended instead." — https://peps.python.org/pep-0741/
|
| |
|
| |
|
|
|
|
| |
[skip ci]
|
| |
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Before, `ledger python -- -c 'raise RuntimeError'` would terminate
messily via SIGABRT, printing the following:
terminate called after throwing an instance of 'int'
[1] 2151711 abort (core dumped) ledger python -c 'raise RuntimeError'
This change makes the python subcommand throw a standard C++ exception
rather than just a plain int, which is never caught and triggers the
SIGABRT. Now, the process prints the uncaught Python exception as
usual and then exits with exit code 1.
|
| |
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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
<class 'bool'> 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
<class 'bool'> True
[...]
Segmentation fault (core dumped)
$ ./ledger -f "test/baseline/feat-value_py3.test" --verify reg | cat
<class 'bool'> True
[...]
$
1. https://www.boost.org/doc/libs/1_62_0/libs/python/doc/html/tutorial/tutorial/embedding.html
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
With python3 the `python` ledger command wound up loading the ledger
module shared library rather than using the builtin module as intended.
This resulted in duplicated initialization and crashing on cleanup. It
was also visible as duplicate converter warnings when importing ledger:
$ ./ledger --no-pager python
Python 3.7.5 (default, Nov 20 2019, 09:21:52)
[...]
>>> import ledger
/usr/lib/python3.7/importlib/_bootstrap.py:219: RuntimeWarning: to-Python converter for boost::posix_time::ptime already registered; second conversion method ignored.
[...]
/usr/lib/python3.7/importlib/_bootstrap.py:219: RuntimeWarning: to-Python converter for ledger::xact_t already registered; second conversion method ignored.
[...]
>>> ledger
<module 'ledger' from '/home/q/src/ledger/ledger.so'>
>>> exit()
Segmentation fault (core dumped)
After this change:
Python 3.7.5 (default, Nov 20 2019, 09:21:52)
[...]
>>> import ledger
>>> ledger
<module 'ledger' (built-in)>
>>> exit()
$
Switches to PyImport_AppendInittab from python::detail::init_module
because 1) that is what the boost docs and examples show and 2)
init_module appears to be undocumented and not intended for outside use.
Fixes #1867
|
|
|
|
|
|
|
|
|
|
| |
Ensure strings passed to Py_Main have a terminating null character by
including the extra character allocated for terminating null in the size
passed to mbstowcs.
Fix argv index so all arguments are not copied to argv[0]. Fixes
potential buffer overflow due to passing argv[0] as destination with
argv[i + 1] src and size to mbstowcs.
|
| |
|
|
|
|
|
|
|
| |
Ledger requires Boost 1.49 or later and enforces this in
CMakeLists.txt. This means BOOST_VERSION will always be
104900 or higher. Also, since Boost 1.46,
BOOST_FILESYSTEM_VERSION is 3.
|
|
|
|
| |
[ci skip]
|
|
|
|
| |
[ci skip]
|
|
|
|
| |
[ci skip]
|
|
|
|
|
|
| |
The following script makes it a no-brainer:
% NEXT_YEAR=2015; ag -l 'Copyright.*Wiegley' \
| xargs sed -i '' -e "s/\(Copyright.*\)-20[0-9]\{2\}/\1-${NEXT_YEAR}/"
|
| |
|
|
|
|
|
|
| |
Fixes test failures introduced with the commit
"Create default scope to read journal"
a9078767b8224a223f8942a1cb80d4544024387b
|
|
|
| |
when using ledger python module
|
|
|
|
| |
These changes only matter if ledger is compiled with USE_PYTHON.
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
The different namespaces are:
Function Value expression functions, which receive a "context"
Option Command-line options
Precommand Commands which are invoked before reading the journal
Command Commands which are invoked after reading the journal
Directive Directives that occur at column 0 in a data file
This greatly eases the ability for Python uses to add intercept hooks to
change how the basic Ledger module functions. An example of what should
be possible soon:
import ledger
def my_foo_handler(value):
print "--foo received:", value
ledger.add_handler(ledger.Option, "foo=", my_foo_handler)
|
| |
|