Title: array.array() setter incorrectly handle overflows for 'e' type code · Issue #156864 · python/cpython · GitHub
Open Graph Title: array.array() setter incorrectly handle overflows for 'e' type code · Issue #156864 · python/cpython
X Title: array.array() setter incorrectly handle overflows for 'e' type code · Issue #156864 · python/cpython
Description: Bug report Bug description: Consider this: >>> import array >>> a = array.array('e', [123]) >>> a[0] = 123456 # doesn't fit in _Float16 but fits in _Float32 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 # doesn't fit in _Float16 but fits in _Float32 Traceback (most recent call last): File ...
X Description: Bug report Bug description: Consider this: >>> import array >>> a = array.array('e', [123]) >>> a[0] = 123456 # doesn't fit in _Float16 but fits in _Float32 T...
Opengraph URL: https://github.com/python/cpython/issues/156864
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"array.array() setter incorrectly handle overflows for 'e' type code","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 # doesn't fit in _Float16 but fits in _Float32\nTraceback (most recent call last):\n File \"\u003cpython-input-5>\", line 1, in \u003cmodule>\n a[0] = 123456\n ~^^^\nOverflowError: float too large to pack with e format\n>>> a\narray('e', [123.0]) \n>>> a[0] = 1e300 # doesn't fit neither in _Float32 nor in _Float16\n>>> a\narray('e', [inf])\n```\n\nThat's happened because we use `PyArg_Parse()` function with `'f'` format code to parse floats. Then in the second case `PyFloat_Pack2()` seen plain infinity and doesn't trigger overflow.\n\nI believe both examples should trigger overflows.\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\u003c!-- /gh-linked-prs -->\n","author":{"url":"https://github.com/skirpichev","@type":"Person","name":"skirpichev"},"datePublished":"2026-09-02T23:36:24Z","url":"https://github.com/python/cpython/issues/156864"}
| 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:a25bdb3f-d6ab-85ca-34df-86674297b202 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 9614:1F2B:3DAEAA:52646A:6B021B84 |
| html-safe-nonce | 458066277ca796856b431dc36f39a07b6b57e69f79753b1133d61d368b96d1dd |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5NjE0OjFGMkI6M0RBRUFBOjUyNjQ2QTo2QjAyMUI4NCIsInZpc2l0b3JfaWQiOiIzMTE1ODc4MTEyMjMyMDg2NDA0IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 276f6588f9ad32acedb5b54fbf6c1887d9beda09a632a0551350e3d997cc9343 |
| hovercard-subject-tag | issue:5330390589 |
| 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/156864/issue_layout |
| twitter:image | https://opengraph.githubassets.com/185a28cf8553c310162a5e59dc58591fab822b402f6112397988cc61708dc3af/python/cpython/issues/156864 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/185a28cf8553c310162a5e59dc58591fab822b402f6112397988cc61708dc3af/python/cpython/issues/156864 |
| og:image:alt | Bug report Bug description: Consider this: >>> import array >>> a = array.array('e', [123]) >>> a[0] = 123456 # doesn't fit in _Float16 but fits in _Float32 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