Skip to content

Commit dd4c246

Browse files
jaracopganssle
andcommitted
Prefer resources namespace for context.
Co-authored-by: Paul Ganssle <1377457+pganssle@users.noreply.github.com>
1 parent e650eb2 commit dd4c246

2 files changed

Lines changed: 4 additions & 4 deletions

File tree

Lib/zoneinfo/_common.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@
22

33

44
def load_tzdata(key):
5-
from importlib.resources import files
5+
from importlib import resources
66

77
components = key.split("/")
88
package_name = ".".join(["tzdata.zoneinfo"] + components[:-1])
99
resource_name = components[-1]
1010

1111
try:
12-
return files(package_name).joinpath(resource_name).open('rb')
12+
return resources.files(package_name).joinpath(resource_name).open("rb")
1313
except (ImportError, FileNotFoundError, UnicodeEncodeError):
1414
# There are three types of exception that can be raised that all amount
1515
# to "we cannot find this key":

Lib/zoneinfo/_tzpath.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,14 +111,14 @@ def available_timezones():
111111
determine if a given file on the time zone search path is to open it
112112
and check for the "magic string" at the beginning.
113113
"""
114-
from importlib.resources import files
114+
from importlib import resources
115115

116116
valid_zones = set()
117117

118118
# Start with loading from the tzdata package if it exists: this has a
119119
# pre-assembled list of zones that only requires opening one file.
120120
try:
121-
with files("tzdata").joinpath("zones").open() as f:
121+
with resources.files("tzdata").joinpath("zones").open("r") as f:
122122
for zone in f:
123123
zone = zone.strip()
124124
if zone:

0 commit comments

Comments
 (0)