FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

gh-107689: add docstrings to abstract classes by kiblik1 · Pull Request #108882 · python/cpython · GitHub

/ cpython Public
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .c  (1) .rst  (1) All 2 file types selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Added docstrings to abstract ctypes.
33 changes: 30 additions & 3 deletions Modules/_ctypes/_ctypes.c
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -2899,6 +2899,13 @@ static PyMethodDef PyCData_methods[] = {
{ NULL, NULL },
};

PyDoc_STRVAR(cdata_doc,
"This non-public class is the common base class of all ctypes data types. Among other things, all ctypes type\n"
"instances contain a memory block that hold C compatible data; the address of the memory block is returned\n"
"by the addressof() helper function. Another instance variable is exposed as _objects; this contains\n"
"other Python objects that need to be kept alive in case the memory block contains pointers."
);

PyTypeObject PyCData_Type = {
PyVarObject_HEAD_INIT(NULL, 0)
"_ctypes._CData",
Expand All @@ -2920,7 +2927,7 @@ PyTypeObject PyCData_Type = {
0, /* tp_setattro */
&PyCData_as_buffer, /* tp_as_buffer */
Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
PyDoc_STR("XXX to be provided"), /* tp_doc */
cdata_doc, /* tp_doc */
(traverseproc)PyCData_traverse, /* tp_traverse */
(inquiry)PyCData_clear, /* tp_clear */
0, /* tp_richcompare */
Expand Down Expand Up @@ -5020,6 +5027,13 @@ Simple_repr(CDataObject *self)
return result;
}


PyDoc_STRVAR(simple_cdata_doc,
"This non-public class is the base class of all fundamental ctypes data types.\n"
"It contains the common attributes of the fundamentalctypes data types.\n"
"_SimpleCData is a subclass of _CData, so it inherits their methods and attributes."
);

static PyTypeObject Simple_Type = {
PyVarObject_HEAD_INIT(NULL, 0)
"_ctypes._SimpleCData",
Expand All @@ -5041,7 +5055,7 @@ static PyTypeObject Simple_Type = {
0, /* tp_setattro */
&PyCData_as_buffer, /* tp_as_buffer */
Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
PyDoc_STR("XXX to be provided"), /* tp_doc */
simple_cdata_doc, /* tp_doc */
(traverseproc)PyCData_traverse, /* tp_traverse */
(inquiry)PyCData_clear, /* tp_clear */
0, /* tp_richcompare */
Expand Down Expand Up @@ -5402,6 +5416,19 @@ static PyNumberMethods Pointer_as_number = {
(inquiry)Pointer_bool, /* nb_bool */
};


PyDoc_STRVAR(cpointer_doc,
"Private, abstract base class for pointers.\n"
"\n"
"Concrete pointer types are created by calling POINTER() with the type that will be pointed to; this is done\n"
"automatically by pointer().\n"
"\n"
"If a pointer points to an array, its elements can be read and written using standard subscript and slice ac-\n"
"cesses. Pointer objects have no size, so len() will raise TypeError. Negative subscripts will read from the\n"
"memory before the pointer (as in C), and out-of-range subscripts will probably crash with an access violation\n"
"(if you’re lucky)."
);

PyTypeObject PyCPointer_Type = {
PyVarObject_HEAD_INIT(NULL, 0)
"_ctypes._Pointer",
Expand All @@ -5423,7 +5450,7 @@ PyTypeObject PyCPointer_Type = {
0, /* tp_setattro */
&PyCData_as_buffer, /* tp_as_buffer */
Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
PyDoc_STR("XXX to be provided"), /* tp_doc */
cpointer_doc, /* tp_doc */
(traverseproc)PyCData_traverse, /* tp_traverse */
(inquiry)PyCData_clear, /* tp_clear */
0, /* tp_richcompare */
Expand Down

Back | FazBrowse Home | New Git URL