Skip to content

gh-125843: indicate which C function caused a curses.error #125844

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 27 commits into from
May 19, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
03fc9c5
improve `curses.error` object
picnixz Oct 15, 2024
3436f9b
update error messages
picnixz Oct 15, 2024
73ce26c
cosmetic changes!
picnixz Oct 16, 2024
cfe5468
blurb
picnixz Oct 22, 2024
a8845ee
update docs
picnixz Oct 22, 2024
1b1230d
Merge remote-tracking branch 'upstream/main' into x-stale/feat/curses…
picnixz Apr 25, 2025
55a491a
reduce diff
picnixz Apr 25, 2025
758dfe5
reduce diff even futher
picnixz Apr 25, 2025
3a3964b
simplify logic
picnixz Apr 25, 2025
92e62cf
simplify logic x2
picnixz Apr 25, 2025
4d8f47f
reduce diff again!
picnixz Apr 25, 2025
5b8ff99
simplify logic x3
picnixz Apr 25, 2025
43d2e99
lint
picnixz Apr 25, 2025
12f0b30
reduce diff x4
picnixz Apr 25, 2025
eaaad71
reduce diff x5
picnixz Apr 25, 2025
b96b542
simplify even more!
picnixz Apr 26, 2025
39f102f
nits(cosmetics)
picnixz Apr 26, 2025
6bc9c3e
update messages
picnixz Apr 27, 2025
5addb78
remove un-necessary prototypes and rearrange code
picnixz Apr 27, 2025
34583e0
address review
picnixz May 6, 2025
236bea5
update error messages in `_curses_panel`
picnixz May 7, 2025
8188179
raise `curses.error` in `is_linetouched` instead of TypeError
picnixz May 19, 2025
9e6c83e
Revert "update error messages in `_curses_panel`"
picnixz May 19, 2025
3989ddd
fix typo
picnixz May 19, 2025
bf54774
correctly check `mouseinterval` return value
picnixz May 19, 2025
34a1c31
Merge remote-tracking branch 'upstream/main' into feat/curses/error-t…
picnixz May 19, 2025
6be3a15
reduce overall diff
picnixz May 19, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions Include/py_curses.h
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,13 @@ static void **PyCurses_API;
static const char catchall_ERR[] = "curses function returned ERR";
static const char catchall_NULL[] = "curses function returned NULL";

#if defined(CURSES_MODULE) || defined(CURSES_PANEL_MODULE)
/* Error messages shared by the curses package */
# define CURSES_ERROR_FORMAT "%s() returned %s"
# define CURSES_ERROR_VERBOSE_FORMAT "%s() (called by %s()) returned %s"
# define CURSES_ERROR_MUST_CALL_FORMAT "must call %s() first"
#endif

#ifdef __cplusplus
}
#endif
Expand Down
3 changes: 3 additions & 0 deletions Lib/test/test_curses.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,9 @@ def test_use_env(self):
curses.use_env(False)
curses.use_env(True)

def test_error(self):
self.assertIsSubclass(curses.error, Exception)

def test_create_windows(self):
win = curses.newwin(5, 10)
self.assertEqual(win.getbegyx(), (0, 0))
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
If possible, indicate which :mod:`curses` C function or macro is responsible
for raising a :exc:`curses.error` exception. Patch by Bénédikt Tran.
Loading
Loading