Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
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
20 changes: 15 additions & 5 deletions 20 Lib/test/clinic.test.c
Original file line number Diff line number Diff line change
Expand Up @@ -4956,11 +4956,16 @@ Test_meth_coexist_impl(TestObj *self)
Test.property
[clinic start generated code]*/

#if defined(Test_property_HAS_DOCSTR)
# define Test_property_DOCSTR Test_property__doc__
#else
# define Test_property_DOCSTR NULL
#endif
#if defined(TEST_PROPERTY_GETSETDEF)
# undef TEST_PROPERTY_GETSETDEF
# define TEST_PROPERTY_GETSETDEF {"property", (getter)Test_property_get, (setter)Test_property_set, NULL},
# define TEST_PROPERTY_GETSETDEF {"property", (getter)Test_property_get, (setter)Test_property_set, Test_property_DOCSTR},
#else
# define TEST_PROPERTY_GETSETDEF {"property", (getter)Test_property_get, NULL, NULL},
# define TEST_PROPERTY_GETSETDEF {"property", (getter)Test_property_get, NULL, Test_property_DOCSTR},
#endif

static PyObject *
Expand All @@ -4974,16 +4979,21 @@ Test_property_get(TestObj *self, void *Py_UNUSED(context))

static PyObject *
Test_property_get_impl(TestObj *self)
/*[clinic end generated code: output=af8140b692e0e2f1 input=2d92b3449fbc7d2b]*/
/*[clinic end generated code: output=27b519719d992e03 input=2d92b3449fbc7d2b]*/

/*[clinic input]
@setter
Test.property
[clinic start generated code]*/

#if defined(TEST_PROPERTY_HAS_DOCSTR)
# define Test_property_DOCSTR Test_property__doc__
#else
# define Test_property_DOCSTR NULL
#endif
#if defined(TEST_PROPERTY_GETSETDEF)
# undef TEST_PROPERTY_GETSETDEF
# define TEST_PROPERTY_GETSETDEF {"property", (getter)Test_property_get, (setter)Test_property_set, NULL},
# define TEST_PROPERTY_GETSETDEF {"property", (getter)Test_property_get, (setter)Test_property_set, Test_property_DOCSTR},
#else
# define TEST_PROPERTY_GETSETDEF {"property", NULL, (setter)Test_property_set, NULL},
#endif
Expand All @@ -4999,7 +5009,7 @@ Test_property_set(TestObj *self, PyObject *value, void *Py_UNUSED(context))

static int
Test_property_set_impl(TestObj *self, PyObject *value)
/*[clinic end generated code: output=f3eba6487d7550e2 input=3bc3f46a23c83a88]*/
/*[clinic end generated code: output=9797cd03c5204ddb input=3bc3f46a23c83a88]*/

/*[clinic input]
output push
Expand Down
15 changes: 15 additions & 0 deletions 15 Lib/test/test_clinic.py
Original file line number Diff line number Diff line change
Expand Up @@ -2221,6 +2221,21 @@ class Foo "" ""
expected_error = f"{annotation} method cannot define parameters"
self.expect_failure(block, expected_error)

def test_setter_docstring(self):
block = """
module foo
class Foo "" ""
@setter
Foo.property

foo

bar
[clinic start generated code]*/
"""
expected_error = "docstrings are only supported for @getter, not @setter"
self.expect_failure(block, expected_error)

def test_duplicate_getset(self):
annotations = ["@getter", "@setter"]
for annotation in annotations:
Expand Down
29 changes: 22 additions & 7 deletions 29 Modules/_io/clinic/bufferedio.c.h

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

29 changes: 22 additions & 7 deletions 29 Modules/_io/clinic/stringio.c.h

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

Loading
Morty Proxy This is a proxified and sanitized view of the page, visit original site.