Skip to content
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

Importing urllib3.exceptions.SubjectAltNameWarning fails under 2.0.x #3015

Closed
cthart opened this issue May 4, 2023 · 5 comments
Closed

Importing urllib3.exceptions.SubjectAltNameWarning fails under 2.0.x #3015

cthart opened this issue May 4, 2023 · 5 comments

Comments

@cthart
Copy link

cthart commented May 4, 2023

Subject

from urllib3.exceptions import SubjectAltNameWarning

fails with

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: cannot import name 'SubjectAltNameWarning' from 'urllib3.exceptions' (/home/colin/venv/lib/python3.8/site-packages/urllib3/exceptions.py)

under urllib 2.0.2 (also under 2.0.1 and 2.0.0)

Can this exception no longer occur? There is no mention of it in the Changelog or Release descriptions. In addition, searching the repository commits for SubjectAltNameWarning doesn't yield any recent changes at all, so I'm stumped why this exception is no longer available, even when it is available under urllib3 1.26.15 with all other installed libraries the same.

Environment

Describe your environment.
At least, paste here the output of:

OS Linux-6.2.6-1-pve-x86_64-with-glibc2.29 (Ubuntu 20.04.6 LTS)
Python 3.8.10
urllib3 2.0.2

Steps to Reproduce

As above

Expected Behavior

Import should succeed, as it does under urllib3 1.26.15

Actual Behavior

Import fails with exception as above

@pquentin
Copy link
Member

pquentin commented May 4, 2023

Hello! And thank you for your report. Sorry that urllib3 2.0 broke your code. The reason the warning disappeared is that in urllib3 2.0 this is no longer a warning but an error: #2113

Can you please share what is your use case for importing the warning?

@cthart
Copy link
Author

cthart commented May 4, 2023

I'm trying to fix one of the libraries I'm using: https://github.com/hbldh/pybankid/blob/master/bankid/__init__.py

@cthart
Copy link
Author

cthart commented May 4, 2023

Pull request submitted for that library. hbldh/pybankid#48
This code works for with test and production certificates, so I'm hopeful this patch or a variant of it will be applied.
Closing this issue.

@pquentin
Copy link
Member

pquentin commented May 4, 2023

Thanks! Until I see a proper use case for declaring a fake SubjectAltNameWarning in 2.0, I'd like to avoid doing it: if you want your code to work at all under urllib3 2.0, this warning should not fire in 1.26.x. So I think the proper fix is always going to be to fix that warning and then remove the filter.

Also note that if you have outdated TLS certificates in your test suite, https://github.com/python-trio/trustme is your friend. :)

@cthart
Copy link
Author

cthart commented May 4, 2023

Yes, sorry if my last message was a bit cryptic: I'm not expecting a change to requests, but hopeful that just removing checks for this particular warning in the pybankid library will work for everyone. It works fine for me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants