Title: regression in 3.13.4 `Random.getrandbits` when an `int` like object is passed · Issue #135326 · python/cpython · GitHub
Open Graph Title: regression in 3.13.4 `Random.getrandbits` when an `int` like object is passed · Issue #135326 · python/cpython
X Title: regression in 3.13.4 `Random.getrandbits` when an `int` like object is passed · Issue #135326 · python/cpython
Description: Bug report Bug description: via #133489 (comment) @tornaria reports: There is an (unintended?) api break. In python 3.13.3, getrandbits() accepts an "integer-like" object as in: Python 3.13.3 (main, Apr 11 2025, 13:41:26) [GCC 13.2.0] on...
Open Graph Description: Bug report Bug description: via #133489 (comment) @tornaria reports: There is an (unintended?) api break. In python 3.13.3, getrandbits() accepts an "integer-like" object as in: Python 3.13.3 (main...
X Description: Bug report Bug description: via #133489 (comment) @tornaria reports: There is an (unintended?) api break. In python 3.13.3, getrandbits() accepts an "integer-like" object as in: Python 3....
Opengraph URL: https://github.com/python/cpython/issues/135326
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"regression in 3.13.4 `Random.getrandbits` when an `int` like object is passed","articleBody":"# Bug report\n\n### Bug description:\n\nvia https://github.com/python/cpython/issues/133489#issuecomment-2954448300 @tornaria reports:\n\nThere is an (unintended?) api break. In python 3.13.3, `getrandbits()` accepts an \"integer-like\" object as in:\n```\nPython 3.13.3 (main, Apr 11 2025, 13:41:26) [GCC 13.2.0] on linux\nType \"help\", \"copyright\", \"credits\" or \"license\" for more information.\n>>> import random ; r = random.Random()\n>>> from numpy import int64\n>>> r.getrandbits(int64(20))\n582096\n```\nbut in python 3.13.4, `getrandbits()` fails as in:\n```\nPython 3.13.4 (main, Jun 8 2025, 19:43:01) [GCC 14.2.1 20250405] on linux\nType \"help\", \"copyright\", \"credits\" or \"license\" for more information.\n>>> import random ; r = random.Random()\n>>> from numpy import int64\n>>> r.getrandbits(int64(20))\nTraceback (most recent call last):\n File \"\u003cpython-input-2>\", line 1, in \u003cmodule>\n r.getrandbits(int64(20))\n ~~~~~~~~~~~~~^^^^^^^^^^^\nTypeError: an integer is required\n```\nThis causes trouble for sagemath, where integers are by default a special type `ZZ`. \n\n### CPython versions tested on:\n\n3.13\n\n### Operating systems tested on:\n\n_No response_\n\n\u003c!-- gh-linked-prs -->\n### Linked PRs\n* gh-135327\n* gh-135332\n* gh-135356\n* gh-135373\n\u003c!-- /gh-linked-prs -->\n","author":{"url":"https://github.com/gpshead","@type":"Person","name":"gpshead"},"datePublished":"2025-06-10T04:38:18Z","url":"https://github.com/python/cpython/issues/135326"}
| 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:9def28a0-c9a7-4629-a89c-9ccd3dbadaac |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 94CE:14EB6E:12C43FB:18B6965:6B01E84A |
| html-safe-nonce | 09dca84d1179c65d7a5d617c9e0bc42de9556826f26b15e0da47a66d34f6f8c5 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5NENFOjE0RUI2RToxMkM0M0ZCOjE4QjY5NjU6NkIwMUU4NEEiLCJ2aXNpdG9yX2lkIjoiMzgyMzA1NDI2MTQ1Mzk3MzU3OCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 34be852adfc0d1f18bdbea290363770a68b73036d9e4eb0f33b90ea7747a9c95 |
| hovercard-subject-tag | issue:3132115463 |
| 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/135326/issue_layout |
| twitter:image | https://opengraph.githubassets.com/6fbf708b80cc33bba046fcbdbba07369bebf0911752bb834ac12a971b00f8bbe/python/cpython/issues/135326 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/6fbf708b80cc33bba046fcbdbba07369bebf0911752bb834ac12a971b00f8bbe/python/cpython/issues/135326 |
| og:image:alt | Bug report Bug description: via #133489 (comment) @tornaria reports: There is an (unintended?) api break. In python 3.13.3, getrandbits() accepts an "integer-like" object as in: Python 3.13.3 (main... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | gpshead |
| hostname | github.com |
| expected-hostname | github.com |
| None | cc5dfdd32f62ebd3223cab3af3aa2b268d3605218237326a48a99d1efd89495c |
| 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 | 8c77c9e8439031ad54c75a250694842892f693e1 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width