classification
Title: rfc2822 formatdate functionality duplication
Type: performance Stage: needs patch
Components: Library (Lib) Versions: Python 3.2
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: BreamoreBoy, ajaksu2, anthonybaxter, barry, dalke, gaul, l0nwlf, r.david.murray
Priority: normal Keywords:

Created on 2003-06-02 05:18 by dalke, last changed 2010-08-19 01:01 by l0nwlf.

Messages (7)
msg60342 - (view) Author: Andrew Dalke (dalke) * (Python committer) Date: 2003-06-02 05:18
There are at least 4 places in the standard Python 2.3 library which 
build an RFC 2822 formatted string:

rfc822.formatstring
email.Utils.formatdate
logging.handlers.SMTPHandler.date_time
BaseHTTPServer.HTTPServer.date_time_string

Looking at them, it makes sense to me to
  - replace rfc822's implementation with email's
      (that's the most flexible of the bunch)

  - start a migration so that email uses the one
      from rfc822, if available, else it's own implementation
      (since email is distributed to older Pythons)

  - have logging use the one in rfc822.

  - have BaseHTTPServer use the one in rfc822

If this is deemed an appropriate change, I can send in
a patch.
msg60343 - (view) Author: Anthony Baxter (anthonybaxter) Date: 2003-06-02 06:13
Logged In: YES 
user_id=29957

It's not just formatdate - various email formatting tasks
are probably the
single largest source of duplication in the std library...

msg60344 - (view) Author: Barry A. Warsaw (barry) * (Python committer) Date: 2003-06-02 12:37
Logged In: YES 
user_id=12800

Personally, I'd like to see the email package's date formatting (and other 
email related tasks) be the canonical standard, and for other modules to use 
its rules when appropriate.
msg60345 - (view) Author: Andrew Gaul (gaul) Date: 2003-08-20 08:31
Logged In: YES 
user_id=139865

Careful, date/time formats differ between RFCs.

RFC 850  = Wdy, DD-Mon-YYYY HH:MM:SS (UT/GMT/(+/-)DDDD/...)
RFC 2616 = Wdy, DD Mon YYYY HH:MM:SS GMT
RFC 2822 = Wdy, DD Mon YYYY HH:MM:SS (+/-)DDDD

rfc822.formatstring
    deprecated; let it rot
email.Utils.formatdate
    uses RFC 2822, the One True Date Format
logging.handlers.SMTPHandler.date_time
    uses RFC 2616, should be using RFC 2822
BaseHTTPServer.HTTPServer.date_time_string
    uses RFC 2616
Cookie._getdate
    uses RFC 850

Patch 791776 changes SMTPHandler to use rfc2822.formatdate.
 grepping for day names, month names, year, gmtime, and
localtime does not reveal further duplication.
msg81712 - (view) Author: Daniel Diniz (ajaksu2) Date: 2009-02-12 03:10
Still present in source, but doesn't seem too bad.
msg114240 - (view) Author: Mark Lawrence (BreamoreBoy) Date: 2010-08-18 16:14
Does this need to be addressed or can it be closed as out of date or what?
msg114288 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2010-08-18 22:33
It still needs to be addressed.  I'm marking it for 3.2 but I doubt it will get addressed before 3.3 in reality.  I also made the type 'performance' since we have no 'refactoring' type.
History
Date User Action Args
2010-08-19 01:01:56l0nwlfsetnosy: + l0nwlf
2010-08-18 22:33:51r.david.murraysetversions: + Python 3.2, - Python 2.6
nosy: + r.david.murray

messages: + msg114288

type: performance
stage: needs patch
2010-08-18 16:14:50BreamoreBoysetnosy: + BreamoreBoy
messages: + msg114240
2009-02-12 03:10:11ajaksu2setnosy: + ajaksu2
messages: + msg81712
versions: + Python 2.6
2003-06-02 05:18:09dalkecreate