Public bug reported:

pyparsing 3.3.3 rewrote infix_notation into a new _InfixNotation class
(pyparsing/helpers.py). When operators at the SAME precedence level are
supplied in an order where one operator is a prefix of another (e.g. '>'
before '>='), the new implementation matches the shorter operator and does
NOT backtrack to try the longer one when the operand fails to match. As a
result 'a >= 1' and 'a <= 1' fail to parse at all.

Minimal repro (pure pyparsing, mirrors mdtraj's grammar shape):

    from pyparsing import Word, alphanums, infix_notation, OpAssoc, Keyword
    ident = Word(alphanums)
    ops = [(Keyword(kw), 2, OpAssoc.LEFT) for kw in
           ['&&', '<', '<=', '==', '>', '>=', 'and', 'eq', 'ge', 'gt',
            'le', 'lt', 'ne', 'or', '||', '!=']]
    infix_notation(ident, ops).parse_string('a >= 1', parse_all=True)

Results (verified in clean venvs):
- pyparsing 3.3.2: parses fine ('a >= 1' and 'a <= 1' both OK)
- pyparsing 3.3.3: 'a >= 1' -> "Expected W:(0-9A-Za-z), found '=' (at char 3)";
  'a <= 1' fails the same way; 'a == 1' happens to work only because '=='
  precedes '>' in this particular ordering
- passing the SAME operators longest-first makes 3.3.3 work, confirming the
  regression is operator-ordering/no-backtracking in the new implementation

Upstream: https://github.com/pyparsing/pyparsing/issues/672
"Regression in infix_notation on 3.3.3" (open). Maintainer comment
(2026-11-23): working on 3.3.4rc1 to revert the infix_notation
implementation back to the 3.3.2 state. No release yet.

Impact in tenacious: pyparsing 3.3.3-2 (proposed, main) breaks the
python3.15 no-change rebuild of mdtraj 1.11.1.post1-3build1 on
amd64/amd64v3/arm64. mdtraj builds its selection operators in sorted order
('>' before '>='), so its build-time test suite fails:

    tests/test_selection.py::test_binary_selection_operator FAILED
    E pyparsing.exceptions.ParseException: Expected '(', found '='  (at char 6)
    (for 'name >= 1'; 'test_within' also skips with "failed to parse selection")

    build log:
https://launchpad.net/ubuntu/+source/mdtraj/1.11.1.post1-3build1/+build/33992566

mdtraj's migration is therefore blocked ("missing build on amd64..."),
holding up the python3.15-add transition (currently 94 %). pyparsing
3.3.3-2's own migration is at the same time blocked by rdep autopkgtest
regressions, which is what is currently protecting the archive.

Options:
a. Revert tenacious-proposed to pyparsing 3.3.2-2 until upstream 3.3.4
   lands (upstream plans to revert the infix_notation rewrite).
b. Sync pyparsing 3.3.4 as soon as it is released.
c. Immediate mdtraj-only unblock: one-line workaround in mdtraj
   (order operator keywords longest-first so '>=' is tried before '>').
   I can prepare that merge proposal; other infix_notation consumers with
   prefix-overlapping operators would remain exposed until 3.3.4.

** Affects: pyparsing (Ubuntu)
     Importance: Undecided
     Assignee: Ruan Comelli (ruancomelli)
         Status: New


** Tags: update-excuse

** Changed in: pyparsing (Ubuntu)
     Assignee: (unassigned) => Ruan Comelli (ruancomelli)

-- 
You received this bug notification because you are a member of Ubuntu
Bugs, which is subscribed to Ubuntu.
https://bugs.launchpad.net/bugs/2180131

Title:
  pyparsing 3.3.3 infix_notation regression: ">=" and "<=" fail to parse
  when a shorter operator sorts first; breaks mdtraj build

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/pyparsing/+bug/2180131/+subscriptions


-- 
ubuntu-bugs mailing list
[email protected]
https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs

Reply via email to