Commit graph

93 commits

Author SHA1 Message Date
Serhiy Storchaka
2602d8ae98
gh-71339: Use new assertion methods in tests (GH-129046) 2025-05-22 13:17:22 +03:00
Bénédikt Tran
ee36db5500
gh-125843: indicate which C function caused a curses.error (#125844)
- Rename error helpers with a `curses_set_error_*` prefix instead of `PyCurses*`.
- Cleanly report both NULL and ERR cases.
- Raise `curses.error` in `is_linetouched` instead of a `TypeError`.
2025-05-19 15:53:39 +02:00
Michael Forney
0af61fe2f4
bpo-44172: Keep reference to original window in curses subwindow objects (GH-26226)
The X/Open curses specification[0] and ncurses documentation[1]
both state that subwindows must be deleted before the main window.

Deleting the windows in the wrong order causes a double-free with
NetBSD's curses implementation.

To fix this, keep track of the original window object in the subwindow
object, and keep a reference to the original for the lifetime of
the subwindow.

[0] https://pubs.opengroup.org/onlinepubs/7908799/xcurses/delwin.html
[1] https://invisible-island.net/ncurses/man/curs_window.3x.html

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2025-05-04 13:29:44 +03:00
Serhiy Storchaka
7363e8d24d
gh-133139: Add curses.assume_default_colors() (GH-133145)
This is a refinement of the curses.use_default_colors() function which
allows to change the color pair 0.
2025-05-03 23:33:22 +03:00
Bénédikt Tran
7f02ded29f
gh-91221: fix test_curses.test_use_default_colors for xterm-256color (#132990)
Terminals with `xterm-256color` Xterm support may use 15 (bright white) as their default foreground color.
2025-04-26 10:38:27 +00:00
Peter Bierma
c2ba931318
gh-120378: Fix crash caused by integer overflow in curses (#124555)
This is actually an upstream problem in curses, and has been reported
to them already:
https://lists.gnu.org/archive/html/bug-ncurses/2024-09/msg00101.html

This is a nice workaround in the meantime to prevent the segfault.

Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
2024-10-02 14:31:23 +00:00
Serhiy Storchaka
4e5b27e6a3
gh-81682: Fix test failures when CPython is built without docstrings (GH-113410) 2023-12-23 09:56:30 +00:00
Nikita Sobolev
3fb7c608e5
gh-106194: Rename duplicated tests in test_curses (#106196) 2023-06-28 14:41:08 -06:00
Aidan Melen
a3a5b4bb23
gh-60436: fix curses textbox backspace/del (#103783)
Co-authored-by: Łukasz Langa <lukasz@langa.pl>
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
Co-authored-by: Michael Blahay <mblahay@gmail.com>
2023-04-26 22:54:07 +02:00
Serhiy Storchaka
f41c16bf51
gh-91914: Fix test_curses on non-UTF-8 locale (GH-91919) 2022-04-26 07:59:56 +03:00
Erlend Egeberg Aasland
fbff5387c3
bpo-43988: Use check disallow instantiation helper (GH-26392) 2021-05-27 08:43:52 +02:00
Erlend Egeberg Aasland
9746cda705
bpo-43916: Apply Py_TPFLAGS_DISALLOW_INSTANTIATION to selected types (GH-25748)
Apply Py_TPFLAGS_DISALLOW_INSTANTIATION to the following types:

* _dbm.dbm
* _gdbm.gdbm
* _multibytecodec.MultibyteCodec
* _sre..SRE_Scanner
* _thread._localdummy
* _thread.lock
* _winapi.Overlapped
* array.arrayiterator
* functools.KeyWrapper
* functools._lru_list_elem
* pyexpat.xmlparser
* re.Match
* re.Pattern
* unicodedata.UCD
* zlib.Compress
* zlib.Decompress
2021-04-30 16:04:57 +02:00
Serhiy Storchaka
b1dc1aacf8
bpo-43084: Return bool instead of int from curses.window.enclose() (GH-24398) 2021-04-05 16:50:24 +03:00
Michael Felt
c8b5738810
bpo-43659: Fix test_curses on AIX (GH-25074)
curses.update_lines_cols() is only defined when the curses library
provides either resizeterm() or resize_term() functions which are optional
and are not provided on AIX.
2021-03-29 22:06:24 +03:00
Pablo Galindo
d0204963ec
bpo-43231: Correctly calculate the curses color pair limit when checking for it (GH-24541) 2021-02-15 22:15:49 +00:00
Pablo Galindo
ab2d481639
bpo-43231: Fix test.test_curses.TestCurses.test_init_pair when running under -R (GH-24539) 2021-02-15 22:35:48 +01:00
Serhiy Storchaka
a1e9a1e120
bpo-43016: Fix test_curses on platform without cursesw (GH-24405) 2021-01-31 23:21:55 +02:00
Serhiy Storchaka
d64fd4bb5b
bpo-43016: Rewrite tests for curses (GH-24312) 2021-01-31 17:22:27 +02:00
Serhiy Storchaka
59f9b4e450
bpo-42681: Fix test_curses failures related to color pairs (GH-24089)
On ncurses 6.1 pair numbers are limited by SHORT_MAX-1, even
with extended color support.

Improve error reporting and tests for color functions.
2021-01-05 09:13:15 +02:00
Serhiy Storchaka
b6fc0c406e
bpo-42789: Enable using /dev/tty in test_curses. (GH-24085)
It was temporary disabled for debugging.
2021-01-04 12:30:20 +02:00
Serhiy Storchaka
1470edd613
bpo-42681: Fix range checks for color and pair numbers in curses (GH-23874) 2021-01-03 22:51:11 +02:00
Serhiy Storchaka
607501abb4
bpo-42789: Don't skip curses tests on non-tty. (GH-24009)
If __stdout__ is not attached to terminal, try to use __stderr__
if it is attached to terminal, or open the terminal device, or
use regular file as terminal, but some functions will be untested
in the latter case.
2021-01-02 19:35:15 +02:00
Hans Petter Jansson
da4e09fff6
bpo-36982: Add support for extended color functions in ncurses 6.1 (GH-17536)
Co-authored-by: Jeffrey Kintscher <websurfer@surf2c.net>
2020-08-03 23:51:33 -04:00
Hai Shi
a7f5d93bb6
bpo-40275: Use new test.support helper submodules in tests (GH-21449) 2020-08-03 18:41:24 +02:00
Anthony Sottile
b32cb97bce bpo-38312: Add curses.{get,set}_escdelay and curses.{get,set}_tabsize. (GH-16938) 2019-10-31 11:13:48 +02:00
Serhiy Storchaka
b232df9197
bpo-31680: Add curses.ncurses_version. (GH-4217)
Use curses.ncurses_version for conditionally skipping a test.
2018-10-30 13:22:42 +02:00
Serhiy Storchaka
a7723d8b09
bpo-31924: Fix test_curses on NetBSD 8. (#4228) 2017-11-03 20:29:33 +02:00
Serhiy Storchaka
4f469c0966
bpo-27666: Fixed stack corruption in curses.box() and curses.ungetmouse(). (#4220) 2017-11-01 20:48:49 +02:00
Serhiy Storchaka
7e68790f3d
bpo-15037: Add a workaround for getkey() in curses for ncurses 5.7 and earlier. (#3826)
Skip a test for unget_wch()/get_wch() on OpenBSD since they are broken
in ncurses 5.7.
2017-11-01 16:03:40 +02:00
Serhiy Storchaka
894ebd065e
bpo-31919: Fix building the curses module on OpenIndiana. (#4211) 2017-11-01 14:34:20 +02:00
Serhiy Storchaka
baac01e629
bpo-31891: Fix building the curses module on NetBSD. (#4165) 2017-10-31 13:56:44 +02:00
Victor Stinner
19f68301a1
bpo-31629: Add support.SaveSignals (#4183)
test_curses now saves/restores signals. On FreeBSD, the curses module
sets handlers of some signals, but don't restore old handlers when
the module is deinitialized.
2017-10-31 03:14:01 -07:00
Serhiy Storchaka
f7eae0adfc [security] bpo-13617: Reject embedded null characters in wchar* strings. (#2302)
Based on patch by Victor Stinner.

Add private C API function _PyUnicode_AsUnicode() which is similar to
PyUnicode_AsUnicode(), but checks for null characters.
2017-06-28 08:30:06 +03:00
Xavier de Gaye
645bc80918 test_curses - substitute self.skip() with self.skipTest() 2017-01-06 09:50:27 +01:00
Serhiy Storchaka
bdf9e0ea74 Issue #13051: Fixed recursion errors in large or resized curses.textpad.Textbox.
Based on patch by Tycho Andersen.
2016-12-28 10:16:06 +02:00
Serhiy Storchaka
283de2b9c1 Issue #9770: curses.ascii predicates now work correctly with negative integers. 2016-12-28 10:04:27 +02:00
Berker Peksag
53926f19cd Issue #27801: Skip test_update_lines_cols when update_lines_cols() is not available 2016-08-19 17:59:01 +03:00
Benjamin Peterson
b1c6bdc76a merge 3.4 2016-08-15 21:43:57 -07:00
Benjamin Peterson
432ea4ff37 fail when negative values are passed to instr() 2016-08-15 21:40:14 -07:00
Benjamin Peterson
f17a8e9acd merge 3.4 2016-08-13 18:21:16 -07:00
Benjamin Peterson
40a77c3381 do not allow reading negative values with getstr() 2016-08-13 18:15:28 -07:00
Serhiy Storchaka
514f9736a7 Issue #27294: Numerical state in the repr for Tkinter event objects is now
represented as a compination of known flags.
2016-06-18 22:08:11 +03:00
Serhiy Storchaka
0a91e43820 Fixed an error in previous commit. 2016-05-22 18:23:36 +03:00
Serhiy Storchaka
53a00353b6 Temporary skip curses tests on non-tty (issue #27067). 2016-05-22 18:16:20 +03:00
Serhiy Storchaka
0eb39e7886 Issue #27067: Improved curses tests. 2016-05-21 21:36:11 +03:00
Serhiy Storchaka
e3f1b0911e Issue #23815: Fixed crashes related to directly created instances of types in
_tkinter and curses.panel modules.
2016-05-08 20:46:22 +03:00
Zachary Ware
baf45c590c Issue #16000: Convert test_curses to use unittest 2014-10-17 13:59:18 -05:00
Larry Hastings
9147a9697a Issue #21088: Bugfix for curses.window.addch() regression in 3.4.0.
In porting to Argument Clinic, the first two arguments were reversed.
2014-05-04 04:41:18 -07:00
Larry Hastings
23e37aa7b7 Issue #20358: Tests for curses.window.overlay and curses.window.overwrite
no longer specify min{row,col} > max{row,col}.
2014-01-25 22:19:47 -08:00
Andrew Kuchling
9290dd14b0 #18113: avoid segfault if Py_XDECREF triggers code that calls set_panel_userptr again
Problem noted & original patch by Serhiy Storchaka; I tweaked the patch a bit.
2013-06-22 14:50:56 -04:00