This issue tracker has been migrated to GitHub ,
and is currently read-only.
For more information,
see the GitHub FAQs in the Python's Developer Guide.
Created on 2006年02月28日 17:11 by rnortman, last changed 2022年04月11日 14:56 by admin. This issue is now closed.
| Files | ||||
|---|---|---|---|---|
| File name | Uploaded | Description | Edit | |
| gen_not_quite_idem.patch | r.david.murray, 2011年03月14日 15:38 | |||
| Messages (5) | |||
|---|---|---|---|
| msg27634 - (view) | Author: Randall Nortman (rnortman) | Date: 2006年02月28日 17:11 | |
The documentation for the email.Generator module claims that the flatten() method is idempotent (i.e., output identical to the input, if email.Parser.Parser was used on the input), but it is not in all cases. The most obvious example is that you need to disable mangle_from and set maxheaderlen=0 to disable header wrapping. This could be considered common sense, but the documentation should mention it, as both are enabled by default. (unixfrom can also create differences between input and output, but is disabled by default.) More importantly, whitespace is not preserved in headers: if there are extra spaces between the header name and the header contents, it will be collapsed to a single space. This little snippet will demonstrate the problem: parser = email.Parser.Parser() msg = parser.parse(sys.stdin) print msg gen = email.Generator.Generator(sys.stdout, mangle_from_=False, maxheaderlen=0) gen.flatten(msg, unixfrom=False) Feed it a single message with extra spaces beween field name and field contents in one or more fields, and diff the input and the output. It is probably not worth actually making these routines idempotent, as preserving whitespace is not important in most applications and would require extra bookkeeping. However, as long as the documentation claims the routines are idempotent, it is a bug not to be. In my particular application, it was important to be truly idempotent, so this was a problem. Had the documentation not made false claims, I would have known from the start that I needed to write my own versions of the routines in the email module. |
|||
| msg81576 - (view) | Author: Barry A. Warsaw (barry) * (Python committer) | Date: 2009年02月10日 18:36 | |
I think we should update the documentation to mention these exceptions. |
|||
| msg115008 - (view) | Author: Mark Lawrence (BreamoreBoy) * | Date: 2010年08月26日 16:44 | |
Does this belong with RDM or docs@python? |
|||
| msg130830 - (view) | Author: R. David Murray (r.david.murray) * (Python committer) | Date: 2011年03月14日 15:38 | |
Here is a patch that adds a footnote explaining the issue. |
|||
| msg160796 - (view) | Author: Roundup Robot (python-dev) (Python triager) | Date: 2012年05月16日 02:14 | |
New changeset 8bd30967bc4b by R David Murray in branch '3.2': #1440472: Explain that email parser/generator isn't *quite* "idempotent" http://hg.python.org/cpython/rev/8bd30967bc4b New changeset f534e6363bfb by R David Murray in branch 'default': merge #1440472: Explain that email parser/generator isn't *quite* "idempotent" http://hg.python.org/cpython/rev/f534e6363bfb New changeset 9d99273c2f74 by R David Murray in branch '2.7': #1440472: Explain that email parser/generator isn't *quite* "idempotent" http://hg.python.org/cpython/rev/9d99273c2f74 New changeset 180d16af22e9 by R David Murray in branch '2.7': #1440472: reflow http://hg.python.org/cpython/rev/180d16af22e9 New changeset d1fbfd9af5c5 by R David Murray in branch '3.2': #1440472: reflow http://hg.python.org/cpython/rev/d1fbfd9af5c5 New changeset 4ec95207281c by R David Murray in branch 'default': merge #1440472: reflow http://hg.python.org/cpython/rev/4ec95207281c |
|||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2022年04月11日 14:56:15 | admin | set | github: 42954 |
| 2012年05月16日 02:15:07 | r.david.murray | set | status: open -> closed stage: needs patch -> resolved resolution: fixed components: + email versions: - Python 3.1 |
| 2012年05月16日 02:14:10 | python-dev | set | nosy:
+ python-dev messages: + msg160796 |
| 2011年03月14日 15:38:26 | r.david.murray | set | files:
+ gen_not_quite_idem.patch messages: + msg130830 keywords: + patch nosy: barry, rnortman, r.david.murray, BreamoreBoy |
| 2011年03月13日 22:53:32 | r.david.murray | set | nosy:
barry, rnortman, r.david.murray, BreamoreBoy versions: + Python 3.3 |
| 2010年08月26日 16:44:50 | BreamoreBoy | set | nosy:
+ BreamoreBoy messages: + msg115008 versions: + Python 3.1, Python 2.7, Python 3.2, - Python 2.6, Python 3.0 |
| 2010年05月05日 13:42:08 | barry | set | assignee: barry -> r.david.murray nosy: + r.david.murray |
| 2009年04月22日 18:50:10 | ajaksu2 | set | keywords:
+ easy stage: needs patch |
| 2009年02月10日 18:36:15 | barry | set | messages: + msg81576 |
| 2009年02月10日 18:09:59 | ajaksu2 | set | type: behavior components: + Documentation, - Library (Lib) versions: + Python 2.6, Python 3.0 |
| 2006年02月28日 17:11:45 | rnortman | create | |