-
Notifications
You must be signed in to change notification settings - Fork 255
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
certifi 2022.6.15.1 broken on Python 3.9 and 3.10 under third-party importers like PyOxidizer #203
Comments
Thank you for the detailed and well thought out report. Unfortunately it fills me with exhaustion -- which isn't your fault. This package is trying to do the incredibly simple thing of taking a Anyhoo, that complaint aside: Your proposal (1) makes sense to me... but my question is, if we do that, who is going to complain that we broke something? It's impossible for me to reason about the backwards compatibility surfaces on any of this. |
I can sympathize! I'm also exhausted from tracing this all down and it derailing the work I actually wanted to be doing. Thank you for considering a fix here, and regardless of anything else, thank you for all your hard work making certifi a reliable module that (nearly all the time!) Just Works. I understand your hesitation to make a change, but I'd be hopeful that doing (1) wouldn't break anything for anyone given that
|
Makes sense to me. I'll let @Lukasa chime in, but based on this I think I'd personally approve a PR to change the version check to 3.11 |
I'm happy to follow (1). |
…n ≥3.11 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: certifi#203 Related-to: certifi#199 Related-to: certifi#123
…n ≥3.11 (#204) 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: #203 Related-to: #199 Related-to: #123
This sidesteps issues with the relatively-new files() / Traversable API of importlib.resources that is present in 3.9 and 3.10 but not supported by PyOxidizer's OxidizedImporter. It only supports the original importlib.resources API and importlib.resources doesn't implement a backwards compatibility layer/adapter until Python 3.11 (not yet released). By using 3.8, code which tests for the presence of the new API in importlib.resources or tests the Python version will not detect stdlib support for the new API and thus will generally fall back to the API supported by PyOxidizer. Related-to: <certifi/python-certifi#203>
This sidesteps issues with the relatively-new files() / Traversable API of importlib.resources that is present in 3.9 and 3.10 but not supported by PyOxidizer's OxidizedImporter. It only supports the original importlib.resources API and importlib.resources doesn't implement a backwards compatibility layer/adapter until Python 3.11 (not yet released). By using 3.8, code which tests for the presence of the new API in importlib.resources or tests the Python version will not detect stdlib support for the new API and thus will generally fall back to the API supported by PyOxidizer. Related-to: <certifi/python-certifi#203>
The recently landed Python 3.11 deprecation warning fix released in 2022.6.15.1 on 9 Sept 2022 causes certifi to throw a
ValueError
on Python 3.10 and aTypeError
on Python 3.9 when using an importer (like PyOxidizer'sOxidizedImporter
) that doesn't support the relatively-new "Traversable" /files()
importlib API. This is because the full adapter layer for the older importlib resources API doesn't exist until Python 3.11.On 3.10, the error is intentionally raised in the stdlib's
DegenerateFiles
class:https://github.com/python/cpython/blob/3.10/Lib/importlib/_adapters.py#L53-L54
because the "adapter" in 3.10 exists only to fail, it seems.
On 3.9, the error is because the stdlib's
files()
function assumes thatcertifi.__file__
(ascertifi.__spec__.origin
) is notNone
:https://github.com/python/cpython/blob/3.9/Lib/importlib/_common.py#L17-L18
Two separate possible solutions come to mind:
certifi.__loader__
in addition to the Python version. I'm not sure how to actually do this at the moment, but I assume it's possible.Option 1 certainly seems simpler to me.
The text was updated successfully, but these errors were encountered: