Skip to content

Commit a7ac22a

Browse files
authored
Prevent exception on import affecting Python 3.6.0-3.6.4 (#12030)
1 parent 23cfa89 commit a7ac22a

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

sdk/identity/azure-identity/CHANGELOG.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
# Release History
22

3-
## 1.4.0b5 (Unreleased)
3+
## 1.4.0b5 (2020-06-12)
4+
- Prevent an error on importing `AzureCliCredential` on Windows caused by a bug
5+
in old versions of Python 3.6 (this bug was fixed in Python 3.6.5).
6+
([#12014](https://github.com/Azure/azure-sdk-for-python/issues/12014))
47
- `SharedTokenCacheCredential.get_token` raises `ValueError` instead of
58
`ClientAuthenticationError` when called with no scopes.
69
([#11553](https://github.com/Azure/azure-sdk-for-python/issues/11553))

sdk/identity/azure-identity/azure/identity/_credentials/azure_cli.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,6 @@
2626
COMMAND_LINE = "az account get-access-token --output json --resource {}"
2727
NOT_LOGGED_IN = "Please run 'az login' to set up an account"
2828

29-
# CLI's "expiresOn" is naive, so we use this naive datetime for the epoch to calculate expires_on in UTC
30-
EPOCH = datetime.fromtimestamp(0)
31-
3229

3330
class AzureCliCredential(object):
3431
"""Authenticates by requesting a token from the Azure CLI.
@@ -74,8 +71,8 @@ def parse_token(output):
7471
token = json.loads(output)
7572
parsed_expires_on = datetime.strptime(token["expiresOn"], "%Y-%m-%d %H:%M:%S.%f")
7673

77-
# calculate seconds since the epoch; parsed_expires_on and EPOCH are naive
78-
expires_on = (parsed_expires_on - EPOCH).total_seconds()
74+
# calculate seconds since the epoch; parsed_expires_on is naive
75+
expires_on = (parsed_expires_on - datetime.fromtimestamp(0)).total_seconds()
7976

8077
return AccessToken(token["accessToken"], int(expires_on))
8178
except (KeyError, ValueError):

0 commit comments

Comments
 (0)