We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
importlib.resources
2 parents 95fe75d + b07d947 commit 6ee7e56Copy full SHA for 6ee7e56
1 file changed
src/pytz/__init__.py
@@ -95,6 +95,16 @@ def open_resource(name):
95
filename = os.path.join(os.path.dirname(__file__),
96
'zoneinfo', *name_parts)
97
if not os.path.exists(filename):
98
+ # pkg_resources is deprecated, try with importlib first
99
+ try:
100
+ from importlib.resources import files
101
+ except ImportError:
102
+ files = None
103
+
104
+ if files is not None:
105
+ # retrieve the zoneinfo file Path object and return its file handle
106
+ return files(__name__).joinpath('zoneinfo', *name_parts).open('rb')
107
108
# http://bugs.launchpad.net/bugs/383171 - we avoid using this
109
# unless absolutely necessary to help when a broken version of
110
# pkg_resources is installed.
0 commit comments