Title: incompatible behaviour between 3.12.0rc1 and previous versions in ctypes · Issue #107940 · python/cpython · GitHub
Open Graph Title: incompatible behaviour between 3.12.0rc1 and previous versions in ctypes · Issue #107940 · python/cpython
X Title: incompatible behaviour between 3.12.0rc1 and previous versions in ctypes · Issue #107940 · python/cpython
Description: Bug report Testing out 3.12.0rc1 on NumPy, we came across numpy/numpy#24399. I have distilled this down to a reproducer that fails on 3.12.0rc1, but passes on previous versions. Checklist I am confident this is a bug in CPython, not a bu...
Open Graph Description: Bug report Testing out 3.12.0rc1 on NumPy, we came across numpy/numpy#24399. I have distilled this down to a reproducer that fails on 3.12.0rc1, but passes on previous versions. Checklist I am conf...
X Description: Bug report Testing out 3.12.0rc1 on NumPy, we came across numpy/numpy#24399. I have distilled this down to a reproducer that fails on 3.12.0rc1, but passes on previous versions. Checklist I am conf...
Opengraph URL: https://github.com/python/cpython/issues/107940
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"incompatible behaviour between 3.12.0rc1 and previous versions in ctypes","articleBody":"\u003c!--\r\n New to Python? The issue tracker isn't the right place to get help.\r\n Consider instead:\r\n\r\n - reading the Python tutorial: https://docs.python.org/3/tutorial/\r\n - posting at https://discuss.python.org/c/users/7\r\n - emailing https://mail.python.org/mailman/listinfo/python-list\r\n--\u003e\r\n\r\n# Bug report\r\nTesting out 3.12.0rc1 on NumPy, we came across numpy/numpy#24399. I have distilled this down to a reproducer that fails on 3.12.0rc1, but passes on previous versions.\r\n## Checklist\r\n\r\n\u003c!-- Bugs in third-party projects (e.g. `requests`) do not belong in the CPython issue tracker --\u003e\r\n\r\n- [x] I am confident this is a bug in CPython, not a bug in a third-party project\r\n- [x] I have searched the CPython issue tracker, and am confident this bug has not been reported before\r\n\r\n## A clear and concise description of the bug\r\n\r\n```py\r\nfrom ctypes import Structure, pointer, c_int16, cast, POINTER\r\n\r\nclass Struct(Structure):\r\n _fields_ = [('a', c_int16)]\r\n\r\nStruct3 = 3 * Struct\r\n\r\nc_array = (2 * Struct3)(\r\n Struct3(Struct(a=1), Struct(a=2), Struct(a=3)),\r\n Struct3(Struct(a=4), Struct(a=5), Struct(a=6))\r\n)\r\n\r\nassert c_array[0][0].a == 1\r\n\r\np_obj = cast(pointer(c_array), POINTER(pointer(c_array)._type_))\r\nobj = p_obj.contents\r\n# Works on 3.12, obj is 2d\r\nassert obj[0][0].a == 1\r\n\r\np_obj = cast(pointer(c_array[0]), POINTER(pointer(c_array)._type_))\r\nobj = p_obj.contents\r\n# Fails on 3.12.0rc1, but works on 3.11 and earlier: obj is not 2d\r\nassert obj[0][0].a == 1\r\n\r\n```\r\n\r\n\r\n\r\n# Your environment\r\n\r\n\u003c!-- Include all relevant details about the environment you experienced the bug in --\u003e\r\n\r\n- CPython versions tested on: 3.12rc1\r\n- Operating system and architecture: ubuntu 22.04\r\n\r\n\u003c!--\r\nYou can freely edit this form. Remove any lines you believe are unnecessary.\r\n--\u003e\r\n\r\nEdit: 3.12rc1 -\u003e 3.12.0rc1\n\n\u003c!-- gh-linked-prs --\u003e\n### Linked PRs\n* gh-108222\n\u003c!-- /gh-linked-prs --\u003e\n","author":{"url":"https://github.com/mattip","@type":"Person","name":"mattip"},"datePublished":"2023-08-14T12:37:01.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":9},"url":"https://github.com/107940/cpython/issues/107940"}
| 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:ad50fb19-994e-ba79-5aee-e778ed44904d |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | B69A:31006B:1387AA1:1A1CAA1:696ADC67 |
| html-safe-nonce | d90c787b0f4db8fa0c14a5812626f6596d59033f8fb6d75c8fa260ef5c00729f |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCNjlBOjMxMDA2QjoxMzg3QUExOjFBMUNBQTE6Njk2QURDNjciLCJ2aXNpdG9yX2lkIjoiODc4MjQxNjExNzIzNDMyNjYzMSIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | e1ecc033b2224e8110d25ddefbe6e9fcd85f7cf518b6a7b01f878832498cfa35 |
| hovercard-subject-tag | issue:1849693683 |
| 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/107940/issue_layout |
| twitter:image | https://opengraph.githubassets.com/572297ec9aa838e2d3b5bdd7f5b24155ce967a11b524336ec158349499fac4c9/python/cpython/issues/107940 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/572297ec9aa838e2d3b5bdd7f5b24155ce967a11b524336ec158349499fac4c9/python/cpython/issues/107940 |
| og:image:alt | Bug report Testing out 3.12.0rc1 on NumPy, we came across numpy/numpy#24399. I have distilled this down to a reproducer that fails on 3.12.0rc1, but passes on previous versions. Checklist I am conf... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | mattip |
| 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 | 524a93f2c1f36522a3b4be4c110467ee4172245d |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width