Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix amalgamation #681

Merged
merged 2 commits into from Dec 31, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 5 additions & 2 deletions babel/messages/extract.py
Expand Up @@ -236,9 +236,12 @@ def extract_from_file(method, filename, keywords=DEFAULT_KEYWORDS,
:returns: list of tuples of the form ``(lineno, message, comments, context)``
:rtype: list[tuple[int, str|tuple[str], list[str], str|None]
"""
if method == 'ignore':
return []

with open(filename, 'rb') as fileobj:
return list(extract(method, fileobj, keywords, comment_tags, options,
strip_comment_tags))
return list(extract(method, fileobj, keywords, comment_tags,
options, strip_comment_tags))


def extract(method, fileobj, keywords=DEFAULT_KEYWORDS, comment_tags=(),
Expand Down
2 changes: 1 addition & 1 deletion babel/numbers.py
Expand Up @@ -1063,7 +1063,7 @@ def _format_int(self, value, min, max, locale):
def _quantize_value(self, value, locale, frac_prec):
quantum = get_decimal_quantum(frac_prec[1])
rounded = value.quantize(quantum)
a, sep, b = str(rounded).partition(".")
a, sep, b = "{:f}".format(rounded).partition(".")
number = (self._format_int(a, self.int_prec[0],
self.int_prec[1], locale) +
self._format_frac(b or '0', locale, frac_prec))
Expand Down
4 changes: 4 additions & 0 deletions tests/test_numbers.py
Expand Up @@ -690,3 +690,7 @@ def test_parse_decimal_nbsp_heuristics():
n = decimal.Decimal("12345.123")
assert numbers.parse_decimal("12 345.123", locale="fi") == n
assert numbers.parse_decimal(numbers.format_decimal(n, locale="fi"), locale="fi") == n


def test_very_small_decimal_no_quantization():
assert numbers.format_decimal(decimal.Decimal('1E-7'), locale='en', decimal_quantization=False) == '0.0000001'