farhan5900 [Mon, 28 Mar 2022 05:32:39 +0000 (11:02 +0530)]
Plural-Forms: Fix missing trailing semicolon
Adds missing semicolon in the code that generates the header that
is Catalog.plural_forms as well as in plural.to_gettext function.
Also modifies all the concerning test cases as well as test data files.
Sigurd Ljødal [Mon, 31 Jan 2022 16:47:21 +0000 (17:47 +0100)]
Fix duplicate locations when writing without lineno
If the same translation appears multiple times in the same file,
duplicate locations would be written to the .po file when using
write_po(..., include_lineno=False).
``parse_date()`` does not allow the user to specify the date's format
and the 'medium' format is used by default in the call to
``get_date_format()`` on line 1144.
This results in a failure to parse the date in short format for the
locale 'sv_SE'. This commit adds the format argument to avoid this
failure. The default value is set to 'medium' to preserve the old behavior.
Aarni Koskela [Tue, 25 Jan 2022 13:14:22 +0000 (15:14 +0200)]
parse_locale(): upper-case variant tag to match file system
At all times, language tags and their subtags, including private use
and extensions, are to be treated as case insensitive: there exist
conventions for the capitalization of some of the subtags, but these
MUST NOT be taken to carry meaning.
Felix Schwarz [Tue, 5 May 2020 08:05:56 +0000 (08:05 +0000)]
fix tests when using Python 3.9a6
In Python 3.9a6 integer values for future flags were changed to prevent
collision with compiler flags. We need to retrieve these at runtime so
the test suite works with Python <= 3.8 as well as Python 3.9.
Felix Schwarz [Tue, 5 May 2020 07:58:01 +0000 (09:58 +0200)]
stop using deprecated ElementTree methods "getchildren()" and "getiterator()"
Both methods were removed in Python 3.9 as mentioned in the release notes:
> Methods getchildren() and getiterator() of classes ElementTree and Element in
> the ElementTree module have been removed. They were deprecated in Python 3.2.
> Use iter(x) or list(x) instead of x.getchildren() and x.iter() or
> list(x.iter()) instead of x.getiterator().
CyanNani123 [Mon, 13 Jan 2020 22:13:01 +0000 (23:13 +0100)]
catalog.rst: Add __iter__ to Catalog documentation
The declaration of __iter__ under the special-members
directive makes it visible in the documentation.
The docstring describing __iter__ already exists.
Niklas Hambüchen [Mon, 27 Jan 2020 23:37:22 +0000 (00:37 +0100)]
Fix unicode printing error on Python 2 without TTY.
Until now, on Python 2.7, `python setup.py test | cat` crashed in the test
runner with
======================================================================
ERROR: test_abort_invalid_po_file (tests.messages.test_pofile.ReadPoTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
File "src/babel/tests/messages/test_pofile.py", line 458, in test_abort_invalid_po_file
output = pofile.read_po(buf, locale='fr', abort_invalid=False)
File "src/babel/babel/messages/pofile.py", line 377, in read_po
parser.parse(fileobj)
File "src/babel/babel/messages/pofile.py", line 310, in parse
self._process_message_line(lineno, line)
File "src/babel/babel/messages/pofile.py", line 210, in _process_message_line
self._process_keyword_line(lineno, line, obsolete)
File "src/babel/babel/messages/pofile.py", line 222, in _process_keyword_line
self._invalid_pofile(line, lineno, "Start of line didn't match any expected keyword.")
File "src/babel/babel/messages/pofile.py", line 325, in _invalid_pofile
print(u"WARNING: Problem on line {0}: {1}".format(lineno + 1, line))
UnicodeEncodeError: 'ascii' codec can't encode character u'\xe0' in position 84: ordinal not in range(128)
The test suite would show this when printing the `à` in the test pofile contents
Pour toute question, veuillez communiquer avec Fulano à nadie@blah.com
But this bug is not confined to the test suite only. Any call to `read_po()`
with invalid .po file could trigger it in non-test code when
`sys.stdout.encoding` is `None`, which is the default for Python 2 when
`sys.stdout.isatty()` is false (as induced e.g. by `| cat`).
The fix is to `repr()` the line when printing the WARNING.
Niklas Hambüchen [Tue, 28 Jan 2020 01:46:25 +0000 (02:46 +0100)]
Introduce invariant that _invalid_pofile() takes unicode line.
This makes debugging and reasoning about the code easier;
otherwise it is surprising that sometimes `line` is a unicode
and sometimes not.
So far, when it was not, it could either be only `""` or
`'Algo esta mal'`; thus this commit makes those two u"" strings.
In all other cases, it was guaranteed that it's unicode,
because all code paths leading to `_invalid_pofile()` went through
if not isinstance(line, text_type):
line = line.decode(self.catalog.charset)
Miro Hrončok [Sun, 5 Jan 2020 23:37:39 +0000 (00:37 +0100)]
Replace usage of parser.suite with ast.parse
Replaced usage of the long-superseded "parser.suite" module in the
mako.util package for parsing the python magic encoding comment with the
"ast.parse" function introduced many years ago in Python 2.5, as
"parser.suite" is emitting deprecation warnings in Python 3.9.