python / python/cpython

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

オープン
#157,210 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

stdlib topic-curses type-bug
主要言語
Python
スター
77.2k
フォーク
35.9k
PR マージ指標
PR 指標を取得中

説明

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

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

調査の方向性

curses.textpad.Textbox.do_command から始め、Linux 上で、提供されている3列および10列の例を使って問題を再現します。記載されている Unicode の動作について Doc/library/curses.rst を確認します。両方のウィンドウが基底文字と結合文字を 'abe\u0301' として保持すれば完了です。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
python
領域
cli
issue の種類
バグ
難易度
3/5
見積もり時間
1〜2日
活発さ
停滞
明瞭さ
明確に書かれている
初心者へのやさしさ
35/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。