Incompatibility with urllib3>=1.26 when using allow_net_connect=False
vphilippon opened this issue · 2 comments
Hello!
I stumbled upon an incompatibility when using allow_net_connect=False
with urllib3>=1.26
.
It boils down to this line in urllib3
:
https://github.com/urllib3/urllib3/blob/1.26.2/src/urllib3/connection.py#L430
The hasattr(self.sock, "version")
calls this __getattr__, which raises UnmockedError
in this case.
A quick 'n dirty fix would be to add something along the lines of
if name == 'version':
raise AttributeError()
to "declare" that the fake socket doesn't have the version
attribute.
I'm not super familiar with the socket
library, but on my side I can see that truesock
doesn't have the version
attribute either (Linux+Py3.7), and I don't see it documented on https://docs.python.org/3/library/socket.html either.
I'll send a MR with that soon, but here you have the context.
And if anyone has a cleaner and/or better idea, please share!
Is there track on this? I've pinned the urllib3 library and requests but I still see this error when using python 3.8.
I confirm this is fixed with httpretty 1.0.3
.
Cheers!