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

Comments

Projects
None yet
3 participants
@gvanrossum
Member

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

This comment has been minimized.

Contributor

TRManderson commented Feb 8, 2017

Metaclasses in Python 2 are also often defined using:

class A(object):
    class __metaclass__(type):
        pass
@gvanrossum

This comment has been minimized.

Member

gvanrossum commented Feb 8, 2017

@TRManderson

This comment has been minimized.

Contributor

TRManderson commented Feb 8, 2017

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

@TRManderson

This comment has been minimized.

Contributor

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

This comment has been minimized.

Contributor

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