Closed Salamek closed 3 weeks ago
Can you give a MCVE for how to cause it to crash?
It passes unit tests. You can use a value of class StrEnum(str, Enum)
as a string.
This also works and doesn't crash:
from gopay.enums import ContentType
import requests
content_type = ContentType.JSON
r = requests.post(
"https://gw.sandbox.gopay.com/api/payments/payment",
headers={"Content-Type": content_type},
data={"test": "test"}
)
assert isinstance(content_type, str)
I'm unable to reproduce this now on Python 3.12.5 and 3.11.2, this was issue on some previous Python3
or requests
(etc.) version, servers are all updated now...
When i'm looking at gopay code bit deeper i can see that StrEnum
is instance of str
with __str__
defined so that should work and pass requests
header tests ok:
I did not "make up" this Exception (and its fix/patch that was used in production on my part until deps. update, when it started working without patching gopay i just thought this issue got resolved :smiling_face_with_tear: ) so there is some combination of gopay/python/requests where it fails for some reason... BUT it is 6 months that this was not an issue for anyone else, it works for me RN with ~latest repo Python3 in Debian/Archlinux and deps. And i don't have time to bisect this any more, so i think we can close this issue as resolved and reject attached PR.
@Salamek Thank you.
Crash is caused by passing ContentType(StringEnum) do
requests
headers dict here: https://github.com/gopaycommunity/gopay-python-api/blob/066e50885f2e424f513ad4ea931da36386975f04/gopay/api.py#L62(PR coming soon)