SAML-Toolkits / python3-saml

MIT License
670 stars 302 forks source link

Cannot generate_metadata_xml in Python 3.12 #409

Open jlgonzalez-martinez opened 2 months ago

jlgonzalez-martinez commented 2 months ago

Using Python 3.12 fails to generate_metadata_xml with a DeprecationWarning:

duration = 'P10D', timestamp = None

@staticmethod
def parse_duration(duration, timestamp=None):
    """
    Interprets a ISO8601 duration value relative to a given timestamp.

    :param duration: The duration, as a string.
    :type: string

    :param timestamp: The unix timestamp we should apply the duration to.
                      Optional, default to the current time.
    :type: string

    :return: The new timestamp, after the duration is applied.
    :rtype: int
    """
    assert isinstance(duration, compat.str_type)
    assert timestamp is None or isinstance(timestamp, int)

    timedelta = duration_parser(duration)
    if timestamp is None:
       data = datetime.utcnow() + timedelta

E DeprecationWarning: datetime.datetime.utcnow() is deprecated and scheduled for removal in a future version. Use timezone-aware objects to represent datetimes in UTC: datetime.datetime.now(datetime.UTC).

The issue is in the parse_duration_method in the OneLogin_Saml2_Utils class.