diff --git a/oslo_serialization/msgpackutils.py b/oslo_serialization/msgpackutils.py index e71a123..eb9cb31 100644 --- a/oslo_serialization/msgpackutils.py +++ b/oslo_serialization/msgpackutils.py @@ -33,16 +33,10 @@ import functools import itertools import uuid from xmlrpc import client as xmlrpclib +import zoneinfo import msgpack -try: - import zoneinfo -except ImportError: - # zoneinfo is available in Python >= 3.9 - from pytz import timezone - zoneinfo = None - from oslo_utils import importutils netaddr = importutils.try_import("netaddr") @@ -243,11 +237,7 @@ class DateTimeHandler(object): 'microsecond': dt.microsecond, } if dt.tzinfo: - if zoneinfo: - tz = str(dt.tzinfo) - else: - tz = dt.tzinfo.tzname(None) - dct['tz'] = tz + dct['tz'] = str(dt.tzinfo) return dumps(dct, registry=self._registry) def deserialize(self, blob): @@ -274,12 +264,7 @@ class DateTimeHandler(object): second=dct['second'], microsecond=dct['microsecond']) if 'tz' in dct and dct['tz']: - if zoneinfo: - tzinfo = zoneinfo.ZoneInfo(dct['tz']) - dt = dt.replace(tzinfo=tzinfo) - else: - tzinfo = timezone(dct['tz']) - dt = tzinfo.localize(dt) + dt = dt.replace(tzinfo=zoneinfo.ZoneInfo(dct['tz'])) return dt diff --git a/releasenotes/notes/remove-py38-2c724027a885cf0b.yaml b/releasenotes/notes/remove-py38-2c724027a885cf0b.yaml new file mode 100644 index 0000000..0403163 --- /dev/null +++ b/releasenotes/notes/remove-py38-2c724027a885cf0b.yaml @@ -0,0 +1,5 @@ +--- +upgrade: + - | + Support for Python 3.8 has been removed. Now the minimum python version + supported is 3.9 . diff --git a/requirements.txt b/requirements.txt index e5a5cef..a59a4e8 100644 --- a/requirements.txt +++ b/requirements.txt @@ -6,5 +6,4 @@ pbr>=2.0.0 # Apache-2.0 msgpack>=0.5.2 # Apache-2.0 oslo.utils>=3.33.0 # Apache-2.0 -pytz>=2013.6;python_version<"3.9" # MIT -tzdata>=2022.4;python_version>="3.9" # MIT +tzdata>=2022.4 # MIT diff --git a/setup.cfg b/setup.cfg index 0b69db6..6c02e81 100644 --- a/setup.cfg +++ b/setup.cfg @@ -6,7 +6,7 @@ description_file = author = OpenStack author_email = openstack-discuss@lists.openstack.org home_page = https://docs.openstack.org/oslo.serialization/latest/ -python_requires = >=3.8 +python_requires = >=3.9 classifier = Environment :: OpenStack Intended Audience :: Information Technology @@ -15,7 +15,6 @@ classifier = Operating System :: POSIX :: Linux Programming Language :: Python Programming Language :: Python :: 3 - Programming Language :: Python :: 3.8 Programming Language :: Python :: 3.9 Programming Language :: Python :: 3.10 Programming Language :: Python :: 3.11