[Python-Dev] base64 -- should b64encode introduce line breaks? (original) (raw)
Bill Janssen janssen at parc.com
Fri Sep 14 21:20:32 CEST 2007
- Previous message: [Python-Dev] base64 -- should b64encode introduce line breaks?
- Next message: [Python-Dev] base64 -- should b64encode introduce line breaks?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
>> I see that base64.b64encode and base64.standardb64encode 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 MIMEb64encode() and PEMb64encode() routines? Or just > an optional parameter to standardb64encode, called "maxlinelength", > 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).
I think that's probably right. I just added the PEM line-wrapping to the code in the ssl module. Though I hate to keep adding line-wrapping code here and there... Perhaps just adding a utility function, wrap_lines(), or some such to the module would suffice.
Bill
- Previous message: [Python-Dev] base64 -- should b64encode introduce line breaks?
- Next message: [Python-Dev] base64 -- should b64encode introduce line breaks?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]