Title: gh-99925: Fix inconsistency in `json.dumps()` error messages by fnesveda · Pull Request #99926 · python/cpython · GitHub
Open Graph Title: gh-99925: Fix inconsistency in `json.dumps()` error messages by fnesveda · Pull Request #99926 · python/cpython
X Title: gh-99925: Fix inconsistency in `json.dumps()` error messages by fnesveda · Pull Request #99926 · python/cpython
Description: Fixes #99925. When you try to serialize a NaN, inf or -inf with json.dumps(..., allow_nan=False), the error messages are inconsistent, depending on whether you use indent or not. >>> json.dumps(float('nan'), allow_nan=False) ValueError: Out of range float values are not JSON compliant >>> json.dumps(float('nan'), allow_nan=False, indent=4) ValueError: Out of range float values are not JSON compliant: nan That is because if you don't use indent, the encoding is done in C code here, but if you use indent, the encoding is done in pure Python code here, and the error messages are different between the two. This PR unifies the error messages, so that both now include the representation of the invalid value. Issue: gh-99925
Open Graph Description: Fixes #99925. When you try to serialize a NaN, inf or -inf with json.dumps(..., allow_nan=False), the error messages are inconsistent, depending on whether you use indent or not. >>> json....
X Description: Fixes #99925. When you try to serialize a NaN, inf or -inf with json.dumps(..., allow_nan=False), the error messages are inconsistent, depending on whether you use indent or not. >>&a...
Opengraph URL: https://github.com/python/cpython/pull/99926
X: @github
Domain: github.com
| route-pattern | /:user_id/:repository/pull/:id/checks(.:format) |
| route-controller | pull_requests |
| route-action | checks |
| fetch-nonce | v2:6ba3c766-4dcc-5c80-6823-1de42714e12a |
| current-catalog-service-hash | 87dc3bc62d9b466312751bfd5f889726f4f1337bdff4e8be7da7c93d6c00a25a |
| request-id | C6FA:E3A3B:12F47E2:1962C40:69699D3B |
| html-safe-nonce | ec8a9868aba6e32e0ab4c480f67e5830f251679e80bb75673ed589a343be202d |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDNkZBOkUzQTNCOjEyRjQ3RTI6MTk2MkM0MDo2OTY5OUQzQiIsInZpc2l0b3JfaWQiOiIyMDU1MzQ3ODkxMDc1NjUyOTIzIiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 41621f9906caae289f0e06f54749078a2917d7ada23c060b9ae2f225517e21b7 |
| hovercard-subject-tag | pull_request:1141946866 |
| github-keyboard-shortcuts | repository,pull-request-list,pull-request-conversation,pull-request-files-changed,checks,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/python/cpython/pull/99926/checks |
| twitter:image | https://avatars.githubusercontent.com/u/2934111?s=400&v=4 |
| twitter:card | summary_large_image |
| og:image | https://avatars.githubusercontent.com/u/2934111?s=400&v=4 |
| og:image:alt | Fixes #99925. When you try to serialize a NaN, inf or -inf with json.dumps(..., allow_nan=False), the error messages are inconsistent, depending on whether you use indent or not. >>> json.... |
| og:site_name | GitHub |
| og:type | object |
| hostname | github.com |
| expected-hostname | github.com |
| None | 24c4c97a2d520cb286b35e1a4c22d7a4df3c26a2fa28dd7cdf0e65db327b4de7 |
| 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 full-width full-width-p-0 |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 124667f43168afb6c9c03b7c02eb5b1d2e1be3d9 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width