#28490: Descriptors on Models are reported as nonexistent by System Check
Framework
for ModelAdmin.list_display if they return None
-------------------------------------+-------------------------------------
Reporter: Hunter Richards | Owner: nobody
Type: Bug | Status: new
Component: contrib.admin | Version: master
Severity: Normal | Resolution:
Keywords: admin, descriptor, | Triage Stage:
system, checks, framework, | Unreviewed
validation |
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Comment (by Hunter Richards):
Thanks for the reply, Tim!
I can't think of a use case for a Descriptor that returns `None` that
triggers the error reported here, but the Descriptor API makes it very
easy to shoot yourself in the foot by writing one, and the Python
Descriptor documentation includes many examples that would trigger this
error, along with no word on having to manually handle the `if obj is
None` case (although the `@property` example is correctly written):
https://docs.python.org/3/howto/descriptor.html
We initially discovered this bug due to such an improperly written
Descriptor, and it took us a long time to track down the reason due to the
triggering of the error message being so deep. We wanted to save other
Djangonauts that time in the future!
Might I also point out that this PR includes a simplification of the
affected Admin Check code, including the removal of a known code
duplication, regardless of the prevalence of `None`-returning Descriptors.
--
Ticket URL: <https://code.djangoproject.com/ticket/28490#comment:2>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/067.b76a7cac217a163c261dc758b85602ca%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.