-
-
Notifications
You must be signed in to change notification settings - Fork 34.4k
Revive binascii.Incomplete? #148108
Copy link
Copy link
Open
Labels
3.15new features, bugs and security fixesnew features, bugs and security fixesextension-modulesC modules in the Modules dirC modules in the Modules dirtype-featureA feature request or enhancementA feature request or enhancement
Metadata
Metadata
Assignees
Labels
3.15new features, bugs and security fixesnew features, bugs and security fixesextension-modulesC modules in the Modules dirC modules in the Modules dirtype-featureA feature request or enhancementA feature request or enhancement
Feature or enhancement
binascii.Incompletewas only used in BinHex 4 (HQX) decoder. After removing that decoder in #89248,binascii.Incompletebecame 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.Incompleteshould be made a subclass ofbinascii.Error.We perhaps will need to add also the
finalparameter (Trueby default). If it is false, thenbinascii.Incompletewill 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