-
Notifications
You must be signed in to change notification settings - Fork 35
iface is not set correctly when using some examples #48
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
Comments
If you use |
I think that's true, but maybe the examples used to work (by accident??) The old code is this: class _FakeSSLContext:
@staticmethod
def wrap_socket(socket, server_hostname=None):
"""Return the same socket"""
# pylint: disable=unused-argument
return socket
def set_socket(sock, iface=None):
"""Legacy API for setting the socket and network interface. Use a `Session` instead."""
global _default_session # pylint: disable=global-statement,invalid-name
_default_session = Session(sock, _FakeSSLContext())
if iface:
sock.set_interface(iface)
|
Is the |
Hmm, perplexing. 🤔 |
It does work to replace the two lines with the one. (The point of all this was just to test that the revised |
Here's what I do:, and it works in CircuitPython. There may be a different sequence to be fully compatible with CPython:
I don't know of a single code sequence that works in CircuitPython on both non-ESP32-S2 and ESP32-S2. The Requests import is typically different between the two also. I suspect Scott is aiming for CPython compatibility on all platforms as he reworks the legacy stack. |
@dhalbert I think the simplest thing is to have |
Adds airlift to example
I'm not sure whether this is an error in the examples or in the revised legacy API.
examples/requests_simpletest.py
andexamples/requests_advanced.py
both contain code:However, this code stopped working at some point during the revision of the legacy API. If I try the
simpletest
, I getHere is the relevant revised code:
The
_FakeSSLContext
ends up with aNone
iface
, and thenwrap_socket()
fails becauseself._iface.TLS_MODE
will fail.The text was updated successfully, but these errors were encountered: