Title: Remove zero or negative reference counter check in `PyObject_Print` · Issue #98928 · python/cpython · GitHub
Open Graph Title: Remove zero or negative reference counter check in `PyObject_Print` · Issue #98928 · python/cpython
X Title: Remove zero or negative reference counter check in `PyObject_Print` · Issue #98928 · python/cpython
Description: Feature or enhancement Remove the section of the PyObject_Print function that handles input objects that have a negative reference counter: cpython/Objects/object.c Lines 274 to 278 in 88297e2 if (Py_REFCNT(op) <= 0) { Py_BEGIN_ALLOW_THR...
Open Graph Description: Feature or enhancement Remove the section of the PyObject_Print function that handles input objects that have a negative reference counter: cpython/Objects/object.c Lines 274 to 278 in 88297e2 if (...
X Description: Feature or enhancement Remove the section of the PyObject_Print function that handles input objects that have a negative reference counter: cpython/Objects/object.c Lines 274 to 278 in 88297e2 if (...
Opengraph URL: https://github.com/python/cpython/issues/98928
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Remove zero or negative reference counter check in `PyObject_Print`","articleBody":"# Feature or enhancement\r\n\r\nRemove the section of the PyObject_Print function that handles input objects that have a negative reference counter:\r\nhttps://github.com/python/cpython/blob/88297e2a8a75898228360ee369628a4a6111e2ee/Objects/object.c#L274-L278\r\n\r\n# Previous discussion\r\nThe PR https://github.com/python/cpython/pull/98749 that improves the coverage of `PyObject_Print` is blocked due to a failing pipeline. After investigation, the test that is failing is associated with the Address Sanitizer. In particular, it fails the test that covers the aforementioned section. It consists in passing an object (specifically a Python string) with its reference counter set to zero and comparing the output string to the expected result: https://github.com/MonadChains/cpython/blob/562b9d26db7e766741c954146d4423eda414d2f6/Modules/_testcapimodule.c#L2053-L2080\r\nHowever, when the reference counter of the object goes to zero, it is deallocated, and the Address Sanitizer does not like it.\r\nAfter the discussion in https://mail.python.org/archives/list/core-mentorship@python.org/thread/7BP55KL6VB3H2ZZ5JZP2NV6RX72HBUCC/, a possible solution to this is to clean up the function and remove this section entirely. Normally this kind of check is performed only in specific situations like for example `_Py_ForgetReference` or `Py_DECREF` so it seems a bit weird to have it in `PyObject_Print`. \r\nAlternatively, another solution could be to remove the failing test from the PR and don't cover this section of the function.\r\n\n\n\u003c!-- gh-pr-number: gh-98929 --\u003e\n* PR: gh-98929\n\u003c!-- /gh-pr-number --\u003e\n","author":{"url":"https://github.com/MonadChains","@type":"Person","name":"MonadChains"},"datePublished":"2022-10-31T21:56:35.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":5},"url":"https://github.com/98928/cpython/issues/98928"}
| 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:f0f43ca3-f7f8-c203-cd38-a2f18c49e90f |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | AA7E:105924:565A2C:75E4E5:69694C86 |
| html-safe-nonce | 0f595a9115bf71ae0cd6bc840d88d838ae0499978aa4f69016277d69832a473b |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBQTdFOjEwNTkyNDo1NjVBMkM6NzVFNEU1OjY5Njk0Qzg2IiwidmlzaXRvcl9pZCI6IjQzMTIzMTc3ODQ1MjgzNDIxNTAiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 7d14d541d8095d8abe7e0eb1109b8fa6b598c67da76c0bdfc83dcdbc418bd339 |
| hovercard-subject-tag | issue:1430548170 |
| 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/98928/issue_layout |
| twitter:image | https://opengraph.githubassets.com/afbb72348bffd4a3086d10a4baef50d3241f56773da86158bc92387b495f2c83/python/cpython/issues/98928 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/afbb72348bffd4a3086d10a4baef50d3241f56773da86158bc92387b495f2c83/python/cpython/issues/98928 |
| og:image:alt | Feature or enhancement Remove the section of the PyObject_Print function that handles input objects that have a negative reference counter: cpython/Objects/object.c Lines 274 to 278 in 88297e2 if (... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | MonadChains |
| hostname | github.com |
| expected-hostname | github.com |
| None | 54182691a21263b584d2e600b758e081b0ff1d10ffc0d2eefa51cf754b43b51d |
| 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 | d69ac0477df0f87da03b8b06cebd187012d7a930 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width