Opened 17 years ago

Closed 17 years ago

#7342 closed (fixed)

Using a new-style class for Meta raises an exception

Reported by: Marty Alchin Owned by: Marty Alchin
Component: Database layer (models, ORM) Version: dev
Severity: Keywords:
Cc: Triage Stage: Ready for checkin
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

When attempting to use a new-style class for a model's Meta inner class (class Meta(object):), Django raises a TypeError because of two additional attributes that new-style classes have that old-style classes don't.

TypeError: 'class Meta' got invalid  attribute(s): __dict__,__weakref__

Admittedly, the documentation only shows old-style classes, but there's no mention of avoiding new-style classes. More to the point, once Python 3000 rolls around, all classes will be new-style by default, and this will become an instant problem.

Attachments (1)

7342-r7568.diff (973 bytes ) - added by Marty Alchin 17 years ago.
Per Jacob, this patch simply ignores any attributes beginning with _, future-proofing this considerably.

Download all attachments as: .zip

Change History (3)

by Marty Alchin, 17 years ago

Attachment: 7342-r7568.diff added

Per Jacob, this patch simply ignores any attributes beginning with _, future-proofing this considerably.

comment:1 by Jacob, 17 years ago

Triage Stage: UnreviewedReady for checkin

comment:2 by Jacob, 17 years ago

Resolution: fixed
Status: newclosed

(In [7585]) Fixed #7342: Ignore any Meta options starting with '_', thus making it OK for Meta to be a newstyle class. Thanks, Gulopine.

Note: See TracTickets for help on using tickets.
Back to Top