R. David Murray <rdmur...@bitdance.com> added the comment:

There are a couple problems with this patch.  The first is that fixing 
date_time_string by using strftime rather than email.utils.formatdate is 
suboptimal from a code reuse standpoint.  The reason is that the date in HTTP 
message headers is required to conform to the same RFC standard as that 
generated by formatdate, so it is better to use the same routine to generate 
it.  That way any bug fixes needed to handle RFC compliance are centralized in 
once place.

The second problem with the patch is that strftime generates locale-aware week 
and month names, but per RFC the header timestamps must use English names (see 
for example msg53731 in issue 665194; the comment about locale applies to both 
strftime and strptime).

If issue 665194 were implemented formatdate could use it, and then 
BaseHTTPServer could also use it directly.  But absent that it should use 
email.util.formatdate.  (That issue should also answer Éric's question about 
whether we can use DateTime here: not yet.)

Now, the logging routine is a different story.  That timestamp isn't required 
to follow the RFC, and one could argue that it makes sense for its timestamp to 
use the locale.  (One could also ask whether BaseHTTPServer should use the 
logging module, but that is a whole separate issue.)

We definitely should have a unit test before applying this patch, that makes 
sure the timestamp gets generated without error.  Checking the detailed format 
of the timestamp can be assumed to be covered by the unit tests for formatdate. 
 (I don't think those tests are completely adequate; for example they don't 
test that the date remains in English if the locale is different, but again 
that is a different issue.)

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue7370>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to