-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Remove the python-dateutil dependency #3715
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
miketheman
wants to merge
2,449
commits into
boto:develop
Choose a base branch
from
miketheman:remove-dateutil
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
2449 commits
Select commit
Hold shift + click to select a range
3a15ff5
Merge branch 'release-1.38.35'
aws-sdk-python-automation 3e3d9b8
Merge branch 'release-1.38.36'
aws-sdk-python-automation 1c572cd
Merge branch 'release-1.38.37'
aws-sdk-python-automation f23a421
Merge branch 'release-1.38.38'
aws-sdk-python-automation c40e2b3
Merge branch 'release-1.38.39'
aws-sdk-python-automation 1b5c96f
Merge branch 'release-1.38.40'
aws-sdk-python-automation 7699cd4
Merge branch 'release-1.38.41'
aws-sdk-python-automation 3ff0f3d
Merge branch 'release-1.38.42'
aws-sdk-python-automation 863c862
Merge branch 'release-1.38.43'
aws-sdk-python-automation 308ad25
Merge branch 'release-1.38.44'
aws-sdk-python-automation f4773c5
Merge branch 'release-1.38.45'
aws-sdk-python-automation e3970ab
Merge branch 'release-1.38.46'
aws-sdk-python-automation 9c42373
Merge branch 'release-1.39.0'
aws-sdk-python-automation d722eb5
Merge branch 'release-1.39.1'
aws-sdk-python-automation 0eef902
Merge branch 'release-1.39.2'
aws-sdk-python-automation b123641
Merge branch 'release-1.39.3'
aws-sdk-python-automation 040eab8
Merge branch 'release-1.39.4'
aws-sdk-python-automation 5db0907
Merge branch 'release-1.39.5'
aws-sdk-python-automation 828533b
Merge branch 'release-1.39.6'
aws-sdk-python-automation 4920825
Merge branch 'release-1.39.7'
aws-sdk-python-automation e4a87a9
Merge branch 'release-1.39.8'
aws-sdk-python-automation 67b8999
Merge branch 'release-1.39.9'
aws-sdk-python-automation df1603e
Merge branch 'release-1.39.10'
aws-sdk-python-automation 52eff0d
Merge branch 'release-1.39.11'
aws-sdk-python-automation b3ec877
Merge branch 'release-1.39.12'
aws-sdk-python-automation 5e39d48
Merge branch 'release-1.39.13'
aws-sdk-python-automation 400edf2
Merge branch 'release-1.39.14'
aws-sdk-python-automation 071aebf
Merge branch 'release-1.39.15'
aws-sdk-python-automation 4239a1d
Merge branch 'release-1.39.16'
aws-sdk-python-automation 3254807
Merge branch 'release-1.39.17'
aws-sdk-python-automation a3bbf61
Merge branch 'release-1.40.0'
aws-sdk-python-automation 5fed6e5
Merge branch 'release-1.40.1'
aws-sdk-python-automation 98c9921
Merge branch 'release-1.40.2'
aws-sdk-python-automation 21afbfc
Merge branch 'release-1.40.3'
aws-sdk-python-automation 3594ee3
Merge branch 'release-1.40.4'
aws-sdk-python-automation 8a1acfd
Merge branch 'release-1.40.5'
aws-sdk-python-automation 63db11e
Merge branch 'release-1.40.6'
aws-sdk-python-automation 9e97196
Merge branch 'release-1.40.7'
aws-sdk-python-automation c8dd2be
Merge branch 'release-1.40.8'
aws-sdk-python-automation 7de1c71
Merge branch 'release-1.40.9'
aws-sdk-python-automation d899e22
Merge branch 'release-1.40.10'
aws-sdk-python-automation 35c8e8c
Merge branch 'release-1.40.11'
aws-sdk-python-automation 4da9b03
Merge branch 'release-1.40.12'
aws-sdk-python-automation 5c7cdd3
Merge branch 'release-1.40.13'
aws-sdk-python-automation f0b3e82
Merge branch 'release-1.40.14'
aws-sdk-python-automation 2d3b8f9
Merge branch 'release-1.40.15'
aws-sdk-python-automation 56a479a
Merge branch 'release-1.40.16'
aws-sdk-python-automation b1b06fe
Merge branch 'release-1.40.17'
aws-sdk-python-automation d409c9b
Merge branch 'release-1.40.18'
aws-sdk-python-automation de0e6a2
Merge branch 'release-1.40.19'
aws-sdk-python-automation c870f2c
Merge branch 'release-1.40.20'
aws-sdk-python-automation 0195f4a
Merge branch 'release-1.40.21'
aws-sdk-python-automation 8e13eda
Merge branch 'release-1.40.22'
aws-sdk-python-automation cbb2c9c
Merge branch 'release-1.40.23'
aws-sdk-python-automation 6bb189b
Merge branch 'release-1.40.24'
aws-sdk-python-automation 27db68b
Merge branch 'release-1.40.25'
aws-sdk-python-automation 9e8135a
Merge branch 'release-1.40.26'
aws-sdk-python-automation 1449771
Merge branch 'release-1.40.27'
aws-sdk-python-automation 95c2082
Merge branch 'release-1.40.28'
aws-sdk-python-automation 160fbaa
Merge branch 'release-1.40.29'
aws-sdk-python-automation dcd9991
Merge branch 'release-1.40.30'
aws-sdk-python-automation b66e8cf
Merge branch 'release-1.40.31'
aws-sdk-python-automation 44da1ad
Merge branch 'release-1.40.32'
aws-sdk-python-automation 24b0557
Merge branch 'release-1.40.33'
aws-sdk-python-automation c198e2c
Merge branch 'release-1.40.34'
aws-sdk-python-automation 331de65
Merge branch 'release-1.40.35'
aws-sdk-python-automation 28c3ae2
Merge branch 'release-1.40.36'
aws-sdk-python-automation 66d1f13
Merge branch 'release-1.40.37'
aws-sdk-python-automation 5d252f6
Merge branch 'release-1.40.38'
aws-sdk-python-automation 52dfbc2
Merge branch 'release-1.40.39'
aws-sdk-python-automation dc5ce63
Merge branch 'release-1.40.40'
aws-sdk-python-automation 9f435e4
Merge branch 'release-1.40.41'
aws-sdk-python-automation 74bd169
Merge branch 'release-1.40.42'
aws-sdk-python-automation 8a00219
Merge branch 'release-1.40.43'
aws-sdk-python-automation 426d4b3
Merge branch 'release-1.40.44'
aws-sdk-python-automation 5ce2bc5
Merge branch 'release-1.40.45'
aws-sdk-python-automation 3784dde
Merge branch 'release-1.40.46'
aws-sdk-python-automation 2ca91ad
Merge branch 'release-1.40.47'
aws-sdk-python-automation 9fbad5a
Merge branch 'release-1.40.48'
aws-sdk-python-automation dc8eb09
Merge branch 'release-1.40.49'
aws-sdk-python-automation c2ea08e
Merge branch 'release-1.40.50'
aws-sdk-python-automation d275003
Merge branch 'release-1.40.51'
aws-sdk-python-automation 5630f31
Merge branch 'release-1.40.52'
aws-sdk-python-automation a0f9cb4
Merge branch 'release-1.40.53'
aws-sdk-python-automation 03982ad
Merge branch 'release-1.40.54'
aws-sdk-python-automation 9bc6c28
Merge branch 'release-1.40.55'
aws-sdk-python-automation abebe36
Merge branch 'release-1.40.56'
aws-sdk-python-automation be7e4d9
Merge branch 'release-1.40.57'
aws-sdk-python-automation 6bedfc1
Merge branch 'release-1.40.58'
aws-sdk-python-automation 665b7c4
Merge branch 'release-1.40.59'
aws-sdk-python-automation 9636e61
Merge branch 'release-1.40.60'
aws-sdk-python-automation 28ff8c7
Merge branch 'release-1.40.61'
aws-sdk-python-automation 68e4960
Merge branch 'release-1.40.62'
aws-sdk-python-automation cf26740
Merge branch 'release-1.40.63'
aws-sdk-python-automation 11d0051
Merge branch 'release-1.40.64'
aws-sdk-python-automation 7b47532
Merge branch 'release-1.40.65'
aws-sdk-python-automation 65bc39a
Merge branch 'release-1.40.66'
aws-sdk-python-automation 51ab00a
Merge branch 'release-1.40.67'
aws-sdk-python-automation c6c184d
Merge branch 'release-1.40.68'
aws-sdk-python-automation f420535
Merge branch 'release-1.40.69'
aws-sdk-python-automation 30b7f49
Merge branch 'release-1.40.70'
aws-sdk-python-automation c5893aa
Merge branch 'release-1.40.71'
aws-sdk-python-automation 552124e
Merge branch 'release-1.40.72'
aws-sdk-python-automation f95e535
Merge branch 'release-1.40.73'
aws-sdk-python-automation 8dfa4fe
Merge branch 'release-1.40.74'
aws-sdk-python-automation e325f9e
Merge branch 'release-1.40.75'
aws-sdk-python-automation b345fd6
Merge branch 'release-1.40.76'
aws-sdk-python-automation afda316
Merge branch 'release-1.41.0'
aws-sdk-python-automation d67dd73
Merge branch 'release-1.41.1'
aws-sdk-python-automation b651756
Merge branch 'release-1.41.2'
aws-sdk-python-automation 154efda
Merge branch 'release-1.41.3'
aws-sdk-python-automation 6b9e761
Merge branch 'release-1.41.4'
aws-sdk-python-automation 9fda087
Merge branch 'release-1.41.5'
aws-sdk-python-automation 5f17732
Merge branch 'release-1.41.6'
aws-sdk-python-automation dd227da
Merge branch 'release-1.42.1'
aws-sdk-python-automation b287796
Merge branch 'release-1.42.2'
aws-sdk-python-automation b71ae76
Merge branch 'release-1.42.3'
aws-sdk-python-automation 05bdcec
Merge branch 'release-1.42.4'
aws-sdk-python-automation 23cd566
Merge branch 'release-1.42.5'
aws-sdk-python-automation 4dbcdb6
Merge branch 'release-1.42.6'
aws-sdk-python-automation a9d520e
Merge branch 'release-1.42.7'
aws-sdk-python-automation 517a891
Merge branch 'release-1.42.8'
aws-sdk-python-automation fefef10
Merge branch 'release-1.42.9'
aws-sdk-python-automation ab29acf
Merge branch 'release-1.42.10'
aws-sdk-python-automation deae31c
Merge branch 'release-1.42.11'
aws-sdk-python-automation 76d67dd
Merge branch 'release-1.42.12'
aws-sdk-python-automation d7832ca
Merge branch 'release-1.42.13'
aws-sdk-python-automation 970b997
Merge branch 'release-1.42.14'
aws-sdk-python-automation dafce6f
Merge branch 'release-1.42.15'
aws-sdk-python-automation d8a1f97
Merge branch 'release-1.42.16'
aws-sdk-python-automation d67a9c4
Merge branch 'release-1.42.17'
aws-sdk-python-automation c8f4f63
Merge branch 'release-1.42.18'
aws-sdk-python-automation 5e019fa
Merge branch 'release-1.42.19'
aws-sdk-python-automation b8ff014
Merge branch 'release-1.42.20'
aws-sdk-python-automation 00fb87d
Merge branch 'release-1.42.21'
aws-sdk-python-automation 6c64e2c
Merge branch 'release-1.42.22'
aws-sdk-python-automation f6e3237
Merge branch 'release-1.42.23'
aws-sdk-python-automation 331cd66
Merge branch 'release-1.42.24'
aws-sdk-python-automation a35f376
Merge branch 'release-1.42.25'
aws-sdk-python-automation 526feac
Merge branch 'release-1.42.26'
aws-sdk-python-automation c7688c2
Merge branch 'release-1.42.27'
aws-sdk-python-automation 10cfc3a
Merge branch 'release-1.42.28'
aws-sdk-python-automation b64df2f
Merge branch 'release-1.42.29'
aws-sdk-python-automation 279b5b6
Merge branch 'release-1.42.30'
aws-sdk-python-automation c365557
Merge branch 'release-1.42.31'
aws-sdk-python-automation 3549e01
Merge branch 'release-1.42.32'
aws-sdk-python-automation b9ed58f
Merge branch 'release-1.42.33'
aws-sdk-python-automation d52e6ce
Merge branch 'release-1.42.34'
aws-sdk-python-automation bd0f61b
Merge branch 'release-1.42.35'
aws-sdk-python-automation 6d639f1
Merge branch 'release-1.42.36'
aws-sdk-python-automation 51455c2
Merge branch 'release-1.42.37'
aws-sdk-python-automation 0b51aea
Merge branch 'release-1.42.38'
aws-sdk-python-automation 26a688f
Merge branch 'release-1.42.39'
aws-sdk-python-automation 12d57f6
Merge branch 'release-1.42.40'
aws-sdk-python-automation 104e8ef
Merge branch 'release-1.42.41'
aws-sdk-python-automation b02439f
Merge branch 'release-1.42.42'
aws-sdk-python-automation 7c51a6d
Merge branch 'release-1.42.43'
aws-sdk-python-automation 77d291c
Merge branch 'release-1.42.44'
aws-sdk-python-automation d7d1a54
Merge branch 'release-1.42.45'
aws-sdk-python-automation 56b6d8c
Merge branch 'release-1.42.46'
aws-sdk-python-automation b182891
Merge branch 'release-1.42.47'
aws-sdk-python-automation 504b9a3
Merge branch 'release-1.42.48'
aws-sdk-python-automation 986db6c
Merge branch 'release-1.42.49'
aws-sdk-python-automation 11d0644
Merge branch 'release-1.42.50'
aws-sdk-python-automation 9d9af73
Merge branch 'release-1.42.51'
aws-sdk-python-automation 7cdfafa
Merge branch 'release-1.42.52'
aws-sdk-python-automation de615b8
Merge branch 'release-1.42.53'
aws-sdk-python-automation b4cc476
Merge branch 'release-1.42.54'
aws-sdk-python-automation 59176e1
Merge branch 'release-1.42.55'
aws-sdk-python-automation b6a65cb
Merge branch 'release-1.42.56'
aws-sdk-python-automation 86d9ec3
Merge branch 'release-1.42.57'
aws-sdk-python-automation f76046b
Merge branch 'release-1.42.58'
aws-sdk-python-automation c204bb1
Merge branch 'release-1.42.59'
aws-sdk-python-automation ec3b3e3
Merge branch 'release-1.42.60'
aws-sdk-python-automation 91f8bd7
Merge branch 'release-1.42.61'
aws-sdk-python-automation d66a4ce
Merge branch 'release-1.42.62'
aws-sdk-python-automation 053383c
Merge branch 'release-1.42.63'
aws-sdk-python-automation dc6194d
Merge branch 'release-1.42.64'
aws-sdk-python-automation 9ed5c2f
Merge branch 'release-1.42.65'
aws-sdk-python-automation 537c33e
Merge branch 'release-1.42.66'
aws-sdk-python-automation 946ffef
Merge branch 'release-1.42.67'
aws-sdk-python-automation 7a0027d
Merge branch 'release-1.42.68'
aws-sdk-python-automation dac0d1b
Merge branch 'release-1.42.69'
aws-sdk-python-automation bda7d02
Merge branch 'release-1.42.70'
aws-sdk-python-automation 0fa4e01
Merge branch 'release-1.42.71'
aws-sdk-python-automation 9a8fcce
Merge branch 'release-1.42.72'
aws-sdk-python-automation 08d494a
Merge branch 'release-1.42.73'
aws-sdk-python-automation b18efcc
Merge branch 'release-1.42.74'
aws-sdk-python-automation cfa4484
Merge branch 'release-1.42.75'
aws-sdk-python-automation eded7ce
Merge branch 'release-1.42.76'
aws-sdk-python-automation a42e6cf
Merge branch 'release-1.42.77'
aws-sdk-python-automation 08282cd
Merge branch 'release-1.42.78'
aws-sdk-python-automation 99ac865
Merge branch 'release-1.42.79'
aws-sdk-python-automation 080f45a
Merge branch 'release-1.42.80'
aws-sdk-python-automation 56a6ef8
Merge branch 'release-1.42.81'
aws-sdk-python-automation d3423de
Merge branch 'release-1.42.82'
aws-sdk-python-automation da27682
Merge branch 'release-1.42.83'
aws-sdk-python-automation 0bb499c
Merge branch 'release-1.42.84'
aws-sdk-python-automation 0db1752
Merge branch 'release-1.42.85'
aws-sdk-python-automation d831a06
Merge branch 'release-1.42.86'
aws-sdk-python-automation 215aec9
Merge branch 'release-1.42.87'
aws-sdk-python-automation 974e23f
Merge branch 'release-1.42.88'
aws-sdk-python-automation 9b76a62
Merge branch 'release-1.42.89'
aws-sdk-python-automation 8cde7ca
Merge branch 'release-1.42.90'
aws-sdk-python-automation 2da0705
Merge branch 'release-1.42.91'
aws-sdk-python-automation 20bd7a8
Merge branch 'release-1.42.92'
aws-sdk-python-automation fd8b312
Merge branch 'release-1.42.93'
aws-sdk-python-automation 9e0cd69
Merge branch 'release-1.42.94'
aws-sdk-python-automation 0aaee4d
Merge branch 'release-1.42.95'
aws-sdk-python-automation 435c9a3
Merge branch 'release-1.42.96'
aws-sdk-python-automation 9131bfc
Merge branch 'release-1.42.97'
aws-sdk-python-automation 05dafea
Merge branch 'release-1.43.0'
aws-sdk-python-automation 7084f04
Merge branch 'release-1.43.1'
aws-sdk-python-automation 6338dda
Merge branch 'release-1.43.2'
aws-sdk-python-automation f687cc7
Merge branch 'release-1.43.3'
aws-sdk-python-automation 2d415ea
Merge branch 'release-1.43.4'
aws-sdk-python-automation 7068f3e
Merge branch 'release-1.43.5'
aws-sdk-python-automation 4fa2154
Merge branch 'release-1.43.6'
aws-sdk-python-automation 74501ce
Merge branch 'release-1.43.7'
aws-sdk-python-automation bd1fb23
Merge branch 'release-1.43.8'
aws-sdk-python-automation 994b6d7
Merge branch 'release-1.43.9'
aws-sdk-python-automation faaa928
Merge branch 'release-1.43.10'
aws-sdk-python-automation 7f1dfc4
Merge branch 'release-1.43.11'
aws-sdk-python-automation 2d725f1
Merge branch 'release-1.43.12'
aws-sdk-python-automation 8bd61f7
Merge branch 'release-1.43.13'
aws-sdk-python-automation f23ff3b
Merge branch 'release-1.43.14'
aws-sdk-python-automation e7ba6b5
Merge branch 'release-1.43.15'
aws-sdk-python-automation 0a7d573
Merge branch 'release-1.43.16'
aws-sdk-python-automation 364f281
Merge branch 'release-1.43.17'
aws-sdk-python-automation 96246a7
Merge branch 'release-1.43.18'
aws-sdk-python-automation 8fdb47d
Merge branch 'release-1.43.19'
aws-sdk-python-automation 250cdcc
Merge branch 'release-1.43.20'
aws-sdk-python-automation 016da4b
Merge branch 'release-1.43.21'
aws-sdk-python-automation d1b7760
Merge branch 'release-1.43.22'
aws-sdk-python-automation fb8102b
Merge branch 'release-1.43.23'
aws-sdk-python-automation f949c25
Merge branch 'release-1.43.24'
aws-sdk-python-automation a09b615
Merge branch 'release-1.43.25'
aws-sdk-python-automation 6ed7218
Merge branch 'release-1.43.26'
aws-sdk-python-automation 0ffcb23
Merge branch 'release-1.43.27'
aws-sdk-python-automation b3f27bf
Merge branch 'release-1.43.28'
aws-sdk-python-automation 77da2d8
Merge branch 'release-1.43.29'
aws-sdk-python-automation c3a7b1c
Merge branch 'release-1.43.30'
aws-sdk-python-automation 6eba456
test: replace dateutil.tz.tzlocal
miketheman 99b9a80
refactor: replace dateutil.tz.tzlocal
miketheman ddec238
test: replace usages of dateutil.tz.tzutc
miketheman c70be79
refactor: replace dateutil.tz.tzutc with stdlib
miketheman 5adb04d
test: use consistent datetime fixtures in s3express
miketheman 99cd4f1
test: replace dateutil.parser with stdlib
miketheman 91e8878
refactor: replace dateutil.parser with stdlib
miketheman aead776
chore(deps): remove unused python-dateutil
miketheman File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -14,6 +14,7 @@ | |
| import binascii | ||
| import datetime | ||
| import email.message | ||
| import email.utils | ||
| import functools | ||
| import hashlib | ||
| import io | ||
|
|
@@ -31,8 +32,6 @@ | |
| from pathlib import Path | ||
| from urllib.request import getproxies, proxy_bypass | ||
|
|
||
| import dateutil.parser | ||
| from dateutil.tz import tzutc | ||
| from urllib3.exceptions import LocationParseError | ||
|
|
||
| import botocore | ||
|
|
@@ -54,6 +53,7 @@ | |
| UNSAFE_URL_CHARS, | ||
| ZONE_ID_PAT, # noqa: F401 | ||
| OrderedDict, | ||
| _normalize_iso8601_for_python_310, | ||
| get_current_datetime, | ||
| get_md5, | ||
| get_tzinfo_options, | ||
|
|
@@ -948,31 +948,55 @@ def _epoch_seconds_to_datetime(value, tzinfo): | |
| :type value: float or int | ||
| :param value: The Unix timestamps as number. | ||
|
|
||
| :type tzinfo: callable | ||
| :param tzinfo: A ``datetime.tzinfo`` class or compatible callable. | ||
| :type tzinfo: datetime.tzinfo | ||
| :param tzinfo: A ``datetime.tzinfo`` instance. | ||
| """ | ||
| epoch_zero = datetime.datetime(1970, 1, 1, 0, 0, 0, tzinfo=tzutc()) | ||
| epoch_zero_localized = epoch_zero.astimezone(tzinfo()) | ||
| epoch_zero = datetime.datetime( | ||
| 1970, 1, 1, 0, 0, 0, tzinfo=datetime.timezone.utc | ||
| ) | ||
| epoch_zero_localized = epoch_zero.astimezone(tzinfo) | ||
| return epoch_zero_localized + datetime.timedelta(seconds=value) | ||
|
|
||
|
|
||
| def _parse_timestamp_with_tzinfo(value, tzinfo): | ||
| """Parse timestamp with pluggable tzinfo options.""" | ||
| if isinstance(value, (int, float)): | ||
| # Possibly an epoch time. | ||
| return datetime.datetime.fromtimestamp(value, tzinfo()) | ||
| return datetime.datetime.fromtimestamp(value, tzinfo) | ||
| else: | ||
| try: | ||
| return datetime.datetime.fromtimestamp(float(value), tzinfo()) | ||
| return datetime.datetime.fromtimestamp(float(value), tzinfo) | ||
| except (TypeError, ValueError): | ||
| pass | ||
| if not isinstance(value, str): | ||
| raise ValueError(f'Invalid timestamp "{value}"') | ||
| # Non-numeric string. Try ISO 8601 first (the common AWS shape), then | ||
| # RFC 2822 / HTTP-date / asctime via email.utils, then a couple of | ||
| # lenient strptime fallbacks for legacy HTTP Expires-header shapes | ||
| # seen in the wild. | ||
| iso_value = _normalize_iso8601_for_python_310(value) | ||
| try: | ||
| return datetime.datetime.fromisoformat(iso_value) | ||
| except (TypeError, ValueError): | ||
| pass | ||
| # A handful of AWS shared examples have a malformed ISO hour like | ||
| # "T016:15:21" — collapse the leading zero and retry. | ||
| fixed_iso = re.sub(r"T0(\d{2}):", r"T\1:", iso_value, count=1) | ||
| if fixed_iso != iso_value: | ||
| try: | ||
| return datetime.datetime.fromisoformat(fixed_iso) | ||
| except (TypeError, ValueError): | ||
| pass | ||
| try: | ||
| # In certain cases, a timestamp marked with GMT can be parsed into a | ||
| # different time zone, so here we provide a context which will | ||
| # enforce that GMT == UTC. | ||
| return dateutil.parser.parse(value, tzinfos={'GMT': tzutc()}) | ||
| except (TypeError, ValueError) as e: | ||
| raise ValueError(f'Invalid timestamp "{value}": {e}') | ||
| return email.utils.parsedate_to_datetime(value) | ||
| except (TypeError, ValueError): | ||
| pass | ||
| for fmt in ("%m/%d/%Y", "%d %b %Y"): | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [Question] This catches a few non-Smithy shapes but rejects others that dateutil handled. For example, it accepts 06/25/2026 but not 2026/06/25, and 15 Jan 2026 but not January 15, 2026. Why these two formats specifically? |
||
| try: | ||
| return datetime.datetime.strptime(value.title(), fmt) | ||
| except ValueError: | ||
| continue | ||
| raise ValueError(f'Invalid timestamp "{value}"') | ||
|
|
||
|
|
||
| def parse_timestamp(value): | ||
|
|
@@ -994,7 +1018,7 @@ def parse_timestamp(value): | |
| except (OSError, OverflowError) as e: | ||
| logger.debug( | ||
| 'Unable to parse timestamp with "%s" timezone info.', | ||
| tzinfo.__name__, | ||
| tzinfo, | ||
| exc_info=e, | ||
| ) | ||
| # For numeric values attempt fallback to using fromtimestamp-free method. | ||
|
|
@@ -1015,7 +1039,7 @@ def parse_timestamp(value): | |
| logger.debug( | ||
| 'Unable to parse timestamp using fallback method with "%s" ' | ||
| 'timezone info.', | ||
| tzinfo.__name__, | ||
| tzinfo, | ||
| exc_info=e, | ||
| ) | ||
| raise RuntimeError( | ||
|
|
@@ -1062,9 +1086,9 @@ def parse_to_aware_datetime(value): | |
| # we should use the local time. However, to restore backwards | ||
| # compat, the previous behavior was to assume UTC, which is | ||
| # what we're going to do here. | ||
| datetime_obj = datetime_obj.replace(tzinfo=tzutc()) | ||
| datetime_obj = datetime_obj.replace(tzinfo=datetime.timezone.utc) | ||
| else: | ||
| datetime_obj = datetime_obj.astimezone(tzutc()) | ||
| datetime_obj = datetime_obj.astimezone(datetime.timezone.utc) | ||
| return datetime_obj | ||
|
|
||
|
|
||
|
|
@@ -1074,14 +1098,14 @@ def datetime2timestamp(dt, default_timezone=None): | |
| :type dt: datetime | ||
| :param dt: A datetime object to be converted into timestamp | ||
| :type default_timezone: tzinfo | ||
| :param default_timezone: If it is provided as None, we treat it as tzutc(). | ||
| :param default_timezone: If it is provided as None, we treat it as UTC. | ||
| But it is only used when dt is a naive datetime. | ||
| :returns: The timestamp | ||
| """ | ||
| epoch = datetime.datetime(1970, 1, 1) | ||
| if dt.tzinfo is None: | ||
| if default_timezone is None: | ||
| default_timezone = tzutc() | ||
| default_timezone = datetime.timezone.utc | ||
| dt = dt.replace(tzinfo=default_timezone) | ||
| d = dt.replace(tzinfo=None) - dt.utcoffset() - epoch | ||
| return d.total_seconds() | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[Discussion point]
Starting off with my biggest comment:
We have a specification for what accepted timestamp shapes are, so we should only ever need to accept those for parsing. This PR properly handles all officially supported datetime formats, so theoretically this is a fully safe change to make despite handling fewer formats than dateutil.
There are still a few places that I'm still concerned about breaking:
It's a bad thing that botocore is so permissive. We have seen AWS service teams test their service with other datetime formats against botocore and seen it work, then be surprised when the same datetime format broke the Java SDK. If we ever want to tighten up this behavior, we have to rip the bandaid off at some point or fully commit to supporting this forever.
One way we could make this a little more cautiously is to start by using this new code path first and emitting a warning when we have to fall back to the old one, then ripping out the legacy path in three months with a minor version bump. What do you think?