summaryrefslogtreecommitdiffstats
path: root/Objects/unicodeobject.c
diff options
context:
space:
mode:
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>2021-05-20 00:37:49 (GMT)
committerGitHub <noreply@github.com>2021-05-20 00:37:49 (GMT)
commitc87b81dcb2c22b6d151da39a0f65d5db304f59a8 (patch)
tree2b851e004671e5de35133a45f9b8d902480d8a66 /Objects/unicodeobject.c
parentdc6526dfa2da8e7d451c3b0f0965fd974436f3d5 (diff)
downloadcpython-c87b81dcb2c22b6d151da39a0f65d5db304f59a8.zip
cpython-c87b81dcb2c22b6d151da39a0f65d5db304f59a8.tar.gz
cpython-c87b81dcb2c22b6d151da39a0f65d5db304f59a8.tar.bz2
bpo-43295: Fix error handling of datetime.strptime format string '%z' (GH-24627) (#25695)
Previously, `datetime.strptime` would match `'z'` with the format string `'%z'` (for UTC offsets), throwing an `IndexError` by erroneously trying to parse `'z'` as a timestamp. As a special case, `'%z'` matches the string `'Z'` which is equivalent to the offset `'+00:00'`, however this behavior is not defined for lowercase `'z'`. This change ensures a `ValueError` is thrown when encountering the original example, as follows: ``` >>> from datetime import datetime >>> datetime.strptime('z', '%z') ValueError: time data 'z' does not match format '%z' ``` Automerge-Triggered-By: GH:pganssle (cherry picked from commit 04f6fbb6969e9860783b9ab4dc24b6fe3c6dab8d) Co-authored-by: Noor Michael <nsmichael31@gmail.com> Co-authored-by: Noor Michael <nsmichael31@gmail.com>
Diffstat (limited to 'Objects/unicodeobject.c')
0 files changed, 0 insertions, 0 deletions