Skip to content

Fix misused super in CACertsHTTPSConnection and CACertsHTTPSHandler #394

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

renaudll
Copy link
Contributor

Fix crash when uploading a thumbnail.

$ rez-env python-3.11 sq_shotgun shotgun_api3-3.8.2  -- python -c 'import sq_shotgun; sg = sq_shotgun.connect("Toolkit");  sg.upload("PublishedFile", 123456, "/path/to/no_preview.jpg", field_name="thumb_image")'
Traceback (most recent call last):
(...)
  File "/home-local/rlarouche/packages/shotgun_api3/3.8.2/python/shotgun_api3/shotgun.py", line 4665, in _send_form
    raise ShotgunError("Max attemps limit reached.")
shotgun_api3.shotgun.ShotgunError: Max attemps limit reached.

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 HTTPSHandler to HTTPHandler.
This change is weird as the class re-implement https_open which don't exist in HTTPHandler.

I assume this was done because without changing the parent class, we get the following error:

  File "/squeeze/rez_software/rez_package/python/3.11.9/platform-linux/arch-x86_64/os-Rocky-9/lib/python3.11/http/client.py", line 1000, in send
    if self.debuglevel > 0:
       ^^^^^^^^^^^^^^^^^^^
TypeError: '>' not supported between instances of 'CACertsHTTPSHandler' and 'int'

The reason we get this error is because of how some lines where converted to super calls.

They were converted from:

urllib.request.HTTPSHandler.__init__(self)

To:

super().__init__(self)

But they should be:

super().__init__()

Passing self to HTTPSHandler.__init__ will set the debuglevel keyword argument, hence the crash.

I hope this helps!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant