Fix py2/3 metaclass compatibility