Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

Literal carriage returns break parser under Python 3.x

Aperta
#153 9 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
3/5
Tempo stimato
1-2 giorni
Idoneità per principianti
45/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Ferma
Stack tecnologico
python
Ambito
tooling

Direzione di ricerca

Reproduce the failure with python3 py/vimlparser.py ~/.vimrc using the .vimrc example containing literal carriage returns. Start in py/vimlparser.py at its file-reading and line-splitting path; done means those literal ^M characters are preserved as parser input rather than converted to newlines, while ordinary line endings continue to parse.

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

Descrizione

This chunk from my .vimrc causes python3 py/vimlparser.py ~/.vimrc to error out on my system.

Since this didn't show up in my initial search for VimL parsers for Python, I started work on a VimL parser of my own and I know why it happens.

The literal <CR>s in this piece of my .vimrc (the ^Ms)...

image

...get converted to \n by the universal newline support in Python 3.x's text mode. (I assume because a bare \r is the old Classic MacOS line terminator and Python's universal newlines mode is converting all potential newlines rather than limiting itself to whichever kind of newline it encounters first like Vim itself does.)

The quick hack I came up with to make the parser robust was to open the file in binary mode and then manually decode and split lines:

with open(path, 'rb') as fobj:
    process_group(fobj.read().decode('utf8').split('\n'))
Lingua principale
Vim Script
Stelle
173
Fork
28
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 vim-jp/vim-vimlparser

Tutte le issue di vim-jp/vim-vimlparser

Issue simili

Altre issue su DevTools

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.