python / python/cpython

Revive binascii.Incomplete?

Open
#148,108 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

3.15 extension-modules type-feature
Dominant language
Python
Stars
77.2k
Forks
35.9k
PR merge metrics
PR metrics pending

Description

Feature or enhancement

binascii.Incomplete was only used in BinHex 4 (HQX) decoder. After removing that decoder in #89248, binascii.Incomplete became orphaned. It could be removed too.

We can reuse it for decoding errors that can potentially be fixed by reading more data. Not all incomplete data errors can be detected, in some codecs incomplete data can be valid.

For compatibility, binascii.Incomplete should be made a subclass of binascii.Error.

We perhaps will need to add also the final parameter (True by default). If it is false, then binascii.Incomplete will be raised if the last group of data is ambiguous, if the result of decoding concatenated data can be different from concatenation of independently decoded chunks.

I am not sure that this feature will be very useful, but without it we cannot reliably decode chunked data if it was split not on boundaries between groups. Although having only this feature the incremental decoder will be vulnerable to quadratic complexity issue. For example, reading line by line and decoding Base64 data split on 76 column lines except the first line containing 75 alphabetic characters will have quadratic complexity.

Linked PRs
  • gh-148109

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

The issue centers on binascii.Incomplete, the removed BinHex/HQX decoder, and chunked Base64 decoding. Start by reviewing the binascii decoder entry points and linked work gh-148109; clarify whether the exception should be removed or reused, its Error subclassing, and final semantics. Done requires agreed scope plus tests for incomplete and concatenated input.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
backend
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.