Title: GitHub · Where software is built
Open Graph Title: python/cpython
X Title: python/cpython
Description: The Python programming language. Contribute to python/cpython development by creating an account on GitHub.
Open Graph Description: The Python programming language. Contribute to python/cpython development by creating an account on GitHub.
X Description: The Python programming language. Contribute to python/cpython development by creating an account on GitHub.
Opengraph URL: https://github.com/python/cpython
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Argument Clinic does not increase NoneType refcount when returning NoneType from a function with no parameters","articleBody":"**Bug report**\r\n\r\n```python\r\n/*[clinic input]\r\nfunction -\u003e NoneType\r\n[clinic start generated code]*/\r\n```\r\n\r\nwill produce this function:\r\n```c\r\nstatic PyObject *\r\nfunction(PyObject *module, PyObject *Py_UNUSED(ignored))\r\n{\r\n return function_impl(module);\r\n}\r\n```\r\n\r\nwhile `function_impl` returns `Py_None` (as it should, if using NoneType return converter), refcount is not increased.\r\n\r\nhere is a working example of NoneType return converter:\r\n```python\r\n/*[clinic input]\r\nfunction -\u003e NoneType\r\n\r\n a: int\r\n /\r\n[clinic start generated code]*/\r\n```\r\n```c\r\nstatic PyObject *\r\nfunction(PyObject *module, PyObject *arg)\r\n{\r\n PyObject *return_value = NULL;\r\n int a;\r\n PyObject *_return_value;\r\n\r\n a = _PyLong_AsInt(arg);\r\n if (a == -1 \u0026\u0026 PyErr_Occurred()) {\r\n goto exit;\r\n }\r\n _return_value = function_impl(module, a);\r\n if (_return_value != Py_None) {\r\n goto exit;\r\n }\r\n return_value = Py_None;\r\n Py_INCREF(Py_None);\r\n\r\nexit:\r\n return return_value;\r\n}\r\n```\r\n\r\nGeneration also fails when generating a function with a single `object` parameter.\r\n\r\nIt seems like the problem is with `default_return_converter` in clinic.py, being set to `True`\r\n","author":{"url":"https://github.com/noamcohen97","@type":"Person","name":"noamcohen97"},"datePublished":"2022-07-19T14:08:54.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":4},"url":"https://github.com/95007/cpython/issues/95007"}
| route-pattern | /:user_id/:repository/issues/:id(.:format) |
| route-controller | issues |
| route-action | show |
| fetch-nonce | v2:5ff62108-dfa2-4cde-d460-36e92231fb43 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | A322:367397:37BA2D:4EFE26:696A0962 |
| html-safe-nonce | 033d655fee0a2a8979ce99bbb27417929cafffe8c84d37d861079043169c6636 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBMzIyOjM2NzM5NzozN0JBMkQ6NEVGRTI2OjY5NkEwOTYyIiwidmlzaXRvcl9pZCI6IjczNjAxNDg1NzYzMTYwMzMzNzgiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | d6441ac4baa942f4ad02e0303af6b792627fbda7cc2f097a339bfffae933ef32 |
| hovercard-subject-tag | repository:81598961 |
| 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/python/cpython/issues/95007 |
| twitter:image | https://opengraph.githubassets.com/7ff32d4ea94f458de4c0df766210532ff22f3b84939f9fe9712235525380677f/python/cpython |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/7ff32d4ea94f458de4c0df766210532ff22f3b84939f9fe9712235525380677f/python/cpython |
| og:image:alt | The Python programming language. Contribute to python/cpython development by creating an account on GitHub. |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| hostname | github.com |
| expected-hostname | github.com |
| None | 699227a00bbb7fe1eec276d2ae1c3a93068bc5ba483bd9dc4b2a27a8f4f2f595 |
| turbo-cache-control | no-cache |
| 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 | 7266b2d935baa1c6474b16dd9feaa5ca30607261 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width