SG-40026 Fix misused super in CACertsHTTPSConnection and CACertsHTTPSHandler#394
SG-40026 Fix misused super in CACertsHTTPSConnection and CACertsHTTPSHandler#394renaudll wants to merge 1 commit intoshotgunsoftware:masterfrom
Conversation
Imran-imtiaz48
left a comment
There was a problem hiding this comment.
In this code snippet, the handling of custom CA certificates is clearly the main focus, and there are a few points worth noting for the review. The __init__ method correctly extracts the ca_certs argument from kwargs before calling the superclass initializer, which ensures that unexpected keyword arguments are not passed up the chain. However, it would be good to add error handling or a default value when popping ca_certs, since its absence could lead to a KeyError and potentially break instantiation. In the connect method, the logic for wrapping the HTTP socket with SSL is clean, but the conditional check on six.PY38 might benefit from a more explicit comment explaining why Python 3.8 requires a different approach, as this would help future maintainers avoid unintentional regressions. For the CACertsHTTPSHandler class, the use of a custom HTTPS handler to enforce CA certs is a solid design choice, but it would be beneficial to include parameter type hints in __init__ for cacerts (e.g., str or pathlib.Path) to clarify expectations. Lastly, while https_open currently delegates to the superclass method, adding a short comment about how this method uses the stored __ca_certs would improve readability for others reading the code.
|
@carlos-villavicencio-adsk since this is related to your commit would you mind taking a quick look? Thanks! |
Fix crash when uploading a thumbnail.
I've isolated the regression to shotgun_api3-3.8.2, more specifically this commit:
https://github.com/shotgunsoftware/python-api/pull/368/files?diff=split&w=0
The issue come from the change in the parent class of
CACertsHTTPSHandler.It was changed from
HTTPSHandlertoHTTPHandler.This change is weird as the class re-implement
https_openwhich don't exist inHTTPHandler.I assume this was done because without changing the parent class, we get the following error:
The reason we get this error is because of how some lines where converted to
supercalls.They were converted from:
To:
But they should be:
Passing
selftoHTTPSHandler.__init__will set thedebuglevelkeyword argument, hence the crash.I hope this helps!