Opened 7 years ago

Closed 7 years ago

Last modified 7 years ago

#28269 closed Bug (fixed)

Fix Model._meta._property_names to work with attributes that raise AttributeError

Reported by: Adam Johnson Owned by: nobody
Component: Database layer (models, ORM) Version: 1.11
Severity: Release blocker Keywords:
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

As reported on the mailing list at https://groups.google.com/forum/#!msg/django-developers/ClQ0mCJ-a6Y/FOYTz98yBgAJ , the optimization I did in model init in commit d2a26c1a90e837777dabdf3d67ceec4d2a70fb86 did not copy in a try/except AttributeError. This fails because some third party apps install "class only" descriptors that raise AttributeError when not accessed in an instance, for example: https://github.com/kmmbvnr/django-fsm/blob/2d2eaee/django_fsm/__init__.py#L225

_property_names should be changed to try/except AttributeError when accessing the attributes on the class, and we should add a test to prevent regression.

Change History (6)

comment:1 by Adam Johnson, 7 years ago

Summary: Fix Model._meta._property_names to work with attributes raise AttributeErrorFix Model._meta._property_names to work with attributes that raise AttributeError

comment:2 by Tim Graham, 7 years ago

Severity: NormalRelease blocker
Triage Stage: UnreviewedAccepted

comment:3 by Adam Johnson, 7 years ago

comment:4 by Adam Johnson, 7 years ago

Has patch: set

comment:5 by Tim Graham <timograham@…>, 7 years ago

Resolution: fixed
Status: newclosed

In ed24419:

Fixed #28269 -- Fixed Model.init() crash on models with a field that has an instance only descriptor.

Regression in d2a26c1a90e837777dabdf3d67ceec4d2a70fb86.

comment:6 by Tim Graham <timograham@…>, 7 years ago

In b7d6077:

[1.11.x] Fixed #28269 -- Fixed Model.init() crash on models with a field that has an instance only descriptor.

Regression in d2a26c1a90e837777dabdf3d67ceec4d2a70fb86.

Backport of ed244199c72f5bbf33ab4547e06e69873d7271d0 from master

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