[Django] #32378: Incorrect exception raising syntax in documentation

15 views
Skip to first unread message

Django

unread,
Jan 21, 2021, 4:16:19 PM1/21/21
to django-...@googlegroups.com
#32378: Incorrect exception raising syntax in documentation
-----------------------------------------+------------------------
Reporter: johnthagen | Owner: nobody
Type: Uncategorized | Status: new
Component: Documentation | Version: master
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 1
UI/UX: 0 |
-----------------------------------------+------------------------
https://docs.djangoproject.com/en/dev/ref/views/#the-403-http-forbidden-
view

{{{
from django.core.exceptions import PermissionDenied

def edit(request, pk):
if not request.user.is_staff:
raise PermissionDenied
# ...
}}}

Should that be `raise PermissionDenied()` to raise an instance?

--
Ticket URL: <https://code.djangoproject.com/ticket/32378>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Jan 21, 2021, 4:26:21 PM1/21/21
to django-...@googlegroups.com
#32378: Incorrect exception raising syntax in documentation
-------------------------------+--------------------------------------

Reporter: johnthagen | Owner: nobody
Type: Uncategorized | Status: new
Component: Documentation | Version: master
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
-------------------------------+--------------------------------------

Comment (by johnthagen):

Looking into this closer, it looks like this is actually valid Python:
https://docs.python.org/3/reference/simple_stmts.html#the-raise-statement

"If it is a class, the exception instance will be obtained when needed by
instantiating the class with no arguments."

I'll leave the ticket open to see if the Django team wants to still fix
this for style consistency purposes.

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

Django

unread,
Jan 21, 2021, 4:26:47 PM1/21/21
to django-...@googlegroups.com
#32378: Inconsistent exception raising syntax in documentation
-------------------------------+--------------------------------------

Reporter: johnthagen | Owner: nobody
Type: Uncategorized | Status: new
Component: Documentation | Version: master
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
-------------------------------+--------------------------------------

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

Django

unread,
Jan 21, 2021, 6:39:24 PM1/21/21
to django-...@googlegroups.com
#32378: Inconsistent exception raising syntax in documentation
-------------------------------+--------------------------------------

Reporter: johnthagen | Owner: nobody
Type: Uncategorized | Status: new
Component: Documentation | Version: master
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
-------------------------------+--------------------------------------

Comment (by Tim Graham):

If I had to choose a style, I wouldn't include unnecessary parentheses but
I'm not sure it's even worth creating the noise in commit history as I
don't think it's bothering anyone. I feel like this came up before but it
may not have since there are some instances of unnecessary prantheses in
Django's code itself - I only found one example in the docs:
`topics/db/transactions.txt: raise SomeError()`).

--
Ticket URL: <https://code.djangoproject.com/ticket/32378#comment:3>

Django

unread,
Jan 22, 2021, 12:42:33 AM1/22/21
to django-...@googlegroups.com
#32378: Inconsistent exception raising syntax in documentation
-------------------------------------+-------------------------------------
Reporter: johnthagen | Owner: nobody
Type: | Status: closed
Cleanup/optimization |
Component: Documentation | Version: master
Severity: Normal | Resolution: invalid

Keywords: | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Mariusz Felisiak):

* status: new => closed
* type: Uncategorized => Cleanup/optimization
* resolution: => invalid


Comment:

Both versions work fine. I agree with Tim, it's not worth changing.

--
Ticket URL: <https://code.djangoproject.com/ticket/32378#comment:4>

Reply all
Reply to author
Forward
0 new messages