Title: Argument Clinic includes internal headers in generated output unconditionally · Issue #107603 · python/cpython · GitHub
Open Graph Title: Argument Clinic includes internal headers in generated output unconditionally · Issue #107603 · python/cpython
X Title: Argument Clinic includes internal headers in generated output unconditionally · Issue #107603 · python/cpython
Description: It seems like Argument Clinic generates code that define Py_BUILD_CORE and includes internal headers unconditionally; for example, a file with a METH_O function will have no need for those: Details /*[clinic input] preserve [clinic start...
Open Graph Description: It seems like Argument Clinic generates code that define Py_BUILD_CORE and includes internal headers unconditionally; for example, a file with a METH_O function will have no need for those: Details...
X Description: It seems like Argument Clinic generates code that define Py_BUILD_CORE and includes internal headers unconditionally; for example, a file with a METH_O function will have no need for those: Details...
Opengraph URL: https://github.com/python/cpython/issues/107603
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Argument Clinic includes internal headers in generated output unconditionally","articleBody":"It seems like Argument Clinic generates code that define `Py_BUILD_CORE` and includes internal headers unconditionally; for example, a file with a `METH_O` function will have no need for those:\r\n\r\n\u003cdetails\u003e\r\n\r\n```c\r\n/*[clinic input]\r\npreserve\r\n[clinic start generated code]*/\r\n\r\n#if defined(Py_BUILD_CORE) \u0026\u0026 !defined(Py_BUILD_CORE_MODULE)\r\n# include \"pycore_gc.h\" // PyGC_Head\r\n# include \"pycore_runtime.h\" // _Py_ID()\r\n#endif\r\n\r\n\r\nPyDoc_STRVAR(func__doc__,\r\n\"func($module, a, /)\\n\"\r\n\"--\\n\"\r\n\"\\n\");\r\n\r\n#define FUNC_METHODDEF \\\r\n {\"func\", (PyCFunction)func, METH_O, func__doc__},\r\n/*[clinic end generated code: output=851b6645c29cfa0d input=a9049054013a1b77]*/\r\n```\r\n\r\n\u003c/details\u003e\r\n\r\nOTOH, a `METH_KEYWORDS` function needs those:\r\n\r\n\u003cdetails\u003e\r\n\r\n```c\r\n/*[clinic input]\r\npreserve\r\n[clinic start generated code]*/\r\n\r\n#if defined(Py_BUILD_CORE) \u0026\u0026 !defined(Py_BUILD_CORE_MODULE)\r\n# include \"pycore_gc.h\" // PyGC_Head\r\n# include \"pycore_runtime.h\" // _Py_ID()\r\n#endif\r\n\r\n\r\nPyDoc_STRVAR(func__doc__,\r\n\"func($module, /, a, b)\\n\"\r\n\"--\\n\"\r\n\"\\n\");\r\n\r\n#define FUNC_METHODDEF \\\r\n {\"func\", _PyCFunction_CAST(func), METH_FASTCALL|METH_KEYWORDS, func__doc__},\r\n\r\nstatic PyObject *\r\nfunc_impl(PyObject *module, PyObject *a, PyObject *b);\r\n\r\nstatic PyObject *\r\nfunc(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)\r\n{\r\n PyObject *return_value = NULL;\r\n #if defined(Py_BUILD_CORE) \u0026\u0026 !defined(Py_BUILD_CORE_MODULE)\r\n\r\n #define NUM_KEYWORDS 2\r\n static struct {\r\n PyGC_Head _this_is_not_used;\r\n PyObject_VAR_HEAD\r\n PyObject *ob_item[NUM_KEYWORDS];\r\n } _kwtuple = {\r\n .ob_base = PyVarObject_HEAD_INIT(\u0026PyTuple_Type, NUM_KEYWORDS)\r\n .ob_item = { \u0026_Py_ID(a), \u0026_Py_ID(b), },\r\n };\r\n #undef NUM_KEYWORDS\r\n #define KWTUPLE (\u0026_kwtuple.ob_base.ob_base)\r\n\r\n #else // !Py_BUILD_CORE\r\n # define KWTUPLE NULL\r\n #endif // !Py_BUILD_CORE\r\n\r\n static const char * const _keywords[] = {\"a\", \"b\", NULL};\r\n static _PyArg_Parser _parser = {\r\n .keywords = _keywords,\r\n .fname = \"func\",\r\n .kwtuple = KWTUPLE,\r\n };\r\n #undef KWTUPLE\r\n PyObject *argsbuf[2];\r\n PyObject *a;\r\n PyObject *b;\r\n\r\n args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, \u0026_parser, 2, 2, 0, argsbuf);\r\n if (!args) {\r\n goto exit;\r\n }\r\n a = args[0];\r\n b = args[1];\r\n return_value = func_impl(module, a, b);\r\n\r\nexit:\r\n return return_value;\r\n}\r\n/*[clinic end generated code: output=e790cd95ffc517a0 input=a9049054013a1b77]*/\r\n```\r\n\r\n\u003c/details\u003e\r\n\r\nArgument Clinic should check if those defines/includes are needed before generating the output.\n\n\u003c!-- gh-linked-prs --\u003e\n### Linked PRs\n* gh-108486\n* gh-108581\n* gh-108715\n* gh-108726\n\u003c!-- /gh-linked-prs --\u003e\n","author":{"url":"https://github.com/erlend-aasland","@type":"Person","name":"erlend-aasland"},"datePublished":"2023-08-03T20:39:44.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":6},"url":"https://github.com/107603/cpython/issues/107603"}
| 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:ce0272c4-c26d-8936-5932-ddf403556a65 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | EBFE:10503:171CCDE:1DFD375:696B25CA |
| html-safe-nonce | b12bbcf23741f60bc753b04f855023cad89ae1bdfeef3e1c2d6633a7afdf33be |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFQkZFOjEwNTAzOjE3MUNDREU6MURGRDM3NTo2OTZCMjVDQSIsInZpc2l0b3JfaWQiOiI3MTQ2OTQ5MDk2OTgyMTI4MDc0IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 9493cbabc04918a93c5c67f29112a8885ed1f6afec9287b9930759b3e1512c12 |
| hovercard-subject-tag | issue:1835705555 |
| 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/107603/issue_layout |
| twitter:image | https://opengraph.githubassets.com/c0dd938aebcabdad458da8579c8bb3a19a766db3146521aefb46b8ad900d204b/python/cpython/issues/107603 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/c0dd938aebcabdad458da8579c8bb3a19a766db3146521aefb46b8ad900d204b/python/cpython/issues/107603 |
| og:image:alt | It seems like Argument Clinic generates code that define Py_BUILD_CORE and includes internal headers unconditionally; for example, a file with a METH_O function will have no need for those: Details... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | erlend-aasland |
| hostname | github.com |
| expected-hostname | github.com |
| None | 5f99f7c1d70f01da5b93e5ca90303359738944d8ab470e396496262c66e60b8d |
| 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 | 82560a55c6b2054555076f46e683151ee28a19bc |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width