[Python-Dev] base64 -- should b64encode introduce line breaks?

Barry Warsaw barry at python.org
Fri Sep 14 20:34:44 CEST 2007


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Sep 13, 2007, at 2:43 PM, Bill Janssen wrote:

>> I see that base64.b64encode and base64.standard_b64encode no longer
>> introduce line breaks into the output strings, as base64.encodestring
>> does.  Shouldn't there be an option on one of them to do this?
>
> See:
>
> http://mail.python.org/pipermail/python-bugs-list/2001-October/ 
> 007856.html
>
> section 2.1 of http://www.faqs.org/rfcs/rfc3548.html
>
> Perhaps adding MIME_b64encode() and PEM_b64encode() routines?  Or just
> an optional parameter to standard_b64encode, called "max_line_length",
> defaulting to 0, meaning no max?

It turns out to be inconvenient in other contexts to do the line  
splitting at this lower level, so I would prefer to leave the current  
methods as is (that means, no change in semantics or arguments).

I wouldn't necessarily be opposed to new functions that did the line  
splitting, but ideally, you could design an API that provided that  
behavior for any of the existing alternatives in the base64 module,  
without duplicating them all.  It's not clear to me how you'd do that  
though (or if it's worth it).

- -Barry

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.7 (Darwin)

iQCUAwUBRurURHEjvBPtnXfVAQLSZAP4pdn3lUPvVfqSl+RT4GBzYmL1uUTMrmJx
+lc+7SEaOj0sphfQbTmN9kKlwS2cJQ7UdZQzXM6t5+zlM+b4GRl6pA0CEk/M3PUI
VWs3JkxgMRQA0CoeF5AflLru7ZxEL7pYej88y9KPAZCQ7H6e0+b8TCr/6Qj0YiYw
c2eLfZoSAA==
=klKj
-----END PGP SIGNATURE-----


More information about the Python-Dev mailing list