[issue23718] strptime() can produce invalid date with negative year day

2016-03-12 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

Thank you Tamás for your contribution.

--
resolution:  -> fixed
stage: commit 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



[issue23718] strptime() can produce invalid date with negative year day

2016-03-12 Thread Roundup Robot

Roundup Robot added the comment:

New changeset f03da87a79fa by Serhiy Storchaka in branch '3.5':
Issue #23718: Fixed parsing time in week 0 before Jan 1.  Original patch by
https://hg.python.org/cpython/rev/f03da87a79fa

New changeset 4fb167ec3108 by Serhiy Storchaka in branch '2.7':
Issue #23718: Fixed parsing time in week 0 before Jan 1.  Original patch by
https://hg.python.org/cpython/rev/4fb167ec3108

New changeset a7093386efaf by Serhiy Storchaka in branch 'default':
Issue #23718: Fixed parsing time in week 0 before Jan 1.  Original patch by
https://hg.python.org/cpython/rev/a7093386efaf

--
nosy: +python-dev

___
Python tracker 

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



[issue23718] strptime() can produce invalid date with negative year day

2016-03-05 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

LGTM. Alexander, what would you say?

--
stage: patch review -> commit review
versions: +Python 3.6 -Python 3.4

___
Python tracker 

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



[issue23718] strptime() can produce invalid date with negative year day

2016-03-05 Thread Serhiy Storchaka

Changes by Serhiy Storchaka :


--
assignee:  -> serhiy.storchaka
stage: test needed -> patch review

___
Python tracker 

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



[issue23718] strptime() can produce invalid date with negative year day

2016-02-16 Thread Tamás Bence Gedai

Tamás Bence Gedai added the comment:

I've added a new patch, it uses an other way to calculate the number of days in 
a given year. I updated the tests, so now it doesn't fail, I also added some 
extra test cases to test leap years.

--
Added file: http://bugs.python.org/file41936/julian_date_v1.patch

___
Python tracker 

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



[issue23718] strptime() can produce invalid date with negative year day

2016-02-16 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

Could you provide a patch? See also my comment on Rietveld (the "review" link).

--

___
Python tracker 

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



[issue23718] strptime() can produce invalid date with negative year day

2016-02-15 Thread Tamás Bence Gedai

Tamás Bence Gedai added the comment:

Actually there are already test cases, but they test for the wrong behaviour. 
The very same example is tested there, but the test gives the expected result, 
so tm_yday = -3. My implementation returns 362, which looks more reasonable. So 
currently with my patch the test fails.

See the tests here: 
https://github.com/python/cpython/blob/master/Lib/test/test_strptime.py#L523

--

___
Python tracker 

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



[issue23718] strptime() can produce invalid date with negative year day

2016-02-12 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

Could you please add tests?

--
stage:  -> test needed

___
Python tracker 

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



[issue23718] strptime() can produce invalid date with negative year day

2016-02-11 Thread Ned Deily

Changes by Ned Deily :


--
nosy: +iaslan

___
Python tracker 

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



[issue23718] strptime() can produce invalid date with negative year day

2016-02-09 Thread Tamás Bence Gedai

Tamás Bence Gedai added the comment:

I made a patch, that solves this issue.

The problem was that there wasn't any Sunday (%w = 0) on the 0th week in 2015. 
2015 started on Thursday, therefore the first Sunday was on 2014.12.28.

julian variable is used to set the tm_yday, which was a minus value, as the 
given date was not in the same year.

--
keywords: +patch
Added file: http://bugs.python.org/file41877/julian_date.patch

___
Python tracker 

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



[issue23718] strptime() can produce invalid date with negative year day

2016-02-06 Thread Tamás Bence Gedai

Tamás Bence Gedai added the comment:

It looks interesting, let me try to solve this. At first it seems odd that 
_calc_julian_from_U_or_W returns -2, I guess something is wrong around there.

--
nosy: +beng94

___
Python tracker 

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



[issue23718] strptime() can produce invalid date with negative year day

2015-03-20 Thread Serhiy Storchaka

New submission from Serhiy Storchaka:

strptime() can produce invalid time with negative year day when parse 
year-week-weekday set. Such time is rejected by strftime(), so 
strptime/strftime roundtrip doesn't work.

>>> t = time.strptime('2015 0 0', '%Y %U %w')
>>> t
time.struct_time(tm_year=2014, tm_mon=12, tm_mday=28, tm_hour=0, tm_min=0, 
tm_sec=0, tm_wday=6, tm_yday=-3, tm_isdst=-1)
>>> time.strftime('%Y %U %w', t)
Traceback (most recent call last):
  File "", line 1, in 
ValueError: day of year out of range

--
components: Library (Lib)
messages: 238648
nosy: belopolsky, lemburg, serhiy.storchaka
priority: normal
severity: normal
status: open
title: strptime() can produce invalid date with negative year day
type: behavior
versions: Python 2.7, Python 3.4, Python 3.5

___
Python tracker 

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