Skip to content

bpo-43084: Return bool instead of int from curses.window.enclose() #24398

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 1 commit into from
Apr 5, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
3 changes: 3 additions & 0 deletions Doc/library/curses.rst
Original file line number Diff line number Diff line change
Expand Up @@ -915,6 +915,9 @@ the following methods and attributes:
determining what subset of the screen windows enclose the location of a mouse
event.

.. versionchanged:: 3.10
Previously it returned ``1`` or ``0`` instead of ``True`` or ``False``.


.. attribute:: window.encoding

Expand Down
13 changes: 6 additions & 7 deletions Lib/test/test_curses.py
Original file line number Diff line number Diff line change
Expand Up @@ -548,13 +548,12 @@ def test_resize(self):
@requires_curses_window_meth('enclose')
def test_enclose(self):
win = curses.newwin(5, 15, 2, 5)
# TODO: Return bool instead of 1/0
self.assertTrue(win.enclose(2, 5))
self.assertFalse(win.enclose(1, 5))
self.assertFalse(win.enclose(2, 4))
self.assertTrue(win.enclose(6, 19))
self.assertFalse(win.enclose(7, 19))
self.assertFalse(win.enclose(6, 20))
self.assertIs(win.enclose(2, 5), True)
self.assertIs(win.enclose(1, 5), False)
self.assertIs(win.enclose(2, 4), False)
self.assertIs(win.enclose(6, 19), True)
self.assertIs(win.enclose(7, 19), False)
self.assertIs(win.enclose(6, 20), False)

def test_putwin(self):
win = curses.newwin(5, 12, 1, 2)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
:func:`curses.window.enclose` returns now ``True`` or ``False`` (as was
documented) instead of ``1`` or ``0``.
8 changes: 4 additions & 4 deletions Modules/_cursesmodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -1341,7 +1341,7 @@ _curses_window_echochar_impl(PyCursesWindowObject *self, PyObject *ch,

#ifdef NCURSES_MOUSE_VERSION
/*[clinic input]
_curses.window.enclose -> long
_curses.window.enclose

y: int
Y-coordinate.
Expand All @@ -1352,11 +1352,11 @@ _curses.window.enclose -> long
Return True if the screen-relative coordinates are enclosed by the window.
[clinic start generated code]*/

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

Expand Down
11 changes: 3 additions & 8 deletions Modules/clinic/_cursesmodule.c.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.