[Python-3000] should rfc822 accept text io or binary io?
barry at python.org
Fri Aug 17 21:03:11 CEST 2007
-----BEGIN PGP SIGNED MESSAGE-----
On Aug 17, 2007, at 1:22 PM, Martin v. Löwis wrote:
> A library implementing that in Python should certainly use bytes
> at the network (stream) side, and strings at the application side.
> Even though the format is human-readable, the protocol is byte-
> not character-oriented.
I should point out that the email package does not really intend to
operate from the wire endpoints. For example, for sending a message
over an smtp connection it expects that something like smtplib would
properly transform \n to \r\n as required by RFC 2821. It's a bit
dicier on the input side since you could envision a milter or
something taking an on-the-wire email representation from an smptd
and parsing it into an internal representation.
As I'm working on the email package I'm realizing that classes like
the parser and generator need to be stricter about how they interpret
their input, and that both use cases are reasonable in many
situations. Sometimes you want the parser to accept strings, but
bytes are not always unreasonable. Similarly with generating
output. Internally though, I feel fairly strongly that an email
message should be represented as strings, though sometimes (certainly
for idempotency) you still need to carry around the charset (i.e.
encoding). Headers are an example of this.
The email package conflates 8-bit strings and bytes all over the
place and I'm trying now to make its semantics much clearer.
Ideally, the package would be well suited not only for wire-to-wire
and all-internal uses, but also related domains like HTTP and other
RFC 2822-like contexts.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.7 (Darwin)
-----END PGP SIGNATURE-----
More information about the Python-3000