René's URL Explorer Experiment


Title: Possible unnecessary OverflowError in random.getrandbits · Issue #133489 · python/cpython · GitHub

Open Graph Title: Possible unnecessary OverflowError in random.getrandbits · Issue #133489 · python/cpython

X Title: Possible unnecessary OverflowError in random.getrandbits · Issue #133489 · python/cpython

Description: Documentation Problem Actual upper bound of a random.Random.randbytes is 2**28 - 1 Following docs and exception message I would expect the limit of 2 ** 32 - 1 as for C 4-bytes integer ## -------------------- bytes methods --------------...

Open Graph Description: Documentation Problem Actual upper bound of a random.Random.randbytes is 2**28 - 1 Following docs and exception message I would expect the limit of 2 ** 32 - 1 as for C 4-bytes integer ## ---------...

X Description: Documentation Problem Actual upper bound of a random.Random.randbytes is 2**28 - 1 Following docs and exception message I would expect the limit of 2 ** 32 - 1 as for C 4-bytes integer ## ---------...

Opengraph URL: https://github.com/python/cpython/issues/133489

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Possible unnecessary OverflowError in random.getrandbits","articleBody":"# Documentation\n\n## Problem\nActual upper bound of a `random.Random.randbytes` is `2**28 - 1`\n\nFollowing docs and exception message I would expect the limit of 2 ** 32 - 1 as for C 4-bytes integer \n\n```\n    ## -------------------- bytes methods ---------------------\n\n    def randbytes(self, n):\n        \"\"\"Generate n random bytes.\"\"\"\n        return self.getrandbits(n * 8).to_bytes(n, 'little')\n```\n\n\n```\n>>> bytes_string = random.randbytes(2 ** 28)\nTraceback (most recent call last):\n  File \"C:\\Program Files\\Python39\\lib\\code.py\", line 90, in runcode\n    exec(code, self.locals)\n  File \"\u003cinput>\", line 1, in \u003cmodule>\n  File \"C:\\Program Files\\Python39\\lib\\random.py\", line 286, in randbytes\n    return self.getrandbits(n * 8).to_bytes(n, 'little')\nOverflowError: Python int too large to convert to C int\n>>> bytes_string = random.randbytes(2 ** 28 - 1)\n>>> len(bytes_string)\n268435455\n\n```\n\nReproduced on \nPython 3.9.4 (tags/v3.9.4:1f2e308, Apr  6 2021, 13:40:21) [MSC v.1928 64 bit (AMD64)] on win32\nPython 3.11.2 (main, Jul 19 2024, 12:24:02) [GCC 12.2.0] on linux\n\n\nWill you please point me - if there is a bug in docs/implementation, or this is my misunderstanding only.\nThank you in advance for you patience.\n\n\u003c!-- gh-linked-prs -->\n### Linked PRs\n* gh-133529\n* gh-133658\n* gh-134964\n* gh-134965\n\u003c!-- /gh-linked-prs -->\n","author":{"url":"https://github.com/Nokhrin","@type":"Person","name":"Nokhrin"},"datePublished":"2025-05-06T03:29:27Z","url":"https://github.com/python/cpython/issues/133489"}

react-profiling0
react-import-mapreact,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-controllervoltron_issues_fragments
route-actionissue_layout
fetch-noncev2:a8e9721a-e1d0-5340-ff7b-40a4b89d9bc2
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-idCA82:313081:1205667:17CE8F9:6B01E446
html-safe-nonce45f35a692221af240f9e3e289405b5b873b2cef8381024f5e0c7fda2c3fde68a
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDQTgyOjMxMzA4MToxMjA1NjY3OjE3Q0U4Rjk6NkIwMUU0NDYiLCJ2aXNpdG9yX2lkIjoiODU4NDc3MDQ1ODI2MjU2MTg2MiIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9
visitor-hmac03b17d634a472d216d5fd54ce877d875d76015dd429c23dc2f078492a6235d64
hovercard-subject-tagissue:3041409673
github-keyboard-shortcutsrepository,issues,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///voltron/issues_fragments/issue_layout
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/python/cpython/133489/issue_layout
twitter:imagehttps://opengraph.githubassets.com/47bd773fa4382867e44839b73245e451435dba9c2f08589fb0c9121380ea583d/python/cpython/issues/133489
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/47bd773fa4382867e44839b73245e451435dba9c2f08589fb0c9121380ea583d/python/cpython/issues/133489
og:image:altDocumentation Problem Actual upper bound of a random.Random.randbytes is 2**28 - 1 Following docs and exception message I would expect the limit of 2 ** 32 - 1 as for C 4-bytes integer ## ---------...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernameNokhrin
hostnamegithub.com
expected-hostnamegithub.com
Nonecc5dfdd32f62ebd3223cab3af3aa2b268d3605218237326a48a99d1efd89495c
turbo-cache-controlno-preview
go-importgithub.com/python/cpython git https://github.com/python/cpython.git
octolytics-dimension-user_id1525981
octolytics-dimension-user_loginpython
octolytics-dimension-repository_id81598961
octolytics-dimension-repository_nwopython/cpython
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id81598961
octolytics-dimension-repository_network_root_nwopython/cpython
turbo-body-classeslogged-out env-production page-responsive
disable-turbofalse
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
release8c77c9e8439031ad54c75a250694842892f693e1
ui-targetfull
theme-color#1e2327
color-schemelight dark
react-app-nameissues

Links:

Skip to contenthttps://github.com/python/cpython/issues/133489#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fpython%2Fcpython%2Fissues%2F133489
GitHubRepository hosting, code review, and collaborationhttps://github.com/platform
CopilotAI coding agent for tasks, projects, and automated workhttps://github.com/features/copilot
ActionsCI/CD and automationhttps://github.com/features/actions
Code QualityQuality analysis, fixes, and enforcementhttps://github.com/features/code-quality
CodespacesCloud development environmentshttps://github.com/features/codespaces
Code SecurityVulnerability detection and remediationhttps://github.com/security/advanced-security/code-security
Secret ProtectionSecret scanning and leak preventionhttps://github.com/security/advanced-security/secret-protection
All Featureshttps://github.com/features
Documentationhttps://docs.github.com/en
Traininghttps://learn.github.com/skills
Certificationshttps://learn.github.com/credentials
Build with Copilothttps://github.com/features/ai
Customize Copilothttps://docs.github.com/en/copilot/how-tos/copilot-on-github/customize-copilot/customize-copilot-overview
Integrationshttps://github.com/marketplace
Trending reposhttps://github.com/trending
GitHub Sponsorshttps://github.com/open-source/sponsors
Developer articleshttps://github.com/resources/articles
ChangelogYour source for the latest features, improvements, and fixes across GitHub products, all in one place.https://github.blog/changelog/
Enterpriseshttps://github.com/enterprise
Teamhttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
See all industrieshttps://github.com/solutions/industry
Why GitHubhttps://github.com/why-github
Customer Storieshttps://github.com/customer-stories
Business insightshttps://github.com/solutions/executive-insights
Trust Centerhttps://github.com/trust-center
GitHub Advanced SecurityEnterprise-grade code securityhttps://github.com/security/advanced-security
Copilot for businessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/enterprise/premium-support
Documentationhttps://docs.github.com/en
Resource centerhttps://github.com/resources
Bloghttps://github.blog/
Events & webinarshttps://github.com/resources/events
Community Forumhttps://github.com/orgs/community/discussions
Customer Storieshttps://github.com/customer-stories
Integrationshttps://github.com/marketplace
Customer supporthttps://help.github.com/
Traininghttps://learn.github.com/skills
GitHub Statushttps://www.githubstatus.com/
Abouthttps://github.com/about
Partnershttps://github.com/partners
Changeloghttps://github.blog/changelog/
GitHub UniverseThe event for developers, by developers — talks, workshops, and what’s next for GitHub.https://githubuniverse.com/
Pricinghttps://github.com/pricing
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fpython%2Fcpython%2Fissues%2F133489
Sign uphttps://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fvoltron%2Fissues_fragments%2Fissue_layout&source=header-repo&source_repo=python%2Fcpython
Reloadhttps://github.com/python/cpython/issues/133489
Reloadhttps://github.com/python/cpython/issues/133489
Reloadhttps://github.com/python/cpython/issues/133489
pythonhttps://github.com/python
cpythonhttps://github.com/python/cpython
Codehttps://github.com/python/cpython
Issues5k+ (5k+)https://github.com/python/cpython/issues
Pull requests2.4k (2.4k)https://github.com/python/cpython/pulls
Actionshttps://github.com/python/cpython/actions
Projectshttps://github.com/python/cpython/projects
Security and qualityhttps://github.com/python/cpython/security
Insightshttps://github.com/python/cpython/insights
https://github.com/python/cpython
New issuehttps://github.com/login?return_to=https://github.com/python/cpython/issues/133489
New issuehttps://github.com/login?return_to=https://github.com/python/cpython/issues/133489
Possible unnecessary OverflowError in random.getrandbitshttps://github.com/python/cpython/issues/133489#top
https://github.com/serhiy-storchaka
extension-modulesC modules in the Modules dirhttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22extension-modules%22
type-bugAn unexpected behavior, bug, or errorhttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22type-bug%22
https://github.com/Nokhrin
Nokhrinhttps://github.com/Nokhrin
on May 6, 2025https://github.com/python/cpython/issues/133489#issue-3041409673
gh-133489: Document random.randbytes bounds. #133529https://github.com/python/cpython/pull/133529
gh-133489: Remove size restrictions on getrandbits() and randbytes() #133658https://github.com/python/cpython/pull/133658
[3.14] gh-133489: Remove size restrictions on getrandbits() and randbytes() (GH-133658) #134964https://github.com/python/cpython/pull/134964
[3.13] gh-133489: Remove size restrictions on getrandbits() and randbytes() (GH-133658) #134965https://github.com/python/cpython/pull/134965
Nexthttps://github.com/python/cpython/issues/133489?timeline_page=1
Nokhrinhttps://github.com/Nokhrin
docsDocumentation in the Doc dirhttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22docs%22
on May 6, 2025https://github.com/python/cpython/issues/133489#event-17529766043
github-project-automationhttps://github.com/apps/github-project-automation
docs issueshttps://github.com/orgs/python/projects/52
on May 6, 2025https://github.com/python/cpython/issues/133489#event-17529766347
github-project-automationhttps://github.com/apps/github-project-automation
docs issueshttps://github.com/orgs/python/projects/52
on May 6, 2025https://github.com/python/cpython/issues/133489
https://github.com/rhettinger
rhettingerhttps://github.com/rhettinger
on May 6, 2025https://github.com/python/cpython/issues/133489#issuecomment-2856002137
@serhiy-storchakahttps://github.com/serhiy-storchaka
rhettingerhttps://github.com/rhettinger
on May 6, 2025https://github.com/python/cpython/issues/133489#event-17544542301
rhettingerhttps://github.com/rhettinger
type-featureA feature request or enhancementhttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22type-feature%22
docsDocumentation in the Doc dirhttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22docs%22
on May 6, 2025https://github.com/python/cpython/issues/133489#event-17544546103
rhettingerhttps://github.com/rhettinger
on May 6, 2025https://github.com/python/cpython/issues/133489#event-17544548226
rhettingerhttps://github.com/rhettinger
serhiy-storchakahttps://github.com/serhiy-storchaka
on May 6, 2025https://github.com/python/cpython/issues/133489#event-17544551729
rhettingerhttps://github.com/rhettinger
type-bugAn unexpected behavior, bug, or errorhttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22type-bug%22
type-featureA feature request or enhancementhttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22type-feature%22
on May 6, 2025https://github.com/python/cpython/issues/133489#event-17544555429
https://github.com/skirpichev
skirpichevhttps://github.com/skirpichev
on May 7, 2025https://github.com/python/cpython/issues/133489#issuecomment-2856928797
picnixzhttps://github.com/picnixz
extension-modulesC modules in the Modules dirhttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22extension-modules%22
on May 7, 2025https://github.com/python/cpython/issues/133489#event-17555688669
https://github.com/rhettinger
rhettingerhttps://github.com/rhettinger
on May 7, 2025https://github.com/python/cpython/issues/133489#issuecomment-2858547020
@skirpichevhttps://github.com/skirpichev
https://github.com/serhiy-storchaka
serhiy-storchakahttps://github.com/serhiy-storchaka
on May 7, 2025https://github.com/python/cpython/issues/133489#issuecomment-2858827452
planshttps://github.com/python/cpython/pull/133093#discussion_r2066537260
serhiy-storchakahttps://github.com/serhiy-storchaka
on May 8, 2025https://github.com/python/cpython/issues/133489#event-17571785627
pythongh-133489: Remove size restrictions on getrandbits() and randby…https://github.com/serhiy-storchaka/cpython/commit/5958a24ed703e8ed731aeba1aeb7061f4fc1271c
pythongh-133489https://github.com/python/cpython/issues/133489
5958a24https://github.com/serhiy-storchaka/cpython/commit/5958a24ed703e8ed731aeba1aeb7061f4fc1271c
https://github.com/serhiy-storchaka
serhiy-storchakahttps://github.com/serhiy-storchaka
on May 8, 2025https://github.com/python/cpython/issues/133489#issuecomment-2862618316
#133658https://github.com/python/cpython/pull/133658
@Raymondhttps://github.com/Raymond
https://github.com/gpshead
gpsheadhttps://github.com/gpshead
on May 31, 2025https://github.com/python/cpython/issues/133489#issuecomment-2924225142
serhiy-storchakahttps://github.com/serhiy-storchaka
on May 31, 2025https://github.com/python/cpython/issues/133489#event-17898450710
gh-133489: Remove size restrictions on getrandbits() and randbytes() (G…https://github.com/python/cpython/commit/68784fed78aa297f0de0d038742495709185bef5
gh-133489https://github.com/python/cpython/issues/133489
G…https://github.com/python/cpython/pull/133658
68784fehttps://github.com/python/cpython/commit/68784fed78aa297f0de0d038742495709185bef5
miss-islingtonhttps://github.com/miss-islington
on May 31, 2025https://github.com/python/cpython/issues/133489#event-17898451008
pythongh-133489: Remove size restrictions on getrandbits() and randby…https://github.com/miss-islington/cpython/commit/03f34edfb81dce7bb8a307cb83f65ba73a1b73c6
pythongh-133489https://github.com/python/cpython/issues/133489
03f34edhttps://github.com/miss-islington/cpython/commit/03f34edfb81dce7bb8a307cb83f65ba73a1b73c6
serhiy-storchakahttps://github.com/serhiy-storchaka
on May 31, 2025https://github.com/python/cpython/issues/133489#event-17898615482
[3.13] pythongh-133489: Remove size restrictions on getrandbits() and…https://github.com/serhiy-storchaka/cpython/commit/ce88d2168cf2f3663e0810caf1061de40d3ee41a
pythongh-133489https://github.com/python/cpython/issues/133489
ce88d21https://github.com/serhiy-storchaka/cpython/commit/ce88d2168cf2f3663e0810caf1061de40d3ee41a
gpsheadhttps://github.com/gpshead
on Jun 1, 2025https://github.com/python/cpython/issues/133489#event-17908448101
[3.14] gh-133489: Remove size restrictions on getrandbits() and randb…https://github.com/python/cpython/commit/7c1dfd9c988be07c14892177db6b512e4983ca20
gh-133489https://github.com/python/cpython/issues/133489
7c1dfd9https://github.com/python/cpython/commit/7c1dfd9c988be07c14892177db6b512e4983ca20
serhiy-storchakahttps://github.com/serhiy-storchaka
on Jun 2, 2025https://github.com/python/cpython/issues/133489#event-17942391811
[3.13] gh-133489: Remove size restrictions on getrandbits() and randb…https://github.com/python/cpython/commit/3e1b8d6e678ed0d834c9bc37bbb599cd63e88a82
gh-133489https://github.com/python/cpython/issues/133489
3e1b8d6https://github.com/python/cpython/commit/3e1b8d6e678ed0d834c9bc37bbb599cd63e88a82
serhiy-storchakahttps://github.com/serhiy-storchaka
completedhttps://github.com/python/cpython/issues?q=is%3Aissue%20state%3Aclosed%20archived%3Afalse%20reason%3Acompleted
on Jun 2, 2025https://github.com/python/cpython/issues/133489#event-17942401552
https://github.com/tornaria
tornariahttps://github.com/tornaria
on Jun 9, 2025https://github.com/python/cpython/issues/133489#issuecomment-2954448300
https://github.com/gpshead
gpsheadhttps://github.com/gpshead
on Jun 9, 2025https://github.com/python/cpython/issues/133489#issuecomment-2954477709
https://github.com/skirpichev
skirpichevhttps://github.com/skirpichev
on Jun 9, 2025https://github.com/python/cpython/issues/133489#issuecomment-2954523136
gpsheadhttps://github.com/gpshead
on Jun 10, 2025https://github.com/python/cpython/issues/133489#event-18066824671
pythongh-135326: Revert "[3.13] pythongh-133489: Remove size restrict…https://github.com/gpshead/cpython/commit/f2585646fe3a4a4d8d1ac3c9c03248165c24db1a
pythongh-135326https://github.com/python/cpython/issues/135326
pythongh-133489https://github.com/python/cpython/issues/133489
f258564https://github.com/gpshead/cpython/commit/f2585646fe3a4a4d8d1ac3c9c03248165c24db1a
Pranjal095https://github.com/Pranjal095
on Jul 12, 2025https://github.com/python/cpython/issues/133489#event-18600177542
pythongh-133489: Remove size restrictions on getrandbits() and randby…https://github.com/Pranjal095/cpython/commit/69fac3499bdb34ee201e8cf7e148f03d6c847773
pythongh-133489https://github.com/python/cpython/issues/133489
69fac34https://github.com/Pranjal095/cpython/commit/69fac3499bdb34ee201e8cf7e148f03d6c847773
taegyunkimhttps://github.com/taegyunkim
on Aug 4, 2025https://github.com/python/cpython/issues/133489#event-18976830519
pythongh-133489: Remove size restrictions on getrandbits() and randby…https://github.com/taegyunkim/cpython/commit/6ec8a7db499014cb82333e50e07ebff0cd2f9987
pythongh-133489https://github.com/python/cpython/issues/133489
6ec8a7dhttps://github.com/taegyunkim/cpython/commit/6ec8a7db499014cb82333e50e07ebff0cd2f9987
Sign up for freehttps://github.com/signup?return_to=https://github.com/python/cpython/issues/133489
Sign in to commenthttps://github.com/login?return_to=https://github.com/python/cpython/issues/133489
serhiy-storchakahttps://github.com/serhiy-storchaka
extension-modulesC modules in the Modules dirhttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22extension-modules%22
type-bugAn unexpected behavior, bug, or errorhttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22type-bug%22
docs issueshttps://github.com/orgs/python/projects/52
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Viewport: width=device-width


URLs of crawlers that visited me.