Skip to content

Commit b5d1e45

Browse files
gh-128083: Fix macro redefinition warning in clinic. (GH-127950)
1 parent ea578fc commit b5d1e45

File tree

4 files changed

+131
-2
lines changed

4 files changed

+131
-2
lines changed

Lib/test/clinic.test.c

+69
Original file line numberDiff line numberDiff line change
@@ -5358,6 +5358,75 @@ static int
53585358
Test_property_set_impl(TestObj *self, PyObject *value)
53595359
/*[clinic end generated code: output=e4342fe9bb1d7817 input=3bc3f46a23c83a88]*/
53605360

5361+
/*[clinic input]
5362+
@setter
5363+
Test.setter_first_with_docstr
5364+
[clinic start generated code]*/
5365+
5366+
#if !defined(Test_setter_first_with_docstr_DOCSTR)
5367+
# define Test_setter_first_with_docstr_DOCSTR NULL
5368+
#endif
5369+
#if defined(TEST_SETTER_FIRST_WITH_DOCSTR_GETSETDEF)
5370+
# undef TEST_SETTER_FIRST_WITH_DOCSTR_GETSETDEF
5371+
# define TEST_SETTER_FIRST_WITH_DOCSTR_GETSETDEF {"setter_first_with_docstr", (getter)Test_setter_first_with_docstr_get, (setter)Test_setter_first_with_docstr_set, Test_setter_first_with_docstr_DOCSTR},
5372+
#else
5373+
# define TEST_SETTER_FIRST_WITH_DOCSTR_GETSETDEF {"setter_first_with_docstr", NULL, (setter)Test_setter_first_with_docstr_set, NULL},
5374+
#endif
5375+
5376+
static int
5377+
Test_setter_first_with_docstr_set_impl(TestObj *self, PyObject *value);
5378+
5379+
static int
5380+
Test_setter_first_with_docstr_set(TestObj *self, PyObject *value, void *Py_UNUSED(context))
5381+
{
5382+
int return_value;
5383+
5384+
return_value = Test_setter_first_with_docstr_set_impl(self, value);
5385+
5386+
return return_value;
5387+
}
5388+
5389+
static int
5390+
Test_setter_first_with_docstr_set_impl(TestObj *self, PyObject *value)
5391+
/*[clinic end generated code: output=e4d76b558a4061db input=31a045ce11bbe961]*/
5392+
5393+
/*[clinic input]
5394+
@getter
5395+
Test.setter_first_with_docstr
5396+
5397+
my silly docstring
5398+
[clinic start generated code]*/
5399+
5400+
PyDoc_STRVAR(Test_setter_first_with_docstr__doc__,
5401+
"my silly docstring");
5402+
#if defined(Test_setter_first_with_docstr_DOCSTR)
5403+
# undef Test_setter_first_with_docstr_DOCSTR
5404+
#endif
5405+
#define Test_setter_first_with_docstr_DOCSTR Test_setter_first_with_docstr__doc__
5406+
5407+
#if !defined(Test_setter_first_with_docstr_DOCSTR)
5408+
# define Test_setter_first_with_docstr_DOCSTR NULL
5409+
#endif
5410+
#if defined(TEST_SETTER_FIRST_WITH_DOCSTR_GETSETDEF)
5411+
# undef TEST_SETTER_FIRST_WITH_DOCSTR_GETSETDEF
5412+
# define TEST_SETTER_FIRST_WITH_DOCSTR_GETSETDEF {"setter_first_with_docstr", (getter)Test_setter_first_with_docstr_get, (setter)Test_setter_first_with_docstr_set, Test_setter_first_with_docstr_DOCSTR},
5413+
#else
5414+
# define TEST_SETTER_FIRST_WITH_DOCSTR_GETSETDEF {"setter_first_with_docstr", (getter)Test_setter_first_with_docstr_get, NULL, Test_setter_first_with_docstr_DOCSTR},
5415+
#endif
5416+
5417+
static PyObject *
5418+
Test_setter_first_with_docstr_get_impl(TestObj *self);
5419+
5420+
static PyObject *
5421+
Test_setter_first_with_docstr_get(TestObj *self, void *Py_UNUSED(context))
5422+
{
5423+
return Test_setter_first_with_docstr_get_impl(self);
5424+
}
5425+
5426+
static PyObject *
5427+
Test_setter_first_with_docstr_get_impl(TestObj *self)
5428+
/*[clinic end generated code: output=749a30266f9fb443 input=10af4e43b3cb34dc]*/
5429+
53615430
/*[clinic input]
53625431
output push
53635432
output preset buffer

Modules/_io/clinic/textio.c.h

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

Modules/clinic/_ssl.c.h

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

Tools/clinic/libclinic/parse_args.py

+3
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,9 @@ def declare_parser(
146146
GETSET_DOCSTRING_PROTOTYPE_STRVAR: Final[str] = libclinic.normalize_snippet("""
147147
PyDoc_STRVAR({getset_basename}__doc__,
148148
{docstring});
149+
#if defined({getset_basename}_DOCSTR)
150+
# undef {getset_basename}_DOCSTR
151+
#endif
149152
#define {getset_basename}_DOCSTR {getset_basename}__doc__
150153
""")
151154
IMPL_DEFINITION_PROTOTYPE: Final[str] = libclinic.normalize_snippet("""

0 commit comments

Comments
 (0)