python / python/cpython

A combining mark in a `Textbox`'s last cell loses the base character

Aperta
#157,210 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

stdlib topic-curses type-bug
Lingua principale
Python
Stelle
77.2k
Fork
35.9k
Metriche di merge delle PR
Metriche PR in attesa

Descrizione

Bug description:

Typing a combining mark into the lower-right cell of a curses.textpad.Textbox puts the mark in a cell of its own and pushes the character it should attach to off the window edge, so that character is lost. The same keystrokes one column earlier attach the mark correctly. Doc/library/curses.rst says of Textbox that "Entering and reading back the full Unicode range, including combining characters, is now supported when curses is built with wide-character support".

import curses, sys
from curses.textpad import Textbox

def typed(ncols):
    win = curses.newwin(1, ncols, 0, 0)
    box = Textbox(win)
    for ch in 'abe\u0301':      # COMBINING ACUTE ACCENT after the 'e'
        box.do_command(ch)
    return win.instr(0, 0, 40).decode()

out = curses.wrapper(lambda stdscr: (typed(3), typed(10)))
print('3 columns:  %a\n10 columns: %a' % out, file=sys.stderr)

Output:

3 columns:  'ab\u0301'
10 columns: 'abe\u0301       '

Expected 'abe\u0301' from both windows: the mark should join the e instead of taking its cell.

CPython versions tested on:

CPython main branch

Operating systems tested on:

Linux

Linked PRs
  • gh-157211

Guida per i contributori

Apri la guida per i contributori

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.

Direzione di ricerca

Inizia con curses.textpad.Textbox.do_command e riproduci il problema usando l'esempio fornito a tre colonne e a dieci colonne su Linux. Controlla Doc/library/curses.rst per il comportamento Unicode dichiarato; completato quando entrambe le finestre preservano il carattere di base e il segno combinante come 'abe\u0301'.

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

Valutazione

Stack tecnologico
python
Ambito
cli
Tipo di issue
Bug
Difficoltà
3/5
Tempo stimato
1-2 giorni
Stato di attività
Ferma
Chiarezza
Specificata chiaramente
Idoneità per principianti
35/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.