Skip to content

Commit 7f912f4

Browse files
committed
Use the importlib.resources backport on Python < 3.7
1 parent 4bf7d9e commit 7f912f4

File tree

2 files changed

+4
-7
lines changed

2 files changed

+4
-7
lines changed

certifi/core.py

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,9 @@
1111
try:
1212
from importlib.resources import read_text
1313
except ImportError:
14-
# This fallback will work for Python versions prior to 3.7 that lack the
15-
# importlib.resources module but relies on the existing `where` function
16-
# so won't address issues with environments like PyOxidizer that don't set
17-
# __file__ on modules.
18-
def read_text(_module, _path, encoding="ascii"):
19-
with open(where(), "r", encoding=encoding) as data:
20-
return data.read()
14+
# Use the backport of importlib.resources for versions of Python that
15+
# don't have importlib.resources
16+
from importlib_resources import read_text
2117

2218

2319
def where():

setup.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,4 +57,5 @@
5757
'Documentation': 'https://certifiio.readthedocs.io/en/latest/',
5858
'Source': 'https://github.com/certifi/python-certifi',
5959
},
60+
extras_require={":python_version < '3.7'": ["importlib-resources"],},
6061
)

0 commit comments

Comments
 (0)