]> git.ipfire.org Git - thirdparty/babel.git/commit
Fix extracted lineno with nested calls (#1126)
authorDylan Kiss <dyki@odoo.com>
Sat, 19 Oct 2024 12:17:36 +0000 (14:17 +0200)
committerGitHub <noreply@github.com>
Sat, 19 Oct 2024 12:17:36 +0000 (12:17 +0000)
commitbef3a734fbdf1da4d1058d25a5eed785bec43a63
tree468c7c559f61962ef95f043edbf6d3fa12c6ca69
parentea84d9d5f0bd2859f3281e4dac812ae05d33f466
Fix extracted lineno with nested calls (#1126)

When a gettext call had a nested function call on a new line, the
extract function would use that nested call's line number when
extracting the terms for the gettext call.

The reason is that we set the line number on any encounter of an opening
parenthesis after a gettext keyword. This does not work if either we
have a nested call, or our first term starts on a new line.

This commit fixes that by only setting the line number when we encounter
the first argument inside a gettext call.

Existing tests were adapted to work according to `xgettext` with regards
to the line numbers.

Fixes https://github.com/python-babel/babel/issues/1123
babel/messages/extract.py
tests/messages/test_extract.py