From b50be4adba7c7a6fc73520491a71fa5291d7d8fc Mon Sep 17 00:00:00 2001 From: Kiran Jonnalagadda Date: Wed, 3 Jan 2024 17:31:44 +0530 Subject: [PATCH] Resolve deprecation warning for importlib.resources.open_text --- funnel/views/helpers.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/funnel/views/helpers.py b/funnel/views/helpers.py index a3d5b825b..d003cc87f 100644 --- a/funnel/views/helpers.py +++ b/funnel/views/helpers.py @@ -54,9 +54,11 @@ # --- Timezone data -------------------------------------------------------------------- # Get all known timezones from zoneinfo and make a lowercased lookup table -valid_timezones = {tz.lower(): tz for tz in zoneinfo.available_timezones()} +valid_timezones = {_tz.lower(): _tz for _tz in zoneinfo.available_timezones()} # Get timezone aliases from tzinfo.zi and place them in the lookup table -with resources.open_text('tzdata.zoneinfo', 'tzdata.zi') as _tzdata: +with (resources.files('tzdata.zoneinfo') / 'tzdata.zi').open( + 'r', encoding='utf-8', errors='strict' +) as _tzdata: for _tzline in _tzdata.readlines(): if _tzline.startswith('L'): _tzlink, _tznew, _tzold = _tzline.strip().split()