TypeError: can't compare offset-naive and offset-aware datetimes
Description of the problem
Attempting to Heartbeat a license hits an error due to data comparison where one side is timezone aware and the other is not.
Seems that the tests are not setting up the datetime objects correctly and so comparison works in the tests.
Steps to reproduce it
List the steps to reproduce the problem:
- Initialize the enforced or metered licensing client for use with a license key (see /docs/user_guide/code_examples/license_checkout_client_license_key.py)
- Checkout a license using a license key, without specifying a license consumer or first authenticating with an OpenID Provider
- Attempt to heartbeat using the lease id of the checked out license token
Expected behavior
HeartbeatTooEarlyError raised, or if enough time has elapsed, the heartbeat succeeds
Behavior detected
TypeError raised
Relevant logs and/or screenshots
tenduke_scale/license_checkout/license_checkout_client.py:579: in _raise_if_heartbeat_too_early
if any(
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
.0 = <list_iterator object at 0x7f5bca49b790>
if any(
token
for token in tokens
> if token.lease_id in old_lease_ids and token.heartbeat_not_before > datetime.datetime.now(datetime.timezone.utc)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
):
E TypeError: can't compare offset-naive and offset-aware datetimes
Environment
Testing on Fedora with tenduke-scale version 2.2.0
Workarounds
None identified