Opened 4 years ago

Closed 4 years ago

#18503 closed defect (fixed)

cdef'ed metaclasses don't work with six's with_metaclass

Reported by: jpswanson Owned by:
Priority: major Milestone: sage-6.8
Component: misc Keywords: ClasscallMetaclass, six, with_metaclass, metaclass, python3, days64.25
Cc: ohanar Merged in:
Authors: R. Andrew Ohana Reviewers: Josh Swanson
Report Upstream: N/A Work issues:
Branch: 7486057 (Commits) Commit: 7486057408c3e3d74027c46bb6e87a9522c288ad
Dependencies: Stopgaps:

Description

Title says it all. MWE:

from sage.misc.classcall_metaclass import ClasscallMetaclass
from six import with_metaclass
class foo(with_metaclass(ClasscallMetaclass)):
    pass

throws an error

TypeError: type.__new__(metaclass) is not safe, use sage.misc.classcall_metaclass.ClasscallMetaclass.__new__()

in six.pyc in with_metaclass(meta, *bases). If mixed Python 2 and Python 3 becomes a reality (e.g. #18492), this'll need to be fixed.

Change History (5)

comment:1 Changed 4 years ago by jpswanson

  • Cc ohanar added

comment:2 Changed 4 years ago by ohanar

  • Authors changed from Josh Swanson to R. Andrew Ohana
  • Branch set to u/ohanar/with_metaclass
  • Commit set to 7486057408c3e3d74027c46bb6e87a9522c288ad
  • Status changed from new to needs_review
  • Summary changed from ClasscallMetaclass doesn't work with six's with_metaclass to cdef'ed metaclasses don't work with six's with_metaclass

New commits:

7486057add a with_metaclass that works with cdef'ed classes

comment:3 Changed 4 years ago by jpswanson

  • Reviewers set to Josh Swanson
  • Status changed from needs_review to positive_review

Good enough. It's a bit infortunate to have to add a slightly modified version of six to Sage, but we might run into other Cython-specific issues with it and development on six seems to have stopped for the last year or so.

comment:4 Changed 4 years ago by jpswanson

  • Keywords days64.25 added

comment:5 Changed 4 years ago by vbraun

  • Branch changed from u/ohanar/with_metaclass to 7486057408c3e3d74027c46bb6e87a9522c288ad
  • Resolution set to fixed
  • Status changed from positive_review to closed
Note: See TracTickets for help on using tickets.