[Python-3000] fix email module for bytes/str
Guido van Rossum
guido at python.org
Thu Aug 9 02:01:14 CEST 2007
You might want to send this to the email-sig.
On 8/8/07, Victor Stinner <victor.stinner at haypocalc.com> wrote:
> Hi,
>
> I started to work on email module, but I have trouble to understand if a
> function should returns bytes or str (because I don't know email module).
>
> Header.encode() -> bytes?
> Message.as_string() -> bytes?
> decode_header() -> list of (bytes, str|None) or (str, str|None)?
> base64MIME.encode() -> bytes?
>
> message_from_string() <- bytes?
>
> Message.get_payload() -> bytes or str?
>
> A charset name type is str, right?
>
> ---------------
>
> Things to change to get bytes:
> - replace StringIO with BytesIO
> - add 'b' prefix, eg. '' becomes b''
> - replace "%s=%s" % (x, y) with b''.join((x, b'=', y))
> => is it the best method to concatenate bytes?
>
> Problems (to port python 2.x code to 3000):
> - When obj.lower() is used, I expect obj to be str but it's bytes
> - obj.strip() doesn't work when obj is a byte, it requires an
> argument but I don't know the right value! Maybe b'\n\r\v\t '?
> - iterate on a bytes object gives number and not bytes object, eg.
> for c in b"small text":
> if re.match("(\n|\r)", c): ...
> Is it possible to 'bytes' regex? re.compile(b"x") raise an exception
>
> --
> Victor Stinner aka haypo
> http://hachoir.org/
> _______________________________________________
> Python-3000 mailing list
> Python-3000 at python.org
> http://mail.python.org/mailman/listinfo/python-3000
> Unsubscribe: http://mail.python.org/mailman/options/python-3000/guido%40python.org
>
--
--Guido van Rossum (home page: http://www.python.org/~guido/)
More information about the Python-3000
mailing list