Title: `int.__round__(None)` is not supported · Issue #120080 · python/cpython · GitHub
Open Graph Title: `int.__round__(None)` is not supported · Issue #120080 · python/cpython
X Title: `int.__round__(None)` is not supported · Issue #120080 · python/cpython
Description: Bug report Bug description: The __round__ method on floats accepts None as an explicit argument, but the one on int does not: >>> (1.0).__round__(None) 1 >>> (1).__round__(None) Traceback (most recent call last): File "
Open Graph Description: Bug report Bug description: The __round__ method on floats accepts None as an explicit argument, but the one on int does not: >>> (1.0).__round__(None) 1 >>> (1).__round__(None) Traceback (most rec...
X Description: Bug report Bug description: The __round__ method on floats accepts None as an explicit argument, but the one on int does not: >>> (1.0).__round__(None) 1 >>> (1).__round__(None) T...
Opengraph URL: https://github.com/python/cpython/issues/120080
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"`int.__round__(None)` is not supported","articleBody":"# Bug report\n\n### Bug description:\n\nThe `__round__` method on floats accepts None as an explicit argument, but the one on int does not:\n\n```python\n>>> (1.0).__round__(None)\n1\n>>> (1).__round__(None)\nTraceback (most recent call last):\n File \"\u003cstdin>\", line 1, in \u003cmodule>\nTypeError: 'NoneType' object cannot be interpreted as an integer\n```\n\nThis goes against the general principle that any operation that works on a float should also work on an int.\n\n(Note that both `round(x)` and `round(x, None)` work on both floats and ints; this issue is entirely about direct calls to `.__round__()`.)\n\n### CPython versions tested on:\n\n3.12, CPython main branch\n\n### Operating systems tested on:\n\n_No response_\n\n\u003c!-- gh-linked-prs -->\n### Linked PRs\n* gh-120088\n* gh-120197\n* gh-120328\n\u003c!-- /gh-linked-prs -->\n","author":{"url":"https://github.com/JelleZijlstra","@type":"Person","name":"JelleZijlstra"},"datePublished":"2024-06-04T23:09:08Z","url":"https://github.com/python/cpython/issues/120080"}
| 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:5dd4ee84-db52-f82e-03b3-3cb812eb9896 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | A302:CF959:278C363:33946FB:6AFFFA4C |
| html-safe-nonce | 7f1f0e915f1532534a3209d9a4e224079bededf967b687ed9aef6b188322c2ca |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBMzAyOkNGOTU5OjI3OEMzNjM6MzM5NDZGQjo2QUZGRkE0QyIsInZpc2l0b3JfaWQiOiI1NDE1MjUwMDQ3ODE2MTU2OTIiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 2c1a4cafdac730c7e2e551f3f957f605d2c5f9d0c53f8e66694d6d685fe17944 |
| hovercard-subject-tag | issue:2334526017 |
| 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/120080/issue_layout |
| twitter:image | https://opengraph.githubassets.com/faa28f119fa7cc59373164ad06e0d928bf597b2308c16f845123bfe95fa30700/python/cpython/issues/120080 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/faa28f119fa7cc59373164ad06e0d928bf597b2308c16f845123bfe95fa30700/python/cpython/issues/120080 |
| og:image:alt | Bug report Bug description: The __round__ method on floats accepts None as an explicit argument, but the one on int does not: >>> (1.0).__round__(None) 1 >>> (1).__round__(None) Traceback (most rec... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | JelleZijlstra |
| hostname | github.com |
| expected-hostname | github.com |
| None | 0a0d8686a27478df474dd7415776a7a080cde8838b3cd92ea7601187572e5729 |
| 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 | 16a11879678aaf97e2a42c33ee70830aa084fa37 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width