Skip to content

Commit 4c4bd6c

Browse files
Apply batched suggestions from code review
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
1 parent 98f85ac commit 4c4bd6c

2 files changed

Lines changed: 4 additions & 7 deletions

File tree

Lib/gettext.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -136,9 +136,7 @@ def _parse(tokens, priority=-1):
136136
except ValueError:
137137
raise _error(nexttok) from None
138138
result = '%s%d' % (result, value)
139-
# In C the unary '!' binds tighter than any binary operator, but Python's
140-
# 'not' binds looser, so parenthesise the negated operand before the
141-
# binary-operator loop below ('!n + 1' means '(!n) + 1', not '!(n + 1)').
139+
# Unary '!' binds tighter than binary operators in C, unlike 'not'.
142140
if result.startswith('not '):
143141
result = '(%s)' % result
144142
nexttok = next(tokens)
Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
Fix ``gettext.c2py`` mistranslating the unary ``!`` operator when it is
2-
followed by a binary operator (for example ``!n + 1``). ``!`` binds tighter
3-
than any binary operator in C, so the operand is now negated as a
4-
self-contained unit, matching the C semantics used by ``Plural-Forms`` rules.
1+
Fix :mod:`gettext` plural form selection when the ``Plural-Forms`` expression
2+
combines the unary ``!`` operator with a binary operator, for example
3+
``!n + 1`` or ``2 * !n``. The latter raised :exc:`SyntaxError`.

0 commit comments

Comments
 (0)