Skip to content

Commit 0b5e26c

Browse files
authored
gh-157695: Make HAVE_CURSES_xxx macros private (#162212)
Rename HAVE_CURSES_xxx macros, added to Python 3.16, to _Py_HAVE_CURSES_xxx. Rename macros of functions: * define_key(): HAVE_CURSES_DEFINE_KEY * has_mouse(): HAVE_CURSES_HAS_MOUSE * is_keypad(): HAVE_CURSES_IS_KEYPAD * is_leaveok(): HAVE_CURSES_IS_LEAVEOK * key_defined(): HAVE_CURSES_KEY_DEFINED * keyok(): HAVE_CURSES_KEYOK * new_prescr(): HAVE_CURSES_NEW_PRESCR * nofilter(): HAVE_CURSES_NOFILTER * scr_dump(): HAVE_CURSES_SCR_DUMP * scr_set(): HAVE_CURSES_SCR_SET * slk_attr_off(): HAVE_CURSES_SLK_ATTR_OFF * slk_attr_on(): HAVE_CURSES_SLK_ATTR_ON * slk_attr_set(): HAVE_CURSES_SLK_ATTR_SET * slk_color(): HAVE_CURSES_SLK_COLOR * term_attrs(): HAVE_CURSES_TERM_ATTRS * use_screen(): HAVE_CURSES_USE_SCREEN * use_window(): HAVE_CURSES_USE_WINDOW * wattr_get(): HAVE_CURSES_WATTR_GET * wattr_off(): HAVE_CURSES_WATTR_OFF * wattr_on(): HAVE_CURSES_WATTR_ON * wattr_set(): HAVE_CURSES_WATTR_SET * wcolor_set(): HAVE_CURSES_WCOLOR_SET Add PY_CHECK_CURSES_FUNC_PRIVATE() function to configure.ac.
1 parent b0ccebc commit 0b5e26c

6 files changed

Lines changed: 559 additions & 510 deletions

File tree

‎Modules/_cursesmodule.c‎

Lines changed: 50 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -1936,10 +1936,10 @@ Window_NoArgTrueFalseFunction(is_scrollok)
19361936
Window_NoArgTrueFalseFunction(is_subwin)
19371937
Window_NoArgTrueFalseFunction(is_syncok)
19381938
#endif
1939-
#if defined(HAVE_CURSES_IS_KEYPAD) || defined(PDCURSES)
1939+
#if defined(_Py__Py_HAVE_CURSES_IS_KEYPAD) || defined(PDCURSES)
19401940
Window_NoArgTrueFalseFunction(is_keypad)
19411941
#endif
1942-
#if defined(HAVE_CURSES_IS_LEAVEOK) || defined(PDCURSES)
1942+
#if defined(_Py_HAVE_CURSES_IS_LEAVEOK) || defined(PDCURSES)
19431943
Window_NoArgTrueFalseFunction(is_leaveok)
19441944
#endif
19451945
#if defined(HAVE_CURSES_IS_PAD) || defined(PDCURSES)
@@ -2199,7 +2199,7 @@ static int
21992199
curses_wattr_save(PyCursesWindowObject *self, attr_t *attrs, int *pair,
22002200
const char *funcname)
22012201
{
2202-
#if defined(HAVE_CURSES_WATTR_GET) && defined(HAVE_CURSES_WATTR_SET)
2202+
#if defined(_Py_HAVE_CURSES_WATTR_GET) && defined(_Py_HAVE_CURSES_WATTR_SET)
22032203
int rtn;
22042204
#if _NCURSES_EXTENDED_COLOR_FUNCS
22052205
short legacy_pair;
@@ -2222,7 +2222,7 @@ curses_wattr_save(PyCursesWindowObject *self, attr_t *attrs, int *pair,
22222222

22232223
/* Put the rendition back. The name of the curses function used is
22242224
_CURSES_WATTR_RESTORE_FUNC, for the caller to name it in an error. */
2225-
#if defined(HAVE_CURSES_WATTR_GET) && defined(HAVE_CURSES_WATTR_SET)
2225+
#if defined(_Py_HAVE_CURSES_WATTR_GET) && defined(_Py_HAVE_CURSES_WATTR_SET)
22262226
#define _CURSES_WATTR_RESTORE_FUNC "wattr_set"
22272227
#else
22282228
#define _CURSES_WATTR_RESTORE_FUNC "wattrset"
@@ -2231,7 +2231,7 @@ curses_wattr_save(PyCursesWindowObject *self, attr_t *attrs, int *pair,
22312231
static int
22322232
curses_wattr_restore(PyCursesWindowObject *self, attr_t attrs, int pair)
22332233
{
2234-
#if defined(HAVE_CURSES_WATTR_GET) && defined(HAVE_CURSES_WATTR_SET)
2234+
#if defined(_Py_HAVE_CURSES_WATTR_GET) && defined(_Py_HAVE_CURSES_WATTR_SET)
22352235
#if _NCURSES_EXTENDED_COLOR_FUNCS
22362236
return wattr_set(self->win, attrs, 0, &pair);
22372237
#else
@@ -2558,7 +2558,7 @@ _curses_window_attrset_impl(PyCursesWindowObject *self, attr_t attr)
25582558
return curses_window_check_err(self, rtn, "wattrset", "attrset");
25592559
}
25602560

2561-
#ifdef HAVE_CURSES_WATTR_GET
2561+
#ifdef _Py_HAVE_CURSES_WATTR_GET
25622562
/*[clinic input]
25632563
_curses.window.attr_get
25642564
@@ -2584,9 +2584,9 @@ _curses_window_attr_get_impl(PyCursesWindowObject *self)
25842584
}
25852585
return Py_BuildValue("(ki)", (unsigned long)attrs, (int)pair);
25862586
}
2587-
#endif /* HAVE_CURSES_WATTR_GET */
2587+
#endif /* _Py_HAVE_CURSES_WATTR_GET */
25882588

2589-
#ifdef HAVE_CURSES_WATTR_SET
2589+
#ifdef _Py_HAVE_CURSES_WATTR_SET
25902590
/*[clinic input]
25912591
_curses.window.attr_set
25922592
@@ -2610,9 +2610,9 @@ _curses_window_attr_set_impl(PyCursesWindowObject *self, attr_t attr,
26102610
#endif
26112611
return curses_window_check_err(self, rtn, "wattr_set", "attr_set");
26122612
}
2613-
#endif /* HAVE_CURSES_WATTR_SET */
2613+
#endif /* _Py_HAVE_CURSES_WATTR_SET */
26142614

2615-
#ifdef HAVE_CURSES_WATTR_ON
2615+
#ifdef _Py_HAVE_CURSES_WATTR_ON
26162616
/*[clinic input]
26172617
_curses.window.attr_on
26182618
@@ -2629,9 +2629,9 @@ _curses_window_attr_on_impl(PyCursesWindowObject *self, attr_t attr)
26292629
int rtn = wattr_on(self->win, attr, NULL);
26302630
return curses_window_check_err(self, rtn, "wattr_on", "attr_on");
26312631
}
2632-
#endif /* HAVE_CURSES_WATTR_ON */
2632+
#endif /* _Py_HAVE_CURSES_WATTR_ON */
26332633

2634-
#ifdef HAVE_CURSES_WATTR_OFF
2634+
#ifdef _Py_HAVE_CURSES_WATTR_OFF
26352635
/*[clinic input]
26362636
_curses.window.attr_off
26372637
@@ -2648,9 +2648,9 @@ _curses_window_attr_off_impl(PyCursesWindowObject *self, attr_t attr)
26482648
int rtn = wattr_off(self->win, attr, NULL);
26492649
return curses_window_check_err(self, rtn, "wattr_off", "attr_off");
26502650
}
2651-
#endif /* HAVE_CURSES_WATTR_OFF */
2651+
#endif /* _Py_HAVE_CURSES_WATTR_OFF */
26522652

2653-
#ifdef HAVE_CURSES_WCOLOR_SET
2653+
#ifdef _Py_HAVE_CURSES_WCOLOR_SET
26542654
/*[clinic input]
26552655
_curses.window.color_set
26562656
@@ -2672,7 +2672,7 @@ _curses_window_color_set_impl(PyCursesWindowObject *self, int pair)
26722672
#endif
26732673
return curses_window_check_err(self, rtn, "wcolor_set", "color_set");
26742674
}
2675-
#endif /* HAVE_CURSES_WCOLOR_SET */
2675+
#endif /* _Py_HAVE_CURSES_WCOLOR_SET */
26762676

26772677
/*[clinic input]
26782678
_curses.window.getattrs
@@ -5035,7 +5035,7 @@ static PyType_Spec PyCursesComplexStr_Type_spec = {
50355035
};
50365036
#undef clinic_state
50375037

5038-
#if defined(HAVE_CURSES_USE_SCREEN) || defined(HAVE_CURSES_USE_WINDOW)
5038+
#if defined(_Py_HAVE_CURSES_USE_SCREEN) || defined(_Py_HAVE_CURSES_USE_WINDOW)
50395039
/* Shared trampoline for window.use()/screen.use(): call
50405040
func(obj, *extra, **kwargs) and store the result (NULL on exception) in
50415041
data->result. */
@@ -5085,7 +5085,7 @@ curses_use_parse(PyObject *args, PyObject **func, PyObject **extra)
50855085
}
50865086
#endif
50875087

5088-
#ifdef HAVE_CURSES_USE_WINDOW
5088+
#ifdef _Py_HAVE_CURSES_USE_WINDOW
50895089
static int
50905090
curses_use_window_cb(WINDOW *Py_UNUSED(win), void *data)
50915091
{
@@ -5111,7 +5111,7 @@ PyCursesWindow_use(PyObject *self, PyObject *args, PyObject *kwargs)
51115111
Py_DECREF(extra);
51125112
return data.result;
51135113
}
5114-
#endif /* HAVE_CURSES_USE_WINDOW */
5114+
#endif /* _Py_HAVE_CURSES_USE_WINDOW */
51155115

51165116
static PyMethodDef PyCursesWindow_methods[] = {
51175117
_CURSES_WINDOW_ADDCH_METHODDEF
@@ -5250,12 +5250,12 @@ static PyMethodDef PyCursesWindow_methods[] = {
52505250
"is_syncok($self, /)\n--\n\n"
52515251
"Return the current value set by syncok()."},
52525252
#endif
5253-
#if defined(HAVE_CURSES_IS_KEYPAD) || defined(PDCURSES)
5253+
#if defined(_Py__Py_HAVE_CURSES_IS_KEYPAD) || defined(PDCURSES)
52545254
{"is_keypad", PyCursesWindow_is_keypad, METH_NOARGS,
52555255
"is_keypad($self, /)\n--\n\n"
52565256
"Return the current value set by keypad()."},
52575257
#endif
5258-
#if defined(HAVE_CURSES_IS_LEAVEOK) || defined(PDCURSES)
5258+
#if defined(_Py_HAVE_CURSES_IS_LEAVEOK) || defined(PDCURSES)
52595259
{"is_leaveok", PyCursesWindow_is_leaveok, METH_NOARGS,
52605260
"is_leaveok($self, /)\n--\n\n"
52615261
"Return the current value set by leaveok()."},
@@ -5336,7 +5336,7 @@ static PyMethodDef PyCursesWindow_methods[] = {
53365336
"untouchwin($self, /)\n--\n\n"
53375337
"Mark all lines in the window as unchanged since last refresh()."},
53385338
_CURSES_WINDOW_VLINE_METHODDEF
5339-
#ifdef HAVE_CURSES_USE_WINDOW
5339+
#ifdef _Py_HAVE_CURSES_USE_WINDOW
53405340
{"use", _PyCFunction_CAST(PyCursesWindow_use),
53415341
METH_VARARGS | METH_KEYWORDS, PyCursesWindow_use__doc__},
53425342
#endif
@@ -5478,7 +5478,7 @@ static PyGetSetDef PyCursesScreen_getsets[] = {
54785478
{NULL, NULL, NULL, NULL, NULL} /* sentinel */
54795479
};
54805480

5481-
#ifdef HAVE_CURSES_USE_SCREEN
5481+
#ifdef _Py_HAVE_CURSES_USE_SCREEN
54825482
static int
54835483
curses_use_screen_cb(SCREEN *Py_UNUSED(sp), void *data)
54845484
{
@@ -5533,7 +5533,7 @@ PyCursesScreen_use(PyObject *self, PyObject *args, PyObject *kwargs)
55335533
}
55345534
return data.result;
55355535
}
5536-
#endif /* HAVE_CURSES_USE_SCREEN */
5536+
#endif /* _Py_HAVE_CURSES_USE_SCREEN */
55375537

55385538
PyDoc_STRVAR(PyCursesScreen_close__doc__,
55395539
"close($self, /)\n--\n\n"
@@ -5552,7 +5552,7 @@ PyCursesScreen_close(PyObject *self, PyObject *Py_UNUSED(ignored))
55525552
static PyMethodDef PyCursesScreen_methods[] = {
55535553
{"close", PyCursesScreen_close, METH_NOARGS,
55545554
PyCursesScreen_close__doc__},
5555-
#ifdef HAVE_CURSES_USE_SCREEN
5555+
#ifdef _Py_HAVE_CURSES_USE_SCREEN
55565556
{"use", _PyCFunction_CAST(PyCursesScreen_use),
55575557
METH_VARARGS | METH_KEYWORDS, PyCursesScreen_use__doc__},
55585558
#endif
@@ -5704,7 +5704,7 @@ _curses_filter_impl(PyObject *module)
57045704
}
57055705
#endif
57065706

5707-
#ifdef HAVE_CURSES_NOFILTER
5707+
#ifdef _Py_HAVE_CURSES_NOFILTER
57085708
/*[clinic input]
57095709
_curses.nofilter
57105710
@@ -6269,7 +6269,7 @@ _curses_getwin(PyObject *module, PyObject *file)
62696269
return res;
62706270
}
62716271

6272-
#ifdef HAVE_CURSES_SCR_DUMP
6272+
#ifdef _Py_HAVE_CURSES_SCR_DUMP
62736273
/*[clinic input]
62746274
_curses.scr_dump
62756275
@@ -6324,7 +6324,7 @@ _curses_scr_init(PyObject *module, PyObject *filename)
63246324
/*[clinic end generated code: output=2e861d381d710419 input=81c45e4702124ef6]*/
63256325
ScreenDumpFunctionBody(scr_init)
63266326

6327-
#ifdef HAVE_CURSES_SCR_SET
6327+
#ifdef _Py_HAVE_CURSES_SCR_SET
63286328
/*[clinic input]
63296329
_curses.scr_set
63306330
@@ -6341,8 +6341,8 @@ static PyObject *
63416341
_curses_scr_set(PyObject *module, PyObject *filename)
63426342
/*[clinic end generated code: output=6056fdec12c5935f input=d248c20543cc289b]*/
63436343
ScreenDumpFunctionBody(scr_set)
6344-
#endif /* HAVE_CURSES_SCR_SET */
6345-
#endif /* HAVE_CURSES_SCR_DUMP */
6344+
#endif /* _Py_HAVE_CURSES_SCR_SET */
6345+
#endif /* _Py_HAVE_CURSES_SCR_DUMP */
63466346

63476347
/*[clinic input]
63486348
_curses.halfdelay
@@ -6421,7 +6421,7 @@ _curses_has_key_impl(PyObject *module, int key)
64216421
}
64226422
#endif
64236423

6424-
#ifdef HAVE_CURSES_DEFINE_KEY
6424+
#ifdef _Py_HAVE_CURSES_DEFINE_KEY
64256425
/*[clinic input]
64266426
_curses.define_key
64276427
@@ -6447,9 +6447,9 @@ _curses_define_key_impl(PyObject *module, const char *definition,
64476447
return curses_check_err(module, define_key(definition, keycode),
64486448
"define_key", NULL);
64496449
}
6450-
#endif /* HAVE_CURSES_DEFINE_KEY */
6450+
#endif /* _Py_HAVE_CURSES_DEFINE_KEY */
64516451

6452-
#ifdef HAVE_CURSES_KEY_DEFINED
6452+
#ifdef _Py_HAVE_CURSES_KEY_DEFINED
64536453
/*[clinic input]
64546454
_curses.key_defined
64556455
@@ -6471,9 +6471,9 @@ _curses_key_defined_impl(PyObject *module, const char *definition)
64716471

64726472
return PyLong_FromLong(key_defined(definition));
64736473
}
6474-
#endif /* HAVE_CURSES_KEY_DEFINED */
6474+
#endif /* _Py_HAVE_CURSES_KEY_DEFINED */
64756475

6476-
#ifdef HAVE_CURSES_KEYOK
6476+
#ifdef _Py_HAVE_CURSES_KEYOK
64776477
/*[clinic input]
64786478
_curses.keyok
64796479
@@ -6494,7 +6494,7 @@ _curses_keyok_impl(PyObject *module, int keycode, int enable)
64946494

64956495
return curses_check_err(module, keyok(keycode, enable), "keyok", NULL);
64966496
}
6497-
#endif /* HAVE_CURSES_KEYOK */
6497+
#endif /* _Py_HAVE_CURSES_KEYOK */
64986498

64996499
/*[clinic input]
65006500
_curses.init_color
@@ -7283,7 +7283,7 @@ _curses_set_term(PyObject *module, PyObject *screen)
72837283
return prev != NULL ? prev : Py_NewRef(Py_None);
72847284
}
72857285

7286-
#ifdef HAVE_CURSES_NEW_PRESCR
7286+
#ifdef _Py_HAVE_CURSES_NEW_PRESCR
72877287
/*[clinic input]
72887288
_curses.new_prescr
72897289
@@ -7317,7 +7317,7 @@ _curses_new_prescr_impl(PyObject *module)
73177317
state->prescreen = Py_NewRef(screenobj);
73187318
return screenobj;
73197319
}
7320-
#endif /* HAVE_CURSES_NEW_PRESCR */
7320+
#endif /* _Py_HAVE_CURSES_NEW_PRESCR */
73217321

73227322
#ifdef HAVE_CURSES_ESCDELAY
73237323
/*[clinic input]
@@ -7573,7 +7573,7 @@ _curses_meta_impl(PyObject *module, int yes)
75737573
}
75747574

75757575
#if defined(HAVE_CURSES_GETMOUSE) || defined(PDCURSES)
7576-
#if defined(HAVE_CURSES_HAS_MOUSE) || defined(PDCURSES)
7576+
#if defined(_Py_HAVE_CURSES_HAS_MOUSE) || defined(PDCURSES)
75777577
/*[clinic input]
75787578
_curses.has_mouse
75797579
@@ -7588,7 +7588,7 @@ _curses_has_mouse_impl(PyObject *module)
75887588

75897589
return PyBool_FromLong(has_mouse());
75907590
}
7591-
#endif /* HAVE_CURSES_HAS_MOUSE || PDCURSES */
7591+
#endif /* _Py_HAVE_CURSES_HAS_MOUSE || PDCURSES */
75927592

75937593
/*[clinic input]
75947594
_curses.mouseinterval
@@ -8272,7 +8272,7 @@ _curses_termattrs_impl(PyObject *module)
82728272
return PyLong_FromUnsignedLong((unsigned long)(chtype)termattrs());
82738273
}
82748274

8275-
#ifdef HAVE_CURSES_TERM_ATTRS
8275+
#ifdef _Py_HAVE_CURSES_TERM_ATTRS
82768276
/*[clinic input]
82778277
_curses.term_attrs
82788278
@@ -8290,7 +8290,7 @@ _curses_term_attrs_impl(PyObject *module)
82908290

82918291
return PyLong_FromUnsignedLongLong(term_attrs());
82928292
}
8293-
#endif /* HAVE_CURSES_TERM_ATTRS */
8293+
#endif /* _Py_HAVE_CURSES_TERM_ATTRS */
82948294

82958295
/*[clinic input]
82968296
@permit_long_summary
@@ -8877,7 +8877,7 @@ _curses_slk_attr_impl(PyObject *module)
88778877
}
88788878
#endif
88798879

8880-
#ifdef HAVE_CURSES_SLK_ATTR_ON
8880+
#ifdef _Py_HAVE_CURSES_SLK_ATTR_ON
88818881
/*[clinic input]
88828882
_curses.slk_attr_on
88838883
@@ -8895,9 +8895,9 @@ _curses_slk_attr_on_impl(PyObject *module, attr_t attr)
88958895
return curses_check_err(module, slk_attr_on(attr, NULL),
88968896
"slk_attr_on", NULL);
88978897
}
8898-
#endif /* HAVE_CURSES_SLK_ATTR_ON */
8898+
#endif /* _Py_HAVE_CURSES_SLK_ATTR_ON */
88998899

8900-
#ifdef HAVE_CURSES_SLK_ATTR_OFF
8900+
#ifdef _Py_HAVE_CURSES_SLK_ATTR_OFF
89018901
/*[clinic input]
89028902
_curses.slk_attr_off
89038903
@@ -8915,9 +8915,9 @@ _curses_slk_attr_off_impl(PyObject *module, attr_t attr)
89158915
return curses_check_err(module, slk_attr_off(attr, NULL),
89168916
"slk_attr_off", NULL);
89178917
}
8918-
#endif /* HAVE_CURSES_SLK_ATTR_OFF */
8918+
#endif /* _Py_HAVE_CURSES_SLK_ATTR_OFF */
89198919

8920-
#ifdef HAVE_CURSES_SLK_ATTR_SET
8920+
#ifdef _Py_HAVE_CURSES_SLK_ATTR_SET
89218921
/*[clinic input]
89228922
_curses.slk_attr_set
89238923
@@ -8941,9 +8941,9 @@ _curses_slk_attr_set_impl(PyObject *module, attr_t attr, int pair)
89418941
#endif
89428942
return curses_check_err(module, rtn, "slk_attr_set", NULL);
89438943
}
8944-
#endif /* HAVE_CURSES_SLK_ATTR_SET */
8944+
#endif /* _Py_HAVE_CURSES_SLK_ATTR_SET */
89458945

8946-
#ifdef HAVE_CURSES_SLK_COLOR
8946+
#ifdef _Py_HAVE_CURSES_SLK_COLOR
89478947
/*[clinic input]
89488948
_curses.slk_color
89498949
@@ -8966,7 +8966,7 @@ _curses_slk_color_impl(PyObject *module, int pair)
89668966
#endif
89678967
return curses_check_err(module, rtn, "slk_color", NULL);
89688968
}
8969-
#endif /* HAVE_CURSES_SLK_COLOR */
8969+
#endif /* _Py_HAVE_CURSES_SLK_COLOR */
89708970

89718971
#ifdef HAVE_CURSES_USE_ENV
89728972
/*[clinic input]
@@ -9178,7 +9178,7 @@ static PyMethodDef cursesmodule_methods[] = {
91789178
_CURSES_NEWPAD_METHODDEF
91799179
_CURSES_NEWTERM_METHODDEF
91809180
_CURSES_NEWWIN_METHODDEF
9181-
#ifdef HAVE_CURSES_NEW_PRESCR
9181+
#ifdef _Py_HAVE_CURSES_NEW_PRESCR
91829182
_CURSES_NEW_PRESCR_METHODDEF
91839183
#endif
91849184
_CURSES_NL_METHODDEF

0 commit comments

Comments
 (0)