Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: Python: Dev

base64 -- should b64encode introduce line breaks?

 

 

Python dev RSS feed   Index | Next | Previous | View Threaded


janssen at parc

Sep 13, 2007, 10:55 AM

Post #1 of 7 (562 views)
Permalink
base64 -- should b64encode introduce line breaks?

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?

Bill
_______________________________________________
Python-Dev mailing list
Python-Dev [at] python
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: http://mail.python.org/mailman/options/python-dev/list-python-dev%40lists.gossamer-threads.com


janssen at parc

Sep 13, 2007, 11:43 AM

Post #2 of 7 (526 views)
Permalink
Re: base64 -- should b64encode introduce line breaks? [In reply to]

> 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?

Bill


_______________________________________________
Python-Dev mailing list
Python-Dev [at] python
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: http://mail.python.org/mailman/options/python-dev/list-python-dev%40lists.gossamer-threads.com


barry at python

Sep 14, 2007, 11:34 AM

Post #3 of 7 (518 views)
Permalink
Re: base64 -- should b64encode introduce line breaks? [In reply to]

-----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-----
_______________________________________________
Python-Dev mailing list
Python-Dev [at] python
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: http://mail.python.org/mailman/options/python-dev/list-python-dev%40lists.gossamer-threads.com


janssen at parc

Sep 14, 2007, 12:20 PM

Post #4 of 7 (519 views)
Permalink
Re: base64 -- should b64encode introduce line breaks? [In reply to]

> >> 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).

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
_______________________________________________
Python-Dev mailing list
Python-Dev [at] python
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: http://mail.python.org/mailman/options/python-dev/list-python-dev%40lists.gossamer-threads.com


barry at python

Sep 14, 2007, 12:54 PM

Post #5 of 7 (514 views)
Permalink
Re: base64 -- should b64encode introduce line breaks? [In reply to]

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

On Sep 14, 2007, at 3:20 PM, Bill Janssen wrote:

> 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.

Does anything in textwrap already do the trick? If not, that might
be the best place to refactor similar code to.

- -Barry

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

iQCVAwUBRurm8HEjvBPtnXfVAQIGFwP9G/hYbZ/cR7n9X4NtKATFqm/Mp+q8SH3b
jFUEuvf/y0/0Ri6aKpC9QJzLNg+ZlgthmaYNRT488SXPplbB4mtysFbJg+A9x3d3
fi4rkqXnrvJt6Msqbti7wt6sGYZRisDveztuKM5Sh8t+die+55e3bZg7ght6Vyuk
+N6V9lg2/3A=
=iknB
-----END PGP SIGNATURE-----
_______________________________________________
Python-Dev mailing list
Python-Dev [at] python
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: http://mail.python.org/mailman/options/python-dev/list-python-dev%40lists.gossamer-threads.com


janssen at parc

Sep 14, 2007, 3:01 PM

Post #6 of 7 (534 views)
Permalink
Re: base64 -- should b64encode introduce line breaks? [In reply to]

> Does anything in textwrap already do the trick? If not, that might
> be the best place to refactor similar code to.

Yes, textwrap.fill. Thanks for pointing it out.

Bill
_______________________________________________
Python-Dev mailing list
Python-Dev [at] python
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: http://mail.python.org/mailman/options/python-dev/list-python-dev%40lists.gossamer-threads.com


barry at python

Sep 14, 2007, 3:37 PM

Post #7 of 7 (519 views)
Permalink
Re: base64 -- should b64encode introduce line breaks? [In reply to]

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

On Sep 14, 2007, at 6:01 PM, Bill Janssen wrote:

>> Does anything in textwrap already do the trick? If not, that might
>> be the best place to refactor similar code to.
>
> Yes, textwrap.fill. Thanks for pointing it out.

/me tries to remember that for Py3k's email package. ;)

- -Barry

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

iQCVAwUBRusNRnEjvBPtnXfVAQIpNgP/SosDYX/GDMolxcv3U2WrGzMjQa+gd8ai
J/Oaw2vdSf8H84eU9ziKaWHQtK0obS9XrnUTLUDyfAKObNffZVvldG1KUV9vAKhr
3JuNJ3xiIk7RKXdkKd5mA7SXXqRd80NVN26Za0H8bkl16mhdpZM7OqJmhaIkCkXr
AJtjJP5esWQ=
=v/C8
-----END PGP SIGNATURE-----
_______________________________________________
Python-Dev mailing list
Python-Dev [at] python
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: http://mail.python.org/mailman/options/python-dev/list-python-dev%40lists.gossamer-threads.com

Python dev RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact Gossamer Threads
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.