R. David Murray added the comment:

Thanks for narrowing this down.  There are two problems: the first is that the 
base64 module is raising "Incorrect padding" when the issue is actually that 
the input string cannot be decoded using the base64 algorithm no matter what 
padding might be supplied.  The second is that the else clause in 
_encoded_words *can* happen, in this circumstance.

The circumstance is that the input string contains n*4+1 characters.  No 
encoding of source text will ever produce that number of output characters.  (I 
also seem to have used an index one greater than needed for the loop; the 
maximum number of padding characters is 2.)

The interesting question is what we want to do for error recovery in the n*4+1 
case.  Do we declare the part invalid and return an empty string?  Do we try 
chopping off the last character and see if we can decode it?  The latter is 
complicated by the possible presence of invalid alphabet characters, but it is 
what I lean toward.

I'm open to alternate suggestions.  And to a patch if someone wants to write 
one :)

----------
stage:  -> needs patch
type: crash -> behavior
versions:  -Python 3.4

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue27397>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to