summaryrefslogtreecommitdiffstats
path: root/Lib/_strptime.py
diff options
context:
space:
mode:
authorMario Corchero <mariocj89@gmail.com>2018-01-09 21:37:26 (GMT)
committerAlexander Belopolsky <abalkin@users.noreply.github.com>2018-01-09 21:37:26 (GMT)
commitf80c0ca13330112fe4d8018609c085ef556cb5bf (patch)
tree652f2e1c70cd8b3e003bee3e92ae8bf8c57b3801 /Lib/_strptime.py
parentd4864c61e3e27e337762dc45e504977299bd5b46 (diff)
downloadcpython-f80c0ca13330112fe4d8018609c085ef556cb5bf.zip
cpython-f80c0ca13330112fe4d8018609c085ef556cb5bf.tar.gz
cpython-f80c0ca13330112fe4d8018609c085ef556cb5bf.tar.bz2
Fix when parsing tz offsets microseconds shorter than 6 (#4781)
As the remainder was directly parsed as an int, strings like .600 were parsed as 600 microseconds rather than milliseconds.
Diffstat (limited to 'Lib/_strptime.py')
-rw-r--r--Lib/_strptime.py5
1 files changed, 4 insertions, 1 deletions
diff --git a/Lib/_strptime.py b/Lib/_strptime.py
index f5195af..1be0485 100644
--- a/Lib/_strptime.py
+++ b/Lib/_strptime.py
@@ -470,7 +470,10 @@ def _strptime(data_string, format="%a %b %d %H:%M:%S %Y"):
minutes = int(z[3:5])
seconds = int(z[5:7] or 0)
gmtoff = (hours * 60 * 60) + (minutes * 60) + seconds
- gmtoff_fraction = int(z[8:] or 0)
+ gmtoff_remainder = z[8:]
+ # Pad to always return microseconds.
+ gmtoff_remainder_padding = "0" * (6 - len(gmtoff_remainder))
+ gmtoff_fraction = int(gmtoff_remainder + gmtoff_remainder_padding)
if z.startswith("-"):
gmtoff = -gmtoff
gmtoff_fraction = -gmtoff_fraction