adafruit / Adafruit_CircuitPython_Requests

Requests-like interface for web interfacing
MIT License
51 stars 36 forks source link

Fix CircuitPython compatibility #53

Closed jepler closed 3 years ago

jepler commented 3 years ago

Closes #52

On CircuitPython, bytearray objects have no split method. Emulate the specific form that we need.

Testing performed: tests still pass, and it works on a device.

jepler commented 3 years ago

Thanks for the testing!

d-c-d commented 3 years ago

Just ran across this same issue while upgrading my pyportal to CP6.0 and Adafruit_CircuitPython_Requests-1.8.0.zip thanks to @anecdata on discord for pointing me to this request - fetched and install source .py file solved the problem for me too!

ladyada commented 3 years ago

thankx!!

anecdata commented 3 years ago

I think there are still some .split methods being used on objects that, at least in some circumstances, are bytearrays:

  File "adafruit_requests.py", line 692, in get
  File "adafruit_requests.py", line 568, in request
  File "adafruit_requests.py", line 277, in close
AttributeError: 'bytearray' object has no attribute 'split'
askpatrickw commented 3 years ago

@anecdata I am seeing this as well. It seems like it works the first call and then not on subsequent calls. But my testing was limited to response = requests.get("https://io.adafruit.com/api/v2/time/seconds"). Were you also using the io time API?

anecdata commented 3 years ago

@askpatrickw I was GETting from my own server, but like yours it seems to happen on the first call in code.py. I didn't explore it too deeply... it's very intermittent and I wasn't catching it, so I reset.

askpatrickw commented 3 years ago

@anecdata Found it... see PR #56