[Python-bugs-list] [ python-Bugs-463330 ] binascii.b2a_base64() trailing newline

noreply@sourceforge.net noreply@sourceforge.net
Sat, 22 Sep 2001 10:46:29 -0700


Bugs item #463330, was opened at 2001-09-20 13:36
You can respond by visiting: 
http://sourceforge.net/tracker/?func=detail&atid=105470&aid=463330&group_id=5470

Category: Extension Modules
Group: None
Status: Open
Resolution: None
Priority: 5
Submitted By: Barry Warsaw (bwarsaw)
Assigned to: Jack Jansen (jackjansen)
Summary: binascii.b2a_base64() trailing newline

Initial Comment:
binascii.b2a_base64() should not append a "courtesy
newline".  See attached patch (but the test suite
should be updated too).


----------------------------------------------------------------------

>Comment By: Guido van Rossum (gvanrossum)
Date: 2001-09-22 10:46

Message:
Logged In: YES 
user_id=6380

Whether or not it's documented for base64, changing that
will also break existing code.

It's a documentation issue (unfortunately).

----------------------------------------------------------------------

Comment By: Barry Warsaw (bwarsaw)
Date: 2001-09-21 20:38

Message:
Logged In: YES 
user_id=12800

You're right, the newline is documented in b2a_base64().  I
actually hit this problem through the base64 module, which
uses binascii underneath.  The extra newline is implied in
the example, but not really documented.  I think it may also
be a bit misleading to quote RFC 1521 where that RFC does
not (I think) require the newline.

Two options:

- reassign to Fred for updating the base64 documentation
about the extra newline.

- get rid of the extra newline in base64 only, not in
binascii.  This can be accomplished by looking at the source
string: if it has a trailing newline, leave one in, if it
doesn't strip the extra newline from the result string. 
That's the solution I'll use in the email package if we
don't change base64.

----------------------------------------------------------------------

Comment By: Guido van Rossum (gvanrossum)
Date: 2001-09-21 09:06

Message:
Logged In: YES 
user_id=6380

But won't this break working code?  I believe the courtesy
newline is documented. If people program around this
naively, their code will break.

----------------------------------------------------------------------

You can respond by visiting: 
http://sourceforge.net/tracker/?func=detail&atid=105470&aid=463330&group_id=5470