]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
[3.13] gh-126313: Fix a crash in curses.napms() due to incorrect error handling ...
authorBénédikt Tran <10796600+picnixz@users.noreply.github.com>
Wed, 6 Nov 2024 13:33:23 +0000 (14:33 +0100)
committerGitHub <noreply@github.com>
Wed, 6 Nov 2024 13:33:23 +0000 (14:33 +0100)
gh-126313: Fix a crash in curses.napms() due to incorrect error handling (GH-126351)

Misc/NEWS.d/next/Library/2024-11-03-09-42-42.gh-issue-126313.EFP6Dl.rst [new file with mode: 0644]
Modules/_cursesmodule.c

diff --git a/Misc/NEWS.d/next/Library/2024-11-03-09-42-42.gh-issue-126313.EFP6Dl.rst b/Misc/NEWS.d/next/Library/2024-11-03-09-42-42.gh-issue-126313.EFP6Dl.rst
new file mode 100644 (file)
index 0000000..dad348d
--- /dev/null
@@ -0,0 +1,2 @@
+Fix an issue in :func:`curses.napms` when :func:`curses.initscr` has not yet
+been called. Patch by Bénédikt Tran.
index f926fa2f9c00938b10fa9295c2e44ca56594521f..55038cf09c28760b21f50d741300ec4937067954 100644 (file)
@@ -3688,7 +3688,10 @@ static int
 _curses_napms_impl(PyObject *module, int ms)
 /*[clinic end generated code: output=5f292a6a724491bd input=c6d6e01f2f1df9f7]*/
 {
-    PyCursesInitialised;
+    if (initialised != TRUE) {
+        PyErr_SetString(PyCursesError, "must call initscr() first");
+        return -1;
+    }
 
     return napms(ms);
 }