Skip to content
This repository has been archived by the owner on Oct 1, 2019. It is now read-only.

with_metaclass: check existence of __prepare__ attribute before calling it #110

Closed
behnam opened this issue Aug 9, 2018 · 1 comment
Closed

Comments

@behnam
Copy link

behnam commented Aug 9, 2018

return meta.__prepare__(name, bases)

The def with_metaclass() implementation assumes that all meta classes have __prepare__ defined.

The Python Reference says (https://docs.python.org/3/reference/datamodel.html#preparing-the-class-namespace):

If the metaclass has a __prepare__ attribute, it is called as [...].

If the metaclass has no __prepare__ attribute, then the class namespace is initialised as an empty ordered mapping.

Therefore, I think six should check existence of __prepare__ attribute before calling it, as __prepare__ is not defined on type in PY2.

@behnam
Copy link
Author

behnam commented Aug 9, 2018

Oops, wrong repo. It's here: benjaminp/six#252

@behnam behnam closed this as completed Aug 9, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant