[issue11584] email.decode_header fails if msg.__getitem__ returns Header object
Roundup Robot devnull@devnull added the comment: New changeset d62e5682a8ac by R David Murray in branch '3.2': #11584: make decode_header handle Header objects correctly http://hg.python.org/cpython/rev/d62e5682a8ac New changeset ce033d252a6d by R David Murray in branch 'default': merge #11584: make decode_header handle Header objects correctly http://hg.python.org/cpython/rev/ce033d252a6d -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue11584 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue11584] email.decode_header fails if msg.__getitem__ returns Header object
Roundup Robot devnull@devnull added the comment: New changeset 3875ccea6367 by R David Murray in branch '3.2': #11584: make Header and make_header handle binary unknown-8bit input http://hg.python.org/cpython/rev/3875ccea6367 New changeset 9569d8c4c781 by R David Murray in branch 'default': merge #11584: make Header and make_header handle binary unknown-8bit input http://hg.python.org/cpython/rev/9569d8c4c781 -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue11584 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue11584] email.decode_header fails if msg.__getitem__ returns Header object
R. David Murray rdmur...@bitdance.com added the comment: OK, the invariant make_header(decode_header(x)) == x should once again work for anything returned by __getitem__. -- stage: needs patch - committed/rejected status: open - closed ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue11584 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue11584] email.decode_header fails if msg.__getitem__ returns Header object
R. David Murray rdmur...@bitdance.com added the comment: Heh, I misstated that invariant, it's only true when x is a Header. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue11584 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue11584] email.decode_header fails if msg.__getitem__ returns Header object
R. David Murray rdmur...@bitdance.com added the comment: My fix (and the tests) for this are wrong. decode_header returns (binary, charset) pairs, but the chunks list is (string, charset) pairs. -- stage: committed/rejected - needs patch status: closed - open ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue11584 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue11584] email.decode_header fails if msg.__getitem__ returns Header object
R. David Murray rdmur...@bitdance.com added the comment: Note that when this is fixed, make_header on the return value from decode_header will fail because it doesn't know now to handle unknown-8bit. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue11584 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue11584] email.decode_header fails if msg.__getitem__ returns Header object
R. David Murray rdmur...@bitdance.com added the comment: Thinking about this some more, I now think it is incorrect that an 8bit header causes getitem to return a Header object. I think instead it should be returning the stringified version of the header, including the unknown-8bit encoding. That way decode_header can be used as normal to recover the original bytes. I hate making a change like this in a bug fix release, but in this case I think it is the right thing to do. I will propose a patch soon. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue11584 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue11584] email.decode_header fails if msg.__getitem__ returns Header object
Steffen Daode Nurpmeso sdao...@googlemail.com added the comment: On Fri, Mar 25, 2011 at 01:51:46PM +, R. David Murray wrote: I now think it is incorrect that an 8bit header causes getitem to return a Header object. I think instead it should be returning the stringified version of the header, including the unknown-8bit encoding. It seems to be much better to either return only strings or only objects. You've prominently documented that (in a model generated from bytes) objects are returned, and *DesignThoughts* states that *all* headers will be represented as objects in the upcoming package, so it's my guess that many people who are currently programming email things using Py3K go for Header. Thus, to give you a neat NONONO - why not simply allowing header objects for decode_header(), too? :) -- title: email.decode_header fails if msg.__getitem__ returns Header object - email.decode_header fails if msg.__getitem__ returns Header object ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue11584 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue11584] email.decode_header fails if msg.__getitem__ returns Header object
R. David Murray rdmur...@bitdance.com added the comment: I documented that? Where? It is true that the fact that all headers will be objects when using the email6 API was one reason I did it this way, but in hindsight I don't think it was the right choice. However, I/we may now be stuck with it, in which case you are right, we could make decode_header just return the chunks from a Header object. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue11584 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue11584] email.decode_header fails if msg.__getitem__ returns Header object
Steffen Daode Nurpmeso sdao...@googlemail.com added the comment: On Fri, Mar 25, 2011 at 02:29:24PM +, R. David Murray wrote: I documented that? Where? Changeset: 67447:cad1811d9e13 user:R. David Murray rdmur...@bitdance.com date:Fri Jan 07 23:25:30 2011 + summary: #10686: recode non-ASCII headers to 'unknown-8bit' instead of ?s. It was a friday. So, have a nice weekend. :) -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue11584 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue11584] email.decode_header fails if msg.__getitem__ returns Header object
R. David Murray rdmur...@bitdance.com added the comment: Heh. OK, so I think we're stuck with it, then. It does mean I don't have to handle certain other edge cases, and can punt more convenient handling of them into email6. I'll make the patch for decode_header instead, then. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue11584 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue11584] email.decode_header fails if msg.__getitem__ returns Header object
R. David Murray rdmur...@bitdance.com added the comment: OK, here is the patch. -- keywords: +patch Added file: http://bugs.python.org/file21392/decode_Header.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue11584 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue11584] email.decode_header fails if msg.__getitem__ returns Header object
Steffen Daode Nurpmeso sdao...@googlemail.com added the comment: On Fri, Mar 25, 2011 at 03:04:29PM +, R. David Murray wrote: OK, here is the patch. Works fine at a first glance and for me - i see you didn't stuck :/. Say, though not belonging here, can you think of problems incurred in message.py:_sanitize_headers() due to if _has_surrogates(value): instead of: if _has_surrogates_or_8bit(value): I stumbled over that place somewhen but fixing it was no real help. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue11584 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue11584] email.decode_header fails if msg.__getitem__ returns Header object
R. David Murray rdmur...@bitdance.com added the comment: Theoretically there should be no way to get bytes into that code path. I'm sure there's a way if you try hard enough (I haven't tried directly assigning a byte string as a header value, for example), but they would be broken uses of the API. If you have an identifiable bug, though, open an issue. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue11584 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue11584] email.decode_header fails if msg.__getitem__ returns Header object
Roundup Robot devnull@devnull added the comment: New changeset b21fdfa0019c by R David Murray in branch '3.2': #11584: Since __getitem__ returns headers, make decode_header handle them. http://hg.python.org/cpython/rev/b21fdfa0019c New changeset 12e39cd7a0e4 by R David Murray in branch 'default': Merge #11584: Since __getitem__ returns headers, make decode_header handle them. http://hg.python.org/cpython/rev/12e39cd7a0e4 -- nosy: +python-dev ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue11584 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue11584] email.decode_header fails if msg.__getitem__ returns Header object
Changes by R. David Murray rdmur...@bitdance.com: -- resolution: - fixed stage: needs patch - committed/rejected status: open - closed ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue11584 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue11584] email.decode_header fails if msg.__getitem__ returns Header object
R. David Murray rdmur...@bitdance.com added the comment: If the message contains 8bit bytes in a header, then getitem is going to return a Header object. decode_header does not operate on Header objects, as you have observed. Thinking about it some more, having decode_header operate on a Header and return its chunks is a decent binary interface for Header. This is right on the borderline between a feature and a bug fix, but given that getitem returning Header after a parse is a new feature in 3.2, I think I'm going to treat it as a bug that decode_header doesn't handle that case. -- stage: test needed - needs patch title: email/header.py: missing str()ification, and bogus encode()s - email.decode_header fails if msg.__getitem__ returns Header object ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue11584 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com