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

cadata param can (and PEM-encoded cadata must) be unicode under PY2 #3150

Merged
merged 4 commits into from Aug 23, 2019
Merged

cadata param can (and PEM-encoded cadata must) be unicode under PY2 #3150

merged 4 commits into from Aug 23, 2019

Conversation

sfreilich
Copy link
Contributor

The documentation for that parameter states: "The cadata object, if
present, is either an ASCII string of one or more PEM-encoded
certificates or a bytes-like object of DER-encoded certificates."
Similar wording is used for PY2 and PY3. But that's a bit of a
backporting bug in the documentation, since "ASCII string" and
"bytes-like object" sound like they could both be str under PY2. In
fact, if the type is str it's assumed to be DER-encoded and
PEM-encoded cadata must use the unicode type under PY2
(https://bugs.python.org/issue37079):
https://github.com/python/cpython/blob/2149a9ad/Modules/_ssl.c#L3011

Thus, these type declarations should use Union[Text, bytes, None]
instead of Union[str, bytes, None].

Also, _create_unverified_context exists in Python 2:
https://github.com/python/cpython/blob/2149a9ad/Lib/ssl.py#L448

The documentation for that parameter states: "The cadata object, if
present, is either an ASCII string of one or more PEM-encoded
certificates or a bytes-like object of DER-encoded certificates."
Similar wording is used for PY2 and PY3. But that's a bit of a
backporting bug in the documentation, since "ASCII string" and
"bytes-like object" sound like they could both be str under PY2. In
fact, if the type is str it's assumed to be DER-encoded and
PEM-encoded cadata must use the unicode type under PY2
(https://bugs.python.org/issue37079):
https://github.com/python/cpython/blob/2149a9ad/Modules/_ssl.c#L3011

Thus, these type declarations should use Union[Text, bytes, None]
instead of Union[str, bytes, None].

Also, _create_unverified_context exists in Python 2:
https://github.com/python/cpython/blob/2149a9ad/Lib/ssl.py#L448
Copy link
Collaborator

@srittau srittau left a comment

Choose a reason for hiding this comment

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

Thanks for the analysis. I left one comment below.

stdlib/2and3/ssl.pyi Outdated Show resolved Hide resolved
stdlib/2and3/ssl.pyi Outdated Show resolved Hide resolved
@JelleZijlstra
Copy link
Member

There is a merge conflict now.

@sfreilich
Copy link
Contributor Author

There is a merge conflict now.

Resolved, I think.

@JelleZijlstra
Copy link
Member

CI is failing now though (haven't checked why).

@sfreilich
Copy link
Contributor Author

Whitespace typo in the merge, missed when looking at the diff. Should be fixed.

@sfreilich
Copy link
Contributor Author

This seems to be fixed, can someone merge this, please?

@srittau srittau merged commit 75ccbdc into python:master Aug 23, 2019
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.

None yet

3 participants