Title: Overflows happened silently in array.array setters for 'e', 'f' and 'Zf' format types · Issue #156865 · python/cpython · GitHub
Open Graph Title: Overflows happened silently in array.array setters for 'e', 'f' and 'Zf' format types · Issue #156865 · python/cpython
X Title: Overflows happened silently in array.array setters for 'e', 'f' and 'Zf' format types · Issue #156865 · python/cpython
Description: Bug report Bug description: Consider this: >>> import array >>> a = array.array('e', [123]) >>> a[0] = 123456 Traceback (most recent call last): File "
Open Graph Description: Bug report Bug description: Consider this: >>> import array >>> a = array.array('e', [123]) >>> a[0] = 123456 Traceback (most recent call last): File "
X Description: Bug report Bug description: Consider this: >>> import array >>> a = array.array('e', [123]) >>> a[0] = 123456 Traceback (most recent call last): File "<py...
Opengraph URL: https://github.com/python/cpython/issues/156865
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Overflows happened silently in array.array setters for 'e', 'f' and 'Zf' format types","articleBody":"# Bug report\n\n### Bug description:\n\nConsider this:\n```pycon\n>>> import array\n>>> a = array.array('e', [123])\n>>> a[0] = 123456\nTraceback (most recent call last):\n File \"\u003cpython-input-2>\", line 1, in \u003cmodule>\n a[0] = 123456\n ~^^^\nOverflowError: float too large to pack with e format\n>>> a = array.array('f', [123])\n>>> a[0] = 1e70 # no OverflowError\n>>> a\narray('f', [inf])\n>>> a = array.array('Zf', [123])\n>>> a[0] = 1e70j # no OverflowError\n>>> a\narray('Zf', [infj])\n>>> import struct\n>>> struct.pack('f', 1e70)\nTraceback (most recent call last):\n File \"\u003cpython-input-7>\", line 1, in \u003cmodule>\n struct.pack('f', 1e70)\n ~~~~~~~~~~~^^^^^^^^^^^\nOverflowError: float too large to pack with f format\n>>> struct.pack('>Zf', 1e70j)\nTraceback (most recent call last):\n File \"\u003cpython-input-13>\", line 1, in \u003cmodule>\n struct.pack('>Zf', 1e70j)\n ~~~~~~~~~~~^^^^^^^^^^^^^^\nOverflowError: float too large to pack with f format\n```\n(BTW, `f_setitem()` suffers from same issue as https://github.com/python/cpython/issues/156864.)\n\nMaybe it's a feature and array() should behave differently wrt the struct module. In either case, this behavior looks inconsistent. If we consider cases for 'f'/'Zf' types being correct - we should clear exceptions also for 'e' type code.\n\nSee also struct/array issues (merged to this per @vstinner suggestion):\n* https://github.com/python/cpython/issues/156864\n* https://github.com/python/cpython/issues/156867\n\n### CPython versions tested on:\n\nCPython main branch\n\n### Operating systems tested on:\n\n_No response_\n\n\u003c!-- gh-linked-prs -->\n### Linked PRs\n* gh-156869\n* gh-156868\n* gh-156916\n* gh-156919\n\u003c!-- /gh-linked-prs -->\n","author":{"url":"https://github.com/skirpichev","@type":"Person","name":"skirpichev"},"datePublished":"2026-09-02T23:49:11Z","url":"https://github.com/python/cpython/issues/156865"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| 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:915326d6-5090-2eb6-7903-9c99fb80360d |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | ABA6:2DBB21:36DEB10:492E895:6B0211E3 |
| html-safe-nonce | 356ca54a0ae7d686dc91ab50d222629eb95b0e8050cebc145eb5f09f09a29950 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBQkE2OjJEQkIyMTozNkRFQjEwOjQ5MkU4OTU6NkIwMjExRTMiLCJ2aXNpdG9yX2lkIjoiODMwNDc0NjY5OTQ2MTYyODM4NyIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 2f8cfdc51b12c2be0d2076279593c651f51e6bd8a7df0e9d3bef734d09ae9c37 |
| hovercard-subject-tag | issue:5330471171 |
| 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/156865/issue_layout |
| twitter:image | https://opengraph.githubassets.com/c1d708aff45459a964ebb4ddfaa749b43fcb43e931bdbb6dc33f839a19337e71/python/cpython/issues/156865 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/c1d708aff45459a964ebb4ddfaa749b43fcb43e931bdbb6dc33f839a19337e71/python/cpython/issues/156865 |
| og:image:alt | Bug report Bug description: Consider this: >>> import array >>> a = array.array('e', [123]) >>> a[0] = 123456 Traceback (most recent call last): File " |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | skirpichev |
| hostname | github.com |
| expected-hostname | github.com |
| None | 87e774ee7c6b3bee0490394e4d3e57ec9dbc956f74b87ea685dc8996c1676456 |
| 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 | 423dbb54c5e7bfecc838eb387c1435eb3d0e760d |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width