babel
babel copied to clipboard
Skip byte strings in extract_python instead of crashing
When pybabel extract encounters a byte string like _(b'foo'), _parse_python_string returns a bytes object which then causes ''.join(buf) to crash with TypeError: sequence item 0: expected str instance, bytes found.
Since byte strings are not valid translation strings (gettext uses normal strings internally), this just skips them by returning None from _parse_python_string when it encounters bytes.
Added a test that confirms byte strings are silently skipped while normal strings in the same file are still extracted correctly.
Fixes #1190