[issue7370] patch: BaseHTTPServer reinventing rfc822 date formatting

2010-06-16 Thread anatoly techtonik

anatoly techtonik techto...@gmail.com added the comment:

I do not like the idea that BaseHTTPServer depends on email package, which in 
turn may depend on another package etc. Having date formatting function inside 
of email package breaks single responsibility principle that would be nice to 
have in stdlib.

--
nosy: +techtonik

___
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



[issue7370] patch: BaseHTTPServer reinventing rfc822 date formatting

2010-06-13 Thread Shashwat Anand

Shashwat Anand anand.shash...@gmail.com added the comment:

Agreed.
Attaching the unit test.

--
Added file: http://bugs.python.org/file17656/test_httpserver.patch

___
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



[issue7370] patch: BaseHTTPServer reinventing rfc822 date formatting

2010-06-13 Thread Éric Araujo

Éric Araujo mer...@netwok.org added the comment:

The skeleton is good but you have to change one thing. Your test should
exercise a function or method of BaseHTTPServer, not the underlying
implementation detail. I failed to explain that earlier:

1a) Write a test that checks that the current code produces right values
for a handful of cases (perhaps the RFC has them, else pick at random);
1b) Check that the test pass with the current code;
2a) Change BaseHTTPServer to use emails.utils.formatdate;
2b) Check that the test still pass.

End of HOWTO write a regression test :)

--

___
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



[issue7370] patch: BaseHTTPServer reinventing rfc822 date formatting

2010-06-06 Thread Éric Araujo

Éric Araujo mer...@netwok.org added the comment:

You could get a minor speedup by doing “from email.utils import formatdate”.

Do we have tests know to check that the patch does not break anything?

Can this still go into 2.7?

--

___
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



[issue7370] patch: BaseHTTPServer reinventing rfc822 date formatting

2010-06-06 Thread Shashwat Anand

Changes by Shashwat Anand anand.shash...@gmail.com:


Removed file: http://bugs.python.org/file17567/BaseHTTPServer.patch

___
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



[issue7370] patch: BaseHTTPServer reinventing rfc822 date formatting

2010-06-06 Thread Shashwat Anand

Shashwat Anand anand.shash...@gmail.com added the comment:

 You could get a minor speedup by doing “from email.utils import formatdate”.

I guess I shall do that. 
Applied the patch and tested it, it does not break anything IMO and should go 
in python2.7

--
Added file: http://bugs.python.org/file17573/BaseHTTPServer.patch

___
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



[issue7370] patch: BaseHTTPServer reinventing rfc822 date formatting

2010-06-06 Thread Éric Araujo

Éric Araujo mer...@netwok.org added the comment:

Opinions are nice, tests are better! :)

--

___
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



[issue7370] patch: BaseHTTPServer reinventing rfc822 date formatting

2010-06-05 Thread Shashwat Anand

Changes by Shashwat Anand anand.shash...@gmail.com:


Removed file: http://bugs.python.org/file16900/BaseHTTPServer.patch

___
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



[issue7370] patch: BaseHTTPServer reinventing rfc822 date formatting

2010-06-05 Thread Shashwat Anand

Shashwat Anand anand.shash...@gmail.com added the comment:

Seems that earlier patch was incorrect. Rectifying and submitting the correct 
patch.

--
Added file: http://bugs.python.org/file17567/BaseHTTPServer.patch

___
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



[issue7370] patch: BaseHTTPServer reinventing rfc822 date formatting

2010-04-12 Thread Éric Araujo

Éric Araujo mer...@netwok.org added the comment:

Nice catch. The patch looks good to me and applies correctly on my trunk copy. 
There seems to be no test about this in the test suite; do you have a little 
test script to compare old and new code?

On a sidenote, I find all this business with time.time, time.gmtime, 
time.localtime and time.strftime always confusing. We have datetime objects 
now, would it be ok to use them in this module?

Regards

--

___
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



[issue7370] patch: BaseHTTPServer reinventing rfc822 date formatting

2010-04-12 Thread R. David Murray

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



[issue7370] patch: BaseHTTPServer reinventing rfc822 date formatting

2010-04-12 Thread Éric Araujo

Éric Araujo mer...@netwok.org added the comment:

“One could also ask whether BaseHTTPServer should use the logging 
module, but that is a whole separate issue.”
Indeed: http://www.python.org/dev/peps/pep-0337/

Cheers

--

___
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



[issue7370] patch: BaseHTTPServer reinventing rfc822 date formatting

2010-04-12 Thread Shashwat Anand

Changes by Shashwat Anand anand.shash...@gmail.com:


Removed file: http://bugs.python.org/file16890/BaseHTTPServer.patch

___
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



[issue7370] patch: BaseHTTPServer reinventing rfc822 date formatting

2010-04-12 Thread Shashwat Anand

Shashwat Anand anand.shash...@gmail.com added the comment:

Quoting from the docstring of trunk/Lib/email/utils.py - formatdate()

We cannot use strftime() because that honors the locale and RFC 2822 requires 
that day and month names be the English abbreviations.

So yes, I do agree that email.utils.formatdate() should be used instead of 
time.strftime() to remove duplicate codes and be compliant with RFC.
Removing previous patch and submitting another.

--

___
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



[issue7370] patch: BaseHTTPServer reinventing rfc822 date formatting

2010-04-12 Thread Shashwat Anand

Changes by Shashwat Anand anand.shash...@gmail.com:


Added file: http://bugs.python.org/file16900/BaseHTTPServer.patch

___
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



[issue7370] patch: BaseHTTPServer reinventing rfc822 date formatting

2010-04-11 Thread Shashwat Anand

Shashwat Anand anand.shash...@gmail.com added the comment:

Instead of “email.utils.formatdate(time, usegmt=True)” we can simply use 
time.strftime() and clean the code in a better way. The duplication is there in 
date_time_string() as well as log_date_time_string(). Submitting the patch for 
review.

--
nosy: +l0nwlf
Added file: http://bugs.python.org/file16890/BaseHTTPServer.patch

___
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



[issue7370] patch: BaseHTTPServer reinventing rfc822 date formatting

2010-04-08 Thread R. David Murray

Changes by R. David Murray rdmur...@bitdance.com:


--
title: patch: BaseHTTPServer reinventing rfc822 - patch: BaseHTTPServer 
reinventing rfc822 date formatting

___
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