diff options
| author | Lars Kotthoff <lars@larsko.org> | 2025-02-05 19:52:51 -0700 |
|---|---|---|
| committer | David Bremner <david@tethera.net> | 2025-02-07 12:13:16 -0400 |
| commit | 9c1f6cf746725af7bbbb66e746c5d694723ac0eb (patch) | |
| tree | f3c1b7b0fc87fa2970bddadb1f9efedf2102bee0 /bindings/python-cffi/tests/test_message.py | |
| parent | 409ad6b2a897c1571044bf6e4021a35fbd85b122 (diff) | |
fix segfaults in Python cFFI API and add tests
Several iterators in the Python cFFI API destroyed the objects they iterated
over too early (when the iterator was exhausted), causing subsequent segfaults
in common cases like creating a list from the iterator. This patch fixes the
segfaults and add tests to ensure that they don't happen again.
Diffstat (limited to 'bindings/python-cffi/tests/test_message.py')
| -rw-r--r-- | bindings/python-cffi/tests/test_message.py | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/bindings/python-cffi/tests/test_message.py b/bindings/python-cffi/tests/test_message.py index 56701d05..3b103530 100644 --- a/bindings/python-cffi/tests/test_message.py +++ b/bindings/python-cffi/tests/test_message.py @@ -218,6 +218,20 @@ class TestProperties: props.add('foo', 'a') assert set(props.getall('foo')) == {('foo', 'a')} + def test_getall_iter(self, props): + props.add('foo', 'a') + props.add('foobar', 'b') + for prop in props.getall('foo'): + assert isinstance(prop.value, str) + + def test_getall_iter_list(self, props): + props.add('foo', 'a') + props.add('foobar', 'b') + res = list(props.getall('foo')) + assert len(res) == 2 + for prop in res: + assert isinstance(prop.value, str) + def test_getall_prefix(self, props): props.add('foo', 'a') props.add('foobar', 'b') |
