Bug description:
curses.complexchar() keeps only the text before an embedded NUL, so complexchar('a\0\u0301') silently drops the combining acute, and complexchar('\0') builds a cell with no text at all, whose repr() is not a valid constructor call.
import curses
print(repr(curses.complexchar('a\0\u0301')))
print(repr(curses.complexchar('a\u0301')))
r = repr(curses.complexchar('\0'))
print(r)
eval(r, {'curses': curses})
curses.complexchar('a')
curses.complexchar('á')
curses.complexchar('')
Traceback (most recent call last):
File "/tmp/bug.py", line 7, in <module>
eval(r, {'curses': curses})
~~~~^^^^^^^^^^^^^^^^^^^^^^^
File "<string>", line 1, in <module>
TypeError: expect a string of 1 to 5 characters, got a str of length 0
The empty cell is worse than the truncation: window.addstr(curses.complexstr([curses.complexchar('\0'), curses.complexchar('B')])) returns None having written nothing. The same text reaches the same converter through window.addch(), insch(), echochar(), hline(), vline(), bkgd(), bkgdset(), border() and box(), and curses.complexstr('a\0b') drops the NUL and returns two cells.
Expected: ValueError: embedded null character, which window.addstr('a\0b') already raises.
CPython versions tested on:
CPython main branch
Operating systems tested on:
Linux
Linked PRs
Bug description:
curses.complexchar()keeps only the text before an embedded NUL, socomplexchar('a\0\u0301')silently drops the combining acute, andcomplexchar('\0')builds a cell with no text at all, whoserepr()is not a valid constructor call.The empty cell is worse than the truncation:
window.addstr(curses.complexstr([curses.complexchar('\0'), curses.complexchar('B')]))returnsNonehaving written nothing. The same text reaches the same converter throughwindow.addch(),insch(),echochar(),hline(),vline(),bkgd(),bkgdset(),border()andbox(), andcurses.complexstr('a\0b')drops the NUL and returns two cells.Expected:
ValueError: embedded null character, whichwindow.addstr('a\0b')already raises.CPython versions tested on:
CPython main branch
Operating systems tested on:
Linux
Linked PRs