[issue747320] rfc2822 formatdate functionality duplication

2016-03-13 Thread Berker Peksag

Changes by Berker Peksag :


--
resolution:  -> fixed
stage: patch review -> resolved
status: open -> closed

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue747320] rfc2822 formatdate functionality duplication

2016-03-13 Thread Roundup Robot

Roundup Robot added the comment:

New changeset ee64faffd46a by Berker Peksag in branch 'default':
Issue #747320: Use email.utils.formatdate() to avoid code duplication
https://hg.python.org/cpython/rev/ee64faffd46a

--
nosy: +python-dev

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue747320] rfc2822 formatdate functionality duplication

2016-03-12 Thread Berker Peksag

Berker Peksag added the comment:

-now = time.time()
-year, month, day, hh, mm, ss, x, y, z = time.localtime(now)
-s = "%02d/%3s/%04d %02d:%02d:%02d" % (
-day, self.monthname[month], year, hh, mm, ss)
+s = time.strftime("%d/%b/%Y %H:%M:%S", time.localtime())

This part of the patch is incorrect. time.strftime() will return non-English 
values for different locales.

About deprecations of weekdayname and monthname attributes:

I know that they are undocumented, but they are already being used in the wild. 
For example, see https://github.com/natemago/srv/blob/master/srv.py#L419 Since 
we don't have any public API for this use case, I'd be +1 to keep them for now.

Here is an updated patch.

--
Added file: http://bugs.python.org/file42153/issue747320_v2.diff

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue747320] rfc2822 formatdate functionality duplication

2015-09-26 Thread Berker Peksag

Berker Peksag added the comment:

Here is an updated patch (including tests and documentation updates).

--
components:  -email
nosy: +berker.peksag
stage: needs patch -> patch review
type: performance -> enhancement
versions: +Python 3.6 -Python 3.5
Added file: http://bugs.python.org/file40587/issue747320.diff

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue747320] rfc2822 formatdate functionality duplication

2014-02-13 Thread Éric Araujo

Éric Araujo added the comment:

> what do you recommend to move forward with this bug and patches?

I would add tests to 3.4, to be sure that changing the code in 3.5 does not 
break compatibility.

> Do you have an example for "(A minor thing: I would use “attribute” instead 
> of “variable” in the docstrings.)"

“Deprecated weekdayname variable” → “Deprecated weekdayname attribute”

--
versions: +Python 3.5 -Python 3.4

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue747320] rfc2822 formatdate functionality duplication

2014-02-03 Thread karl

karl added the comment:

Eric,

what do you recommend to move forward with this bug and patches?
Need guidance.
Do you have an example for "(A minor thing: I would use “attribute” instead of 
“variable” in the docstrings.)"

Also which code base I should use? A lot of water has gone under the bridge in 
one year. :)

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue747320] rfc2822 formatdate functionality duplication

2014-02-03 Thread Mark Lawrence

Changes by Mark Lawrence :


--
nosy:  -BreamoreBoy

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue747320] rfc2822 formatdate functionality duplication

2013-03-08 Thread Éric Araujo

Éric Araujo added the comment:

Tests would be great, especially given that we can add them in 3.2 and when 
merging 3.2 into 3.3 and then default, it ensures that the new code has no 
regression.

(A minor thing: I would use “attribute” instead of “variable” in the 
docstrings.)

There are also test helpers to assert that a warning is sent, but we don’t have 
a full coverage policy so it’s okay if you don’t feel like adding them.

--
nosy: +eric.araujo, orsenthil

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue747320] rfc2822 formatdate functionality duplication

2013-03-08 Thread karl

karl added the comment:

Ok after comments and review by Eric Araujo on the previous patch.
See issue-747320-3.patch

I have ran

→ ./python.exe Lib/test/test_httpservers.py

[…]

--
Ran 39 tests in 3.734s

OK
[137158 refs]

That said there is no specific tests for date_time_string() and 
log_date_time_string(). That might be something to consider.

→ grep date_time  Lib/test/test_httpservers.py
[nil]

--
Added file: http://bugs.python.org/file29352/issue-747320-3.patch

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue747320] rfc2822 formatdate functionality duplication

2013-02-28 Thread karl

karl added the comment:

R. David Murray:

Sure. Is it better? issue-747320-1.patch

It seems there are already tests for gmt date format in 
Lib/test/test_email/test_utils.py

--
Added file: http://bugs.python.org/file29279/issue-747320-1.patch

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue747320] rfc2822 formatdate functionality duplication

2013-02-28 Thread R. David Murray

R. David Murray added the comment:

Could you regenerate your patch using hg diff? (or at least diff -u)?

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue747320] rfc2822 formatdate functionality duplication

2013-02-25 Thread karl

Changes by karl :


Removed file: http://bugs.python.org/file29240/server.patch

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue747320] rfc2822 formatdate functionality duplication

2013-02-25 Thread karl

karl added the comment:

Made a mistake in the previous server.patch, use server.2.patch

--
Added file: http://bugs.python.org/file29241/server2.patch

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue747320] rfc2822 formatdate functionality duplication

2013-02-25 Thread karl

karl added the comment:

http://tools.ietf.org/html/draft-ietf-httpbis-p2-semantics-22#section-7.1.1

quoting from HTTP 1.1 bis

   Prior to 1995, there were three different formats commonly used by
   servers to communicate timestamps.  For compatibility with old
   implementations, all three are defined here.  The preferred format is
   a fixed-length and single-zone subset of the date and time
   specification used by the Internet Message Format [RFC5322].

 HTTP-date= IMF-fixdate / obs-date

   An example of the preferred format is

 Sun, 06 Nov 1994 08:49:37 GMT; IMF-fixdate

   Examples of the two obsolete formats are

 Sunday, 06-Nov-94 08:49:37 GMT   ; obsolete RFC 850 format
 Sun Nov  6 08:49:37 1994 ; ANSI C's asctime() format

   A recipient that parses a timestamp value in an HTTP header field
   MUST accept all three formats.  A sender MUST generate the IMF-
   fixdate format when sending an HTTP-date value in a header field.


What http.server.BaseHTTPRequestHandler.date_time_string is currently doing

>>> import time
>>> timestamp = time.time()
>>> weekdayname = ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun']
>>> monthname = [None,'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun','Jul', 'Aug', 
>>> 'Sep', 'Oct', 'Nov', 'Dec']
>>> year, month, day, hh, mm, ss, wd, y, z = time.gmtime(timestamp)
>>> s = "%s, %02d %3s %4d %02d:%02d:%02d GMT" % (weekdayname[wd],day, 
>>> monthname[month], year,hh, mm, ss)
>>> s
'Mon, 25 Feb 2013 19:26:34 GMT'



what email.utils.formatdate is doing:

>>> import email.utils
>>> email.utils.formatdate(timeval=None,localtime=False, usegmt=True)
'Mon, 25 Feb 2013 19:40:04 GMT'
>>> import time
>>> ts = time.time()
>>> email.utils.formatdate(timeval=ts,localtime=False, usegmt=True)
'Mon, 25 Feb 2013 19:51:50 GMT'

I createad a patch 
s = email.utils.formatdate(timestamp, False, True)

I didn't touch the log method which has a different format which is anyway not 
compatible with email.utils.

--
keywords: +patch
nosy: +karlcow
Added file: http://bugs.python.org/file29240/server.patch

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue747320] rfc2822 formatdate functionality duplication

2013-02-23 Thread R. David Murray

R. David Murray added the comment:

I notice that logging has been updated.  Only http.server's date_time_string 
remains (email.utils.formatdate does support the GMT form).

--
components: +email
versions: +Python 3.4 -Python 3.2

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue747320] rfc2822 formatdate functionality duplication

2010-08-18 Thread Shashwat Anand

Changes by Shashwat Anand :


--
nosy: +l0nwlf

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue747320] rfc2822 formatdate functionality duplication

2010-08-18 Thread R. David Murray

R. David Murray  added the comment:

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.

--
nosy: +r.david.murray
stage:  -> needs patch
type:  -> performance
versions: +Python 3.2 -Python 2.6

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue747320] rfc2822 formatdate functionality duplication

2010-08-18 Thread Mark Lawrence

Mark Lawrence  added the comment:

Does this need to be addressed or can it be closed as out of date or what?

--
nosy: +BreamoreBoy

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue747320] rfc2822 formatdate functionality duplication

2009-02-11 Thread Daniel Diniz

Daniel Diniz  added the comment:

Still present in source, but doesn't seem too bad.

--
nosy: +ajaksu2
versions: +Python 2.6

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com