Opened 21 months ago

Closed 21 months ago

Last modified 21 months ago

#28269 closed Bug (fixed)

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

Reported by: Adam (Chainz) 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 Changed 21 months ago by Adam (Chainz) Johnson

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 Changed 21 months ago by Tim Graham

Severity: NormalRelease blocker
Triage Stage: UnreviewedAccepted

comment:3 Changed 21 months ago by Adam (Chainz) Johnson

comment:4 Changed 21 months ago by Adam (Chainz) Johnson

Has patch: set

comment:5 Changed 21 months ago by Tim Graham <timograham@…>

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 Changed 21 months ago by Tim Graham <timograham@…>

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