Title: ctypes: Add docstring for `ctypes.Array` · Issue #107689 · python/cpython · GitHub
Open Graph Title: ctypes: Add docstring for `ctypes.Array` · Issue #107689 · python/cpython
X Title: ctypes: Add docstring for `ctypes.Array` · Issue #107689 · python/cpython
Description: Documentation The Array class from the ctypes module doesn't have a proper docstring: from ctypes import Array help(Array) >>> Help on class Array in module _ctypes: >>> >>> class Array(_CData) >>> | XXX to be provided # !! >>> | Though ...
Open Graph Description: Documentation The Array class from the ctypes module doesn't have a proper docstring: from ctypes import Array help(Array) >>> Help on class Array in module _ctypes: >>> >>> class Array(_CData) >>>...
X Description: Documentation The Array class from the ctypes module doesn't have a proper docstring: from ctypes import Array help(Array) >>> Help on class Array in module _ctypes: >>> >&...
Opengraph URL: https://github.com/python/cpython/issues/107689
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"ctypes: Add docstring for `ctypes.Array`","articleBody":"# Documentation\r\n\r\nThe [`Array` class](https://docs.python.org/3.13/library/ctypes.html#ctypes.Array) from the `ctypes` module doesn't have a proper docstring:\r\n\r\n```python\r\nfrom ctypes import Array\r\nhelp(Array)\r\n\r\n\u003e\u003e\u003e Help on class Array in module _ctypes:\r\n\u003e\u003e\u003e\r\n\u003e\u003e\u003e class Array(_CData)\r\n\u003e\u003e\u003e | XXX to be provided # !!\r\n\u003e\u003e\u003e |\r\n```\r\n\r\nThough the class is documented in the [docs](https://docs.python.org/3.13/library/ctypes.html#ctypes.Array) so we could just reuse that description.\r\n\r\nFeel free to pick up this issue :) If you're new to the C internals, here's a small guide to help you get started:\r\n\r\n`ctypes.Array` is a class implemented in C defined in `Modules/_ctypes/_ctypes.c`. Here is the current docstring definition:\r\n\r\nhttps://github.com/python/cpython/blob/71a7c96ffeb0d7fef06be3e57468896e030967a5/Modules/_ctypes/_ctypes.c#L4816-L4818\r\n\r\nTo update the docstring, we could simply change the argument of `PyDoc_STR(...)` but if the docstring is longer it's better to use [PyDoc_STRVAR](https://docs.python.org/3/c-api/intro.html#c.PyDoc_STRVAR) to create a separate variable with the new docstring:\r\n\r\n```c\r\nPyDoc_STRVAR(array_doc,\r\n\"Abstract base class for arrays.\\n\"\r\n\"\\n\"\r\n\"The recommended way to create ...\");\r\n```\r\nthen you substitute it back instead of `PyDoc_STR`:\r\n```diff\r\nPy_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */ \r\n- PyDoc_STR(\"XXX to be provided\"), /* tp_doc */ \r\n+ array_doc, /* tp_doc */ \r\n(traverseproc)PyCData_traverse, \r\n```\r\n\r\nTo test that it worked, rebuild python and check the docstring ;)\r\n\r\n\n\n\u003c!-- gh-linked-prs --\u003e\n### Linked PRs\n* gh-107697\n* gh-108882\n\u003c!-- /gh-linked-prs --\u003e\n","author":{"url":"https://github.com/tomasr8","@type":"Person","name":"tomasr8"},"datePublished":"2023-08-06T10:56:35.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":7},"url":"https://github.com/107689/cpython/issues/107689"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:4394eae3-e045-0e55-7ea0-7c4ce658c08c |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 86F8:320F8E:169C9E7:1EFE60D:696AA91D |
| html-safe-nonce | cba8bc58bca2480c9c40bbd31d47c9d7b1b3945666a5b01623440a4447bfaa99 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4NkY4OjMyMEY4RToxNjlDOUU3OjFFRkU2MEQ6Njk2QUE5MUQiLCJ2aXNpdG9yX2lkIjoiODEwODc1NTc0NTMwNjc0OTIxMyIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | ed3dc9f2fcda5b9e7a49b83c73e1a5b8b8025685d95ad6d2202118fe0193513b |
| hovercard-subject-tag | issue:1838157545 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/python/cpython/107689/issue_layout |
| twitter:image | https://opengraph.githubassets.com/05c75d5011705b7af285d5e59408d3b5e7d7284a83a6bd538e9d2eae7ae3fdce/python/cpython/issues/107689 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/05c75d5011705b7af285d5e59408d3b5e7d7284a83a6bd538e9d2eae7ae3fdce/python/cpython/issues/107689 |
| og:image:alt | Documentation The Array class from the ctypes module doesn't have a proper docstring: from ctypes import Array help(Array) >>> Help on class Array in module _ctypes: >>> >>> class Array(_CData) >>>... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | tomasr8 |
| hostname | github.com |
| expected-hostname | github.com |
| None | 3eaf9b8cf1badcd7041a8ad480b9d9b28bea0ef1cc821ca9ff20f2cc7f4fe4b9 |
| turbo-cache-control | no-preview |
| go-import | github.com/python/cpython git https://github.com/python/cpython.git |
| octolytics-dimension-user_id | 1525981 |
| octolytics-dimension-user_login | python |
| octolytics-dimension-repository_id | 81598961 |
| octolytics-dimension-repository_nwo | python/cpython |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 81598961 |
| octolytics-dimension-repository_network_root_nwo | python/cpython |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | dd9a979046e6382bd084e2bd873bf65f797125ff |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width