@@ -1112,12 +1112,13 @@ _curses_window_addstr_impl(PyCursesWindowObject *self, int group_left_1,
11121112 attr_old = getattrs (self -> win );
11131113 if (curses_wattrset (self , attr , "addstr" ) < 0 ) {
11141114 curses_release_wstr (strtype , wstr );
1115- Py_DECREF (bytesobj );
1115+ Py_XDECREF (bytesobj );
11161116 return NULL ;
11171117 }
11181118 }
11191119#ifdef HAVE_NCURSESW
11201120 if (strtype == 2 ) {
1121+ assert (bytesobj == NULL );
11211122 if (use_xy ) {
11221123 rtn = mvwaddwstr (self -> win ,y ,x ,wstr );
11231124 funcname = "mvwaddwstr" ;
@@ -1131,6 +1132,7 @@ _curses_window_addstr_impl(PyCursesWindowObject *self, int group_left_1,
11311132 else
11321133#endif
11331134 {
1135+ assert (wstr == NULL );
11341136 const char * str = PyBytes_AS_STRING (bytesobj );
11351137 if (use_xy ) {
11361138 rtn = mvwaddstr (self -> win ,y ,x ,str );
@@ -1211,7 +1213,7 @@ _curses_window_addnstr_impl(PyCursesWindowObject *self, int group_left_1,
12111213 attr_old = getattrs (self -> win );
12121214 if (curses_wattrset (self , attr , "addnstr" ) < 0 ) {
12131215 curses_release_wstr (strtype , wstr );
1214- Py_DECREF (bytesobj );
1216+ Py_XDECREF (bytesobj );
12151217 return NULL ;
12161218 }
12171219 }
@@ -2214,7 +2216,7 @@ _curses_window_insstr_impl(PyCursesWindowObject *self, int group_left_1,
22142216 attr_old = getattrs (self -> win );
22152217 if (curses_wattrset (self , attr , "insstr" ) < 0 ) {
22162218 curses_release_wstr (strtype , wstr );
2217- Py_DECREF (bytesobj );
2219+ Py_XDECREF (bytesobj );
22182220 return NULL ;
22192221 }
22202222 }
0 commit comments