[Django] #35426: `GenericPrefetch` should have `queryset` parameter as required

9 views
Skip to first unread message

Django

unread,
May 3, 2024, 4:34:00 AMMay 3
to django-...@googlegroups.com
#35426: `GenericPrefetch` should have `queryset` parameter as required
-------------------------------------+-------------------------------------
Reporter: Sobolev | Owner: Sobolev Nikita
Nikita |
Type: | Status: assigned
Uncategorized |
Component: | Version: 5.0
contrib.contenttypes |
Severity: Normal | Keywords:
Triage Stage: | Has patch: 0
Unreviewed |
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 1
UI/UX: 0 |
-------------------------------------+-------------------------------------
Original issue: https://code.djangoproject.com/ticket/33651

Source:
https://github.com/django/django/blob/91a4b9a8ec2237434f06866f39c7977e889aeae6/django/contrib/contenttypes/prefetch.py#L6-L7

Right now this code is really strange. It produces this result:

```
>>> import django
>>> from django.contrib.contenttypes.prefetch import GenericPrefetch
>>> GenericPrefetch('a')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Users/sobolev/Documents/github/wemake-django-
template/.venv/lib/python3.11/site-
packages/django/contrib/contenttypes/prefetch.py", line 7, in __init__
for queryset in querysets:
TypeError: 'NoneType' object is not iterable
```

I guess that there are two ways:
- Using `if querysets is None: querysets = []`
- Requiring this argument, which I guess is the correct thing to do. Why
would we ever want this field to be empty?

I will send a PR with the fix.

I found this while working on https://github.com/typeddjango/django-
stubs/pull/2115
--
Ticket URL: <https://code.djangoproject.com/ticket/35426>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
May 3, 2024, 4:34:44 AMMay 3
to django-...@googlegroups.com
#35426: `GenericPrefetch` should have `queryset` parameter as required
-------------------------------------+-------------------------------------
Reporter: Sobolev Nikita | Owner: Sobolev
| Nikita
Type: Uncategorized | Status: assigned
Component: | Version: 5.0
contrib.contenttypes |
Severity: Normal | Resolution:
Keywords: | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
Description changed by Sobolev Nikita:

Old description:

> Original issue: https://code.djangoproject.com/ticket/33651
>
> Source:
> https://github.com/django/django/blob/91a4b9a8ec2237434f06866f39c7977e889aeae6/django/contrib/contenttypes/prefetch.py#L6-L7
>
> Right now this code is really strange. It produces this result:
>
> ```
> >>> import django
> >>> from django.contrib.contenttypes.prefetch import GenericPrefetch
> >>> GenericPrefetch('a')
> Traceback (most recent call last):
> File "<stdin>", line 1, in <module>
> File "/Users/sobolev/Documents/github/wemake-django-
> template/.venv/lib/python3.11/site-
> packages/django/contrib/contenttypes/prefetch.py", line 7, in __init__
> for queryset in querysets:
> TypeError: 'NoneType' object is not iterable
> ```
>
> I guess that there are two ways:
> - Using `if querysets is None: querysets = []`
> - Requiring this argument, which I guess is the correct thing to do. Why
> would we ever want this field to be empty?
>
> I will send a PR with the fix.
>
> I found this while working on https://github.com/typeddjango/django-
> stubs/pull/2115

New description:

Original issue: https://code.djangoproject.com/ticket/33651

Source:
https://github.com/django/django/blob/91a4b9a8ec2237434f06866f39c7977e889aeae6/django/contrib/contenttypes/prefetch.py#L6-L7

Right now this code is really strange. It produces this result:


{{{
>>> import django
>>> from django.contrib.contenttypes.prefetch import GenericPrefetch
>>> GenericPrefetch('a')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Users/sobolev/Documents/github/wemake-django-
template/.venv/lib/python3.11/site-
packages/django/contrib/contenttypes/prefetch.py", line 7, in __init__
for queryset in querysets:
TypeError: 'NoneType' object is not iterable
}}}


I guess that there are two ways:
- Using `if querysets is None: querysets = []`
- Requiring this argument, which I guess is the correct thing to do. Why
would we ever want this field to be empty?

I will send a PR with the fix.

I found this while working on https://github.com/typeddjango/django-
stubs/pull/2115

--
--
Ticket URL: <https://code.djangoproject.com/ticket/35426#comment:1>

Django

unread,
May 3, 2024, 4:43:32 AMMay 3
to django-...@googlegroups.com
#35426: `GenericPrefetch` should have `queryset` parameter as required
-------------------------------------+-------------------------------------
Reporter: Sobolev Nikita | Owner: Sobolev
| Nikita
Type: Uncategorized | Status: assigned
Component: | Version: 5.0
contrib.contenttypes |
Severity: Normal | Resolution:
Keywords: | Triage Stage:
| Unreviewed
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Sobolev Nikita):

* has_patch: 0 => 1

--
Ticket URL: <https://code.djangoproject.com/ticket/35426#comment:2>

Django

unread,
May 3, 2024, 7:05:06 AMMay 3
to django-...@googlegroups.com
#35426: `GenericPrefetch` should have `queryset` parameter as required
-------------------------------------+-------------------------------------
Reporter: Sobolev Nikita | Owner: Sobolev
| Nikita
Type: Bug | Status: assigned
Component: | Version: 5.0
contrib.contenttypes |
Severity: Release blocker | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Sarah Boyce):

* severity: Normal => Release blocker
* stage: Unreviewed => Accepted
* type: Uncategorized => Bug

Comment:

Hi Sobelev, thank you for the report and patch!
Agreed this is a bug in cac94dd8aa2fb49cd2e06b5b37cf039257284bb0, as this
is a new feature introduced in 5.0, marking as a release blocker.
--
Ticket URL: <https://code.djangoproject.com/ticket/35426#comment:3>

Django

unread,
May 4, 2024, 5:30:45 AMMay 4
to django-...@googlegroups.com
#35426: `GenericPrefetch` should have `queryset` parameter as required
-------------------------------------+-------------------------------------
Reporter: Sobolev Nikita | Owner: Sobolev
| Nikita
Type: Bug | Status: closed
Component: | Version: 5.0
contrib.contenttypes |
Severity: Release blocker | Resolution: fixed
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Sarah Boyce <42296566+sarahboyce@…>):

* resolution: => fixed
* status: assigned => closed

Comment:

In [changeset:"9a27c76021f934201cccf12215514a3091325ec8" 9a27c760]:
{{{#!CommitTicketReference repository=""
revision="9a27c76021f934201cccf12215514a3091325ec8"
Fixed #35426 -- Updated querysets to be a required argument of
GenericPrefetch.
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/35426#comment:4>

Django

unread,
May 4, 2024, 5:34:58 AMMay 4
to django-...@googlegroups.com
#35426: `GenericPrefetch` should have `queryset` parameter as required
-------------------------------------+-------------------------------------
Reporter: Sobolev Nikita | Owner: Sobolev
| Nikita
Type: Bug | Status: closed
Component: | Version: 5.0
contrib.contenttypes |
Severity: Release blocker | Resolution: fixed
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
Comment (by Sarah Boyce <42296566+sarahboyce@…>):

In [changeset:"9b5029f04851878923e04085591b29ee291718b6" 9b5029f0]:
{{{#!CommitTicketReference repository=""
revision="9b5029f04851878923e04085591b29ee291718b6"
[5.0.x] Fixed #35426 -- Updated querysets to be a required argument of
GenericPrefetch.

Backport of 9a27c76021f934201cccf12215514a3091325ec8 from main.
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/35426#comment:5>

Django

unread,
May 4, 2024, 5:42:58 AMMay 4
to django-...@googlegroups.com
#35426: `GenericPrefetch` should have `queryset` parameter as required
-------------------------------------+-------------------------------------
Reporter: Sobolev Nikita | Owner: Sobolev
| Nikita
Type: Bug | Status: closed
Component: | Version: 5.0
contrib.contenttypes |
Severity: Release blocker | Resolution: fixed
Keywords: | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Sarah Boyce):

* stage: Accepted => Ready for checkin

--
Ticket URL: <https://code.djangoproject.com/ticket/35426#comment:6>
Reply all
Reply to author
Forward
0 new messages