Title: base64.b64decode error raised on valid input · Issue #145968 · python/cpython · GitHub
Open Graph Title: base64.b64decode error raised on valid input · Issue #145968 · python/cpython
X Title: base64.b64decode error raised on valid input · Issue #145968 · python/cpython
Description: Bug report Bug description: An error is raised for the following valid test cases using the newly introduced ignorechars parameter import base64 assert base64.b64decode(b'/----', altchars=b'-+', ignorechars=b'/') == b'\xfb\xef\xbe' asser...
Open Graph Description: Bug report Bug description: An error is raised for the following valid test cases using the newly introduced ignorechars parameter import base64 assert base64.b64decode(b'/----', altchars=b'-+', ig...
X Description: Bug report Bug description: An error is raised for the following valid test cases using the newly introduced ignorechars parameter import base64 assert base64.b64decode(b'/----', altchars=b...
Opengraph URL: https://github.com/python/cpython/issues/145968
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"base64.b64decode error raised on valid input","articleBody":"# Bug report\n\n### Bug description:\n\nAn error is raised for the following valid test cases using the newly introduced `ignorechars` parameter\n```python\nimport base64\n\nassert base64.b64decode(b'/----', altchars=b'-+', ignorechars=b'/') == b'\\xfb\\xef\\xbe'\nassert base64.b64decode(b'+----', altchars=b'/-', ignorechars=b'+') == b'\\xff\\xff\\xff'\n```\n\nFor both we get:\n```\nbinascii.Error: Invalid base64-encoded string: number of data characters (5) cannot be 1 more than a multiple of 4\n```\nIn both cases, the leading byte should be ignored thus giving a 4 bytes valid input.\n\n### CPython versions tested on:\n\nCPython main branch\n\n### Operating systems tested on:\n\nmacOS\n\n\u003c!-- gh-linked-prs --\u003e\n### Linked PRs\n* gh-145969\n\u003c!-- /gh-linked-prs --\u003e\n","author":{"url":"https://github.com/mayeut","@type":"Person","name":"mayeut"},"datePublished":"2026-03-15T08:51:05.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":3},"url":"https://github.com/145968/cpython/issues/145968"}
| 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:df660a29-ef67-bafc-5e2a-a1791b3a06e9 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | D1C6:82FD0:AC2D311:AF99724:6A50B9DC |
| html-safe-nonce | bef2310351c8816716c3adb999fec24ed723be91ae9f9538e7b93e7f745adc9c |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJEMUM2OjgyRkQwOkFDMkQzMTE6QUY5OTcyNDo2QTUwQjlEQyIsInZpc2l0b3JfaWQiOiIxOTA0NDQ1MDg3MDI0MjAwMTU2IiwicmVnaW9uX2VkZ2UiOiJzZWEiLCJyZWdpb25fcmVuZGVyIjoic2VhIn0= |
| visitor-hmac | 880003ae90f15e67088a1ba3e70c9b1a45f5a8d9c2525c2d11b7bd3f82ffb90e |
| hovercard-subject-tag | issue:4077954714 |
| 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/145968/issue_layout |
| twitter:image | https://opengraph.githubassets.com/ef34751dc3ad7e50140366358593c8a31a8a3538d6ad80b1ced8fdd0aa18db9a/python/cpython/issues/145968 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/ef34751dc3ad7e50140366358593c8a31a8a3538d6ad80b1ced8fdd0aa18db9a/python/cpython/issues/145968 |
| og:image:alt | Bug report Bug description: An error is raised for the following valid test cases using the newly introduced ignorechars parameter import base64 assert base64.b64decode(b'/----', altchars=b'-+', ig... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | mayeut |
| hostname | github.com |
| expected-hostname | github.com |
| None | 63772747707af4093f0d5fc7aa1bb3bb55f412a9865207c4f421aa34c64cc404 |
| 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 | ded53fe94e3ff1bb4dbf8cc77e285396c92580fb |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width