[issue43295] datetime.strptime emits IndexError on parsing 'z' as %z

2021-05-20 Thread STINNER Victor


STINNER Victor  added the comment:

It seems like the issue is fixed, I close it.

--
nosy: +vstinner
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



[issue43295] datetime.strptime emits IndexError on parsing 'z' as %z

2021-05-19 Thread Paul Ganssle


Paul Ganssle  added the comment:


New changeset c87b81dcb2c22b6d151da39a0f65d5db304f59a8 by Miss Islington (bot) 
in branch '3.9':
bpo-43295: Fix error handling of datetime.strptime format string '%z' 
(GH-24627) (#25695)
https://github.com/python/cpython/commit/c87b81dcb2c22b6d151da39a0f65d5db304f59a8


--

___
Python tracker 

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



[issue43295] datetime.strptime emits IndexError on parsing 'z' as %z

2021-04-28 Thread miss-islington


Change by miss-islington :


--
pull_requests: +24385
pull_request: https://github.com/python/cpython/pull/25695

___
Python tracker 

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



[issue43295] datetime.strptime emits IndexError on parsing 'z' as %z

2021-03-03 Thread miss-islington


Change by miss-islington :


--
pull_requests: +23501
pull_request: https://github.com/python/cpython/pull/24729

___
Python tracker 

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



[issue43295] datetime.strptime emits IndexError on parsing 'z' as %z

2021-03-03 Thread miss-islington


Change by miss-islington :


--
pull_requests: +23500
pull_request: https://github.com/python/cpython/pull/24728

___
Python tracker 

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



[issue43295] datetime.strptime emits IndexError on parsing 'z' as %z

2021-03-03 Thread miss-islington


miss-islington  added the comment:


New changeset 04f6fbb6969e9860783b9ab4dc24b6fe3c6dab8d by Noor Michael in 
branch 'master':
bpo-43295: Fix error handling of datetime.strptime format string '%z' (GH-24627)
https://github.com/python/cpython/commit/04f6fbb6969e9860783b9ab4dc24b6fe3c6dab8d


--
nosy: +miss-islington

___
Python tracker 

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



[issue43295] datetime.strptime emits IndexError on parsing 'z' as %z

2021-02-25 Thread itchyny


itchyny  added the comment:

@noormichael Thank you for submitting a patch, I confirmed the original issue 
is fixed. I'm ok this ticket is closed. Regarding the second issue, I learned 
it is a Turkish character (thanks!), but the error is same type so will not 
cause such a critical issue.

--

___
Python tracker 

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



[issue43295] datetime.strptime emits IndexError on parsing 'z' as %z

2021-02-22 Thread Noor Michael


Change by Noor Michael :


--
keywords: +patch
pull_requests: +23411
stage:  -> patch review
pull_request: https://github.com/python/cpython/pull/24627

___
Python tracker 

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



[issue43295] datetime.strptime emits IndexError on parsing 'z' as %z

2021-02-22 Thread Noor Michael

Noor Michael  added the comment:

I will address the original issue regarding '%z', but the second issue actually 
has to do with the Unicode representation of Turkish characters. In Turkish, 
the letter I ('\u0049') is a capital ı ('\u0131') and the letter İ ('\u0130') 
is a capital i ('\u0069'). In Python however, the lowercase of I is i, as in 
English.

>>> '\u0049'.lower()
'i'
>>> '\u0130'.lower()
'i̇'

We see that the lowercase forms of both I and İ are i, consistent with English 
in one case and Turkish in the other.

--
nosy: +noormichael

___
Python tracker 

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



[issue43295] datetime.strptime emits IndexError on parsing 'z' as %z

2021-02-22 Thread itchyny

itchyny  added the comment:

I noticed another unexpectedeffect of the IGNORECASE flag. It enables some 
non-ascii characters to match against the alphabets.

>>> from datetime import datetime
>>> datetime.strptime("Apr\u0130l", "%B")
Traceback (most recent call last):
  File "", line 1, in 
  File "/usr/local/lib/python3.9/_strptime.py", line 568, in _strptime_datetime
tt, fraction, gmtoff_fraction = _strptime(data_string, format)
  File "/usr/local/lib/python3.9/_strptime.py", line 391, in _strptime
month = locale_time.f_month.index(found_dict['B'].lower())
ValueError: 'apri̇l' is not in list

I expect time data does not match error. The ASCII flag will disable matching 
unexpected unicode characters.

--

___
Python tracker 

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



[issue43295] datetime.strptime emits IndexError on parsing 'z' as %z

2021-02-22 Thread Karthikeyan Singaravelan


Change by Karthikeyan Singaravelan :


--
nosy: +belopolsky, p-ganssle

___
Python tracker 

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



[issue43295] datetime.strptime emits IndexError on parsing 'z' as %z

2021-02-22 Thread itchyny


New submission from itchyny :

In Python 3.9.2, parsing 'z' (small letter) as '%z' (time zone offset) using 
datetime.strptime emits an IndexError.

>>> from datetime import datetime
>>> datetime.strptime('z', '%z')
Traceback (most recent call last):
  File "", line 1, in 
  File "/usr/local/lib/python3.9/_strptime.py", line 568, in _strptime_datetime
tt, fraction, gmtoff_fraction = _strptime(data_string, format)
  File "/usr/local/lib/python3.9/_strptime.py", line 453, in _strptime
if z[3] == ':':
IndexError: string index out of range

I expect ValueError (or some another useful error) as follows.
ValueError: time data 'z' does not match format '%z'

This is caused by compiling '%z' to a pattern containing 'Z' (for UTC) with the 
IGNORECASE flag and accessing z[3] without noticing 'z' is accepted by the 
regexp.

--
components: Library (Lib)
messages: 387514
nosy: itchyny
priority: normal
severity: normal
status: open
title: datetime.strptime emits IndexError on parsing 'z' as %z
type: behavior
versions: Python 3.9

___
Python tracker 

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