Skip to content

Revive binascii.Incomplete? #148108

@serhiy-storchaka

Description

@serhiy-storchaka

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    3.15new features, bugs and security fixesextension-modulesC modules in the Modules dirtype-featureA feature request or enhancement

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions