Skip to content

Commit b1dc1aa

Browse files
bpo-43084: Return bool instead of int from curses.window.enclose() (GH-24398)
1 parent c8e5eb9 commit b1dc1aa

File tree

5 files changed

+18
-19
lines changed

5 files changed

+18
-19
lines changed

Doc/library/curses.rst

+3
Original file line numberDiff line numberDiff line change
@@ -915,6 +915,9 @@ the following methods and attributes:
915915
determining what subset of the screen windows enclose the location of a mouse
916916
event.
917917

918+
.. versionchanged:: 3.10
919+
Previously it returned ``1`` or ``0`` instead of ``True`` or ``False``.
920+
918921

919922
.. attribute:: window.encoding
920923

Lib/test/test_curses.py

+6-7
Original file line numberDiff line numberDiff line change
@@ -566,13 +566,12 @@ def test_resize(self):
566566
@requires_curses_window_meth('enclose')
567567
def test_enclose(self):
568568
win = curses.newwin(5, 15, 2, 5)
569-
# TODO: Return bool instead of 1/0
570-
self.assertTrue(win.enclose(2, 5))
571-
self.assertFalse(win.enclose(1, 5))
572-
self.assertFalse(win.enclose(2, 4))
573-
self.assertTrue(win.enclose(6, 19))
574-
self.assertFalse(win.enclose(7, 19))
575-
self.assertFalse(win.enclose(6, 20))
569+
self.assertIs(win.enclose(2, 5), True)
570+
self.assertIs(win.enclose(1, 5), False)
571+
self.assertIs(win.enclose(2, 4), False)
572+
self.assertIs(win.enclose(6, 19), True)
573+
self.assertIs(win.enclose(7, 19), False)
574+
self.assertIs(win.enclose(6, 20), False)
576575

577576
def test_putwin(self):
578577
win = curses.newwin(5, 12, 1, 2)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
:func:`curses.window.enclose` returns now ``True`` or ``False`` (as was
2+
documented) instead of ``1`` or ``0``.

Modules/_cursesmodule.c

+4-4
Original file line numberDiff line numberDiff line change
@@ -1343,7 +1343,7 @@ _curses_window_echochar_impl(PyCursesWindowObject *self, PyObject *ch,
13431343

13441344
#ifdef NCURSES_MOUSE_VERSION
13451345
/*[clinic input]
1346-
_curses.window.enclose -> long
1346+
_curses.window.enclose
13471347
13481348
y: int
13491349
Y-coordinate.
@@ -1354,11 +1354,11 @@ _curses.window.enclose -> long
13541354
Return True if the screen-relative coordinates are enclosed by the window.
13551355
[clinic start generated code]*/
13561356

1357-
static long
1357+
static PyObject *
13581358
_curses_window_enclose_impl(PyCursesWindowObject *self, int y, int x)
1359-
/*[clinic end generated code: output=5251c961cbe3df63 input=dfe1d9d4d05d8642]*/
1359+
/*[clinic end generated code: output=8679beef50502648 input=4fd3355d723f7bc9]*/
13601360
{
1361-
return wenclose(self->win, y, x);
1361+
return PyBool_FromLong(wenclose(self->win, y, x));
13621362
}
13631363
#endif
13641364

Modules/clinic/_cursesmodule.c.h

+3-8
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)