From de0eae12a6d5794a4c1e33052af6717707ce1fcc Mon Sep 17 00:00:00 2001 From: Thomas Sibley Date: Tue, 13 Sep 2022 13:15:21 -0700 Subject: [PATCH] =?UTF-8?q?Only=20use=20importlib.resources's=20new=20file?= =?UTF-8?q?s()=20/=20Traversable=20API=20on=20Python=20=E2=89=A53.11=20(#2?= =?UTF-8?q?04)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Using importlib.resource's files() API on 3.9 and 3.10 causes a TypeError on 3.9 and a ValueError on 3.10 when running under a third-party meta path importer (like PyOxidizer's OxidizedImporter) that doesn't support the relatively-new API. This is because the full adapter layer (importlib.resources._adapters) for the older importlib resources API doesn't exist until Python 3.11. The older resources API is now used by 3.7–3.10, as it was prior to the certifi 2022.06.15.1 release. This codepath has existed in certifi since April 2020 (3fc8fec). An alternative to this change would be testing the actual importer in use at runtime (e.g. certifi.__loader__) for files() support, but that seemed more complex than reverting to the previous codepath here. Resolves: https://github.com/certifi/python-certifi/issues/203 Related-to: https://github.com/certifi/python-certifi/pull/199 Related-to: https://github.com/certifi/python-certifi/pull/123 --- certifi/core.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/certifi/core.py b/certifi/core.py index cfd42ce3..de028981 100644 --- a/certifi/core.py +++ b/certifi/core.py @@ -7,7 +7,7 @@ import sys -if sys.version_info >= (3, 9): +if sys.version_info >= (3, 11): from importlib.resources import as_file, files