Lexer gives quoted identifiers an `end` that is the token length, not its end offset

Aperta
#380 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

@chiliec ci sta già lavorando.

Dal 12/10/2026.

  • #382 di @chiliec — aperta
  • #393 di @ApparentlyTejas — aperta

Valutazione

Difficoltà
1/5
Tempo stimato
Meno di un'ora
Idoneità per principianti
20/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Ferma
Stack tecnologico
python
Ambito
backend

Direzione di ricerca

Read jmespath/lexer.py around line 185 and inspect _consume_quoted_identifier; the issue includes a reproducing expression and the incorrect token fields. Check the existing lexer tests for position assertions, then verify the quoted identifier's end is its end offset in foo."q".

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

While testing an experimental version of Perch, we found the following and figured it was worth a report.

_consume_quoted_identifier sets the token's end to the token's length instead of start + length, so it's wrong whenever the identifier isn't at the start of the expression:

>>> from jmespath.lexer import Lexer
>>> [t for t in Lexer().tokenize('foo."q"') if t['type'] == 'quoted_identifier']
[{'type': 'quoted_identifier', 'value': 'q', 'start': 4, 'end': 2}]

end is 2, which is before start. Every other token type uses start + len(...). Search results aren't affected; only the position information is wrong.

It's at jmespath/lexer.py:185:

return {'type': 'quoted_identifier', 'value': loads(lexeme),
        'start': start, 'end': token_len}

'end': start + token_len would fix it. The lexer rewrite in #362 keeps the same line.

Tested on develop (2812594), Python 3.14.6, macOS 26.2.

Lingua principale
Python
Stelle
2.5k
Fork
231
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Preparare l'ambiente

Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di jmespath/jmespath.py

Tutte le issue di jmespath/jmespath.py

Issue simili

Altre issue su Python

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.