Issue 14344: repr of email policies is wrong (original) (raw)

Created on 2012-03-17 02:54 by eric.araujo, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Messages (6)
msg156130 - (view) Author: Éric Araujo (eric.araujo) * (Python committer) Date: 2012-03-17 02:54
>>> import email.policy as p >>> p.default Policy() >>> p.HTTP Policy(["linesep='\\r\\n'", 'max_line_length=None']) I think you wanted Policy(linesep='\r\n', max_line_length=None); the problem comes from __repr__ where a format field is replaced by a list, which should have been something ', '.join(args) instead. I can commit this minor thing if you want, I just wanted to check if I was right first.
msg156159 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2012-03-17 14:03
That doesn't produce an evalable repr, though. The repr should actually be Policy(linesep='\\r\\n', max_line_length=None) I'm not immediately seeing how to get that to happen.
msg156162 - (view) Author: Éric Araujo (eric.araujo) * (Python committer) Date: 2012-03-17 15:54
I don’t understand why the repr should use \\r instead of \r. It seems to work: >>> from email.policy import Policy, HTTP, strict >>> strict Policy(raise_on_defect=True) >>> eval(repr(strict)) Policy(raise_on_defect=True) >>> HTTP Policy(linesep='\r\n', max_line_length=None) >>> eval(repr(HTTP)) Policy(linesep='\r\n', max_line_length=None) >>> HTTP.__dict__ {'max_line_length': None, 'linesep': '\r\n'} >>> eval(repr(HTTP)).__dict__ {'max_line_length': None, 'linesep': '\r\n'}
msg156190 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2012-03-17 19:05
Ach, I screwed up my testing at the interactive interpreter. Yes, it does work, and I will commit the fix. Thanks for the report.
msg156191 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2012-03-17 19:12
New changeset 97b0cf9df420 by R David Murray in branch 'default': #14344: fixed the repr of email.policy objects. http://hg.python.org/cpython/rev/97b0cf9df420
msg156192 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2012-03-17 19:12
Committed.
History
Date User Action Args
2022-04-11 14:57:28 admin set github: 58552
2012-03-17 19:12:52 r.david.murray set status: open -> closedresolution: fixedmessages: + stage: resolved
2012-03-17 19:12:15 python-dev set nosy: + python-devmessages: +
2012-03-17 19:05:07 r.david.murray set messages: +
2012-03-17 15:54:08 eric.araujo set messages: +
2012-03-17 14:03:47 r.david.murray set messages: +
2012-03-17 02:54:57 eric.araujo create