[issue33770] base64 throws 'incorrect padding' exception when the issue is NOT with the padding

2018-06-10 Thread Ned Deily


Change by Ned Deily :


--
resolution:  -> fixed
stage: patch review -> resolved
status: open -> closed
versions:  -Python 2.7, Python 3.6

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue33770] base64 throws 'incorrect padding' exception when the issue is NOT with the padding

2018-06-10 Thread Tal Einat


Tal Einat  added the comment:

The change is not entirely backward-compatible, so not back-porting before 3.7 
seems good to me. IMO this should be closed.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue33770] base64 throws 'incorrect padding' exception when the issue is NOT with the padding

2018-06-10 Thread Ned Deily


Ned Deily  added the comment:

I backported Tal's fix for 3.7.0rc1.  I am less certain about backporting to 
3.6 and 2.7 at this stage of their lives but I don't have a strong feeling 
about it so I'll leave the issue open for that.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue33770] base64 throws 'incorrect padding' exception when the issue is NOT with the padding

2018-06-10 Thread Ned Deily


Ned Deily  added the comment:


New changeset 053d6c5ce246e6ba9c046467b02a0b6ba4abb8bf by Ned Deily (Miss 
Islington (bot)) in branch '3.7':
bpo-33770: improve base64 exception message for encoded inputs of invalid 
length (GH-7416) (GH-7602)
https://github.com/python/cpython/commit/053d6c5ce246e6ba9c046467b02a0b6ba4abb8bf


--
nosy: +ned.deily

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue33770] base64 throws 'incorrect padding' exception when the issue is NOT with the padding

2018-06-10 Thread miss-islington


Change by miss-islington :


--
pull_requests: +7224

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue33770] base64 throws 'incorrect padding' exception when the issue is NOT with the padding

2018-06-10 Thread Tal Einat


Tal Einat  added the comment:


New changeset 1b85c71a2136d3fa6a1da05b27b1fe4e4b8ee45e by Tal Einat in branch 
'master':
bpo-33770: improve base64 exception message for encoded inputs of invalid 
length (#7416)
https://github.com/python/cpython/commit/1b85c71a2136d3fa6a1da05b27b1fe4e4b8ee45e


--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue33770] base64 throws 'incorrect padding' exception when the issue is NOT with the padding

2018-06-08 Thread Tal Einat


Tal Einat  added the comment:

PR is ready with an improved exception message and raising binascii.Incomplete 
rather than binascii.Error. A final review would be welcome!

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue33770] base64 throws 'incorrect padding' exception when the issue is NOT with the padding

2018-06-08 Thread Tal Einat


Tal Einat  added the comment:

Code using only a2b_base64() would likely not be expecting this exception.

We have at least one such example in the stdlib: decode_b() in 
Lib/email/_encoded_words.py (which needs to be fixed regardless; see #27397).

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue33770] base64 throws 'incorrect padding' exception when the issue is NOT with the padding

2018-06-08 Thread R. David Murray


R. David Murray  added the comment:

I think that would move it even more into the realm of a bugfix, then, since 
code that cared about specific binascii exceptions could be looking for that 
one already.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue33770] base64 throws 'incorrect padding' exception when the issue is NOT with the padding

2018-06-08 Thread Tal Einat


Tal Einat  added the comment:

It is more a correction than a clarification.

After looking through the module some more, I'm considering using 
binascii.Incomplete for this case, since it seems appropriate enough that it's 
worth using it rather than adding another, separate exception.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue33770] base64 throws 'incorrect padding' exception when the issue is NOT with the padding

2018-06-08 Thread Terry J. Reedy


Terry J. Reedy  added the comment:

Is the new message a clarification, in which case we would typically not 
backport, or a correction, which we usually would?

--
nosy: +terry.reedy

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue33770] base64 throws 'incorrect padding' exception when the issue is NOT with the padding

2018-06-05 Thread Dmitry


Dmitry  added the comment:

@taleinat - yes, that does look much better!

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue33770] base64 throws 'incorrect padding' exception when the issue is NOT with the padding

2018-06-05 Thread Tal Einat


Tal Einat  added the comment:

Would an exception message as following be acceptable? "Invalid base64-encoded 
string: length cannot be 1 more than a multiple of 4"

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue33770] base64 throws 'incorrect padding' exception when the issue is NOT with the padding

2018-06-05 Thread R. David Murray


R. David Murray  added the comment:

I agree, but that would be a separate enhancement PR.  The email library would 
use that capability if it existed...currently it adds padding in a loop trying 
to do the decode if it gets the invalid padding message.  Which of course is 
going to fail for this case.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue33770] base64 throws 'incorrect padding' exception when the issue is NOT with the padding

2018-06-05 Thread Dmitry

Dmitry  added the comment:

I think something like “invalid length” message does make more sense in this 
case than the misleading “incorrect padding”.

It would also be great if there was a way to force it to try its best at 
decoding the string. :)

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue33770] base64 throws 'incorrect padding' exception when the issue is NOT with the padding

2018-06-05 Thread Tal Einat


Tal Einat  added the comment:

They're not the same.

When the encoded string's length modulu 4 is 2 or 3, there just need to be (at 
least) 2 or 1 padding characters ('=') for decoding to be successful, due to 
our decoder being rather strict. Less strict decoders may ignore the missing 
padding and successfully decode the encoded string.

When the remainder is 0, no padding is needed and everything is fine.

When the remainder is 1, the encoded string is simply invalid. It is not a 
padding issue. There is no valid way to decode the encoded string.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue33770] base64 throws 'incorrect padding' exception when the issue is NOT with the padding

2018-06-05 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:

I'm not sure that "Invalid length" is better than "Invalid padding". Doesn't it 
mean the same?

--
nosy: +serhiy.storchaka

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue33770] base64 throws 'incorrect padding' exception when the issue is NOT with the padding

2018-06-05 Thread Tal Einat


Tal Einat  added the comment:

Oops: when I wrote "length can only have a remainder of ..." I meant remainder 
upon division by 4.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue33770] base64 throws 'incorrect padding' exception when the issue is NOT with the padding

2018-06-05 Thread Tal Einat


Tal Einat  added the comment:

A base64-encoded string's length can only have a remainder of 0, 2 or 3, but 
never 1. This is why the padding you get when encoding can only be '=' or '==' 
but never '==='.

--
nosy: +taleinat

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue33770] base64 throws 'incorrect padding' exception when the issue is NOT with the padding

2018-06-05 Thread Tal Einat


Change by Tal Einat :


--
keywords: +patch
pull_requests: +7040
stage: needs patch -> patch review

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue33770] base64 throws 'incorrect padding' exception when the issue is NOT with the padding

2018-06-04 Thread Dmitry


Change by Dmitry :


--
title: base64 throws 'incorrect padding' exception even though the string 
length is a multiple of 4 -> base64 throws 'incorrect padding' exception when 
the issue is NOT with the padding

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com