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 Python 2 support for __metaclass__ #2823

Closed
gvanrossum opened this issue Feb 7, 2017 · 5 comments
Closed

Add Python 2 support for __metaclass__ #2823

gvanrossum opened this issue Feb 7, 2017 · 5 comments
Labels

Comments

@gvanrossum
Copy link
Member

@gvanrossum gvanrossum commented Feb 7, 2017

Now that we have metaclasses, we should support them for Python 2 as well. While in Python 3 the metaclass is specified as a metaclass=M keyword arg in the class heading, for Python 2 the metaclass is given by a __metaclass__ = M assignment in the body of the class.

@gvanrossum gvanrossum added the feature label Feb 7, 2017
@TRManderson
Copy link
Contributor

@TRManderson TRManderson commented Feb 8, 2017

Metaclasses in Python 2 are also often defined using:

class A(object):
    class __metaclass__(type):
        pass
@gvanrossum
Copy link
Member Author

@gvanrossum gvanrossum commented Feb 8, 2017

@TRManderson
Copy link
Contributor

@TRManderson TRManderson commented Feb 8, 2017

Agreed, but it's valid and it works and people do it :'( :'( :'(

@TRManderson
Copy link
Contributor

@TRManderson TRManderson commented Feb 8, 2017

I think I've got a non-terrible solution for the __metaclass__ = M case, but the inner class thing going to require a structural change WRT metaclasses to support, so I'd say it's probably better to have an error message saying "don't do this" instead of trying to support it.

Just working on forming it into a nice PR at the moment.

@elazarg
Copy link
Contributor

@elazarg elazarg commented Apr 3, 2017

I think this issue can be closed by now

@gvanrossum gvanrossum closed this Apr 3, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
3 participants