Skip to content
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

Add support for PyPy 3.10 #113

Merged
merged 3 commits into from
Sep 7, 2023
Merged

Add support for PyPy 3.10 #113

merged 3 commits into from
Sep 7, 2023

Conversation

sethmlarson
Copy link
Owner

This is very much a hack, I don't like it, but attempting to add support to PyPy while maintaining the SSLContext subclassing is a huge pain from my initial attempt. The __class__ hack maintains compatibility for aiohttp and trustme.

Closes #112

@davisagli
Copy link
Collaborator

Oh my. Mostly I'm just impressed if it works. Good call on only changing it for non-CPython implementations, in case someone is already using isinstance to check if they've got our SSLContext.

I'll wait for final review until the tests pass.

@sethmlarson
Copy link
Owner Author

Looks like a bug in PyPy's SSLContext.load_cert_chain() function, they're not accepting PosixPath objects. Unfortunately their GitLab instance appears to be offline right now. I guess I'll check later?

@sethmlarson
Copy link
Owner Author

Okay @davisagli tests are passing so ready for review. If you'd like to take a stab at PyPy support without the horrible hacks please do, I would like to not have them 😓

davisagli
davisagli previously approved these changes Sep 7, 2023
@davisagli davisagli merged commit 2f3c9ba into main Sep 7, 2023
15 checks passed
@davisagli davisagli deleted the pypy-support branch September 7, 2023 21:44
# Dirty hack to get around isinstance() checks
# for ssl.SSLContext instances in aiohttp/trustme
# when using non-CPython implementations.
return _truststore_SSLContext_dunder_class or SSLContext
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you point me to a reproducer for why this was needed for PyPy? Is there something PyPy should be doing to make isinstance work?

certfile=mkcert_certs.cert_file,
keyfile=mkcert_certs.key_file,
certfile=str(mkcert_certs.cert_file),
keyfile=str(mkcert_certs.key_file),
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry about that, is there a simple reproducer for this? PyPy passes the CPython ssl stdlib tests, maybe there is a case missing there?

@mattip
Copy link

mattip commented Sep 14, 2023

Thanks for getting PyPy to work. I am not familiar with the project, but am a PyPy core dev. Please ping me (mattip) if you come across any other PyPy problems.

@mattip
Copy link

mattip commented Sep 14, 2023

I opened https://foss.heptapod.net/pypy/pypy/-/issues/4002 to continue the discussion.

@sethmlarson
Copy link
Owner Author

@mattip Thanks Matti! We'll keep you in mind if we run into future problems :)

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.

pypy3.10: AttributeError: 'SSLContext' object has no attribute '_ctx'. Did you mean: 'ctx'?
3 participants