Skip to content

Let's rename "2.7 to "2" #579

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

Closed
gvanrossum opened this issue Sep 30, 2016 · 1 comment
Closed

Let's rename "2.7 to "2" #579

gvanrossum opened this issue Sep 30, 2016 · 1 comment

Comments

@gvanrossum
Copy link
Member

There's a "3" subdirectory which is the baseline for all supported Python 3 versions, i.e. 3.2 and up. Maybe we could also have a "2" subdirectory as the baseline for all supported Python 2 versions, i.e. 2.7 and up? The asymmetry bothers me, and I use pathname completion enough that I long for a shorter name here. @matthiaskramm Does pytype have any plans for supporting 2.6? I know mypy doesn't.

@matthiaskramm
Copy link
Contributor

No major objections from my side. We don't plan to support 2.6.

The only advantage of 2.7 over 2 is that with 2.7 it's slightly more obvious that it's a Python version number.

gvanrossum pushed a commit that referenced this issue Oct 26, 2016
hswong3i pushed a commit to alvistack/python-typeshed that referenced this issue May 25, 2025
…ython#580)

Fixes python#579 .

When performing an `issubclass` check of a type against a protocol, the `__annotations__` member of the type is accessed and assumed to be iterable. `__annotations__` is a descriptor in the case of `types.FunctionType`, so while it is iterable when accessed on a function instance it is not iterable when accessed on the type of a function. This causes the `issubclass` check to fail with an exception.

In some cases (AFAICT, non-data protocols), an `isinstance` check of an object will use, internally, a subclass check of the object's type. As a result, `isinstance` will also fail with an exception in these conditions.

The above only seemed to occur in Python 3.

This PR fixes the issue in the Python 3 implementation while adding test coverage for both Python 2 and 3 that ensures that functions (and `types.FunctionType`) can be correctly compared both against protocols that they legitimately implement as well as those that they do not implement.
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

No branches or pull requests

2 participants