This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: compound_stmt syntax includes 'decorated'
Type: Stage:
Components: Documentation Versions: Python 3.0
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: georg.brandl Nosy List: benjamin.peterson, dangyogi, georg.brandl
Priority: normal Keywords:

Created on 2008-09-20 00:59 by dangyogi, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Messages (6)
msg73448 - (view) Author: Bruce Frederiksen (dangyogi) Date: 2008-09-20 00:59
The python 3.0 Language Reference page describing compound_stmt
(http://docs.python.org/dev/3.0/reference/compound_stmts.html) includes
'decorated'.  But the funcdef and classdef definitions both include
optional decorators.  It looks like this 'decorated' option should be
deleted.
msg73450 - (view) Author: Benjamin Peterson (benjamin.peterson) * (Python committer) Date: 2008-09-20 01:03
If you look at the real Grammar (in Grammar/Grammar), you will see that
this decorated is used in the grammar.
msg73453 - (view) Author: Bruce Frederiksen (dangyogi) Date: 2008-09-20 01:48
But the real Grammar doesn't include decorators on funcdef and classdef, 
while the Language Reference document does.  So the 'decorated' option 
is not needed in the Language Reference (and, indeed, doesn't even seem 
to be defined there).

Benjamin Peterson wrote:
> Benjamin Peterson <musiccomposition@gmail.com> added the comment:
>
> If you look at the real Grammar (in Grammar/Grammar), you will see that
> this decorated is used in the grammar.
>
> ----------
> nosy: +benjamin.peterson
> resolution:  -> invalid
> status: open -> closed
>
> _______________________________________
> Python tracker <report@bugs.python.org>
> <http://bugs.python.org/issue3913>
> _______________________________________
>
>
msg73454 - (view) Author: Benjamin Peterson (benjamin.peterson) * (Python committer) Date: 2008-09-20 02:13
The language reference is merely a explanation of the the Grammar, so I
don't understand why you think it shouldn't be there. A 'decorated' node
contains a 'classdef' or 'fundef'.
msg73456 - (view) Author: Bruce Frederiksen (dangyogi) Date: 2008-09-20 03:00
The grammar definitions in the Language Reference are _not_ just a 
straight copy of the Grammar.  They have been reworked.  (I don't know 
why, perhaps to make it easier to understand)?

So the Grammar defines funcdef and classdef _without_ decorators and 
then has a separate definition for decorated funcdefs and classdefs 
called 'decorated' that is another compound_stmt (along with funcdef and 
classdef).  (For Grammar, I'm looking at: 
http://docs.python.org/dev/3.0/reference/grammar.html).

The Language Reference defines both funcdef and classdef _with_ optional 
decorators, so the 'decorated' alternative for compound_stmt is no 
longer required and should be deleted.  The following links should take 
you straight to the funcdef and classdef definitions in the Language 
Reference:

http://docs.python.org/dev/3.0/reference/compound_stmts.html#grammar-token-funcdef
http://docs.python.org/dev/3.0/reference/compound_stmts.html#grammar-token-classdef

Now, I just also noticed that the Language Reference actually has two 
definitions of funcdef.  The second definition is 3 lines below the 
first one and fails to include either the optional decorators or the new 
["->" expression] option after the argument list.  Should I report this 
as another bug, or does this comment count.  This second definition 
should be deleted.

Also, the first definition of funcdef in the Language Reference has an 
extraneous '?' character after the ["->" expression] which should also 
be deleted.  Should I report this as a separate bug too, or leave it, as 
well, to this comment?  (Sorry for asking whether to report these too, I 
don't know how strict you guys are about keeping a record of everything).

There are many other places where the grammar defined in the Language 
Reference is not a mirror copy of the Grammar (but is still an 
equivalent grammar).  In fact, this seems to be the rule, rather than 
the exception.  If you are unaware of this, you should examine the 
grammar definitions in the Language Reference and compare them to the 
Grammar yourself; or ask whoever is in charge of the Language Reference 
document.  I don't know why this was done, I'm just trying to point out 
that the Language Reference document has some (minor) bugs in it that 
are very easily fixed.

Benjamin Peterson wrote:
> Benjamin Peterson <musiccomposition@gmail.com> added the comment:
>
> The language reference is merely a explanation of the the Grammar, so I
> don't understand why you think it shouldn't be there. A 'decorated' node
> contains a 'classdef' or 'fundef'.
>
> _______________________________________
> Python tracker <report@bugs.python.org>
> <http://bugs.python.org/issue3913>
> _______________________________________
>
>
msg73491 - (view) Author: Georg Brandl (georg.brandl) * (Python committer) Date: 2008-09-21 07:22
Bruce is right.

I fixed "decorated", the duplicate "funcdef" and the "?" in r66527 and
r66528.

Bruce, usually adding comments with more issues, especially if they are
so small, is fine; however, since they may be overlooked you're free to
open another bug after a time if no reaction happens.
History
Date User Action Args
2022-04-11 14:56:39adminsetgithub: 48163
2008-09-21 07:22:42georg.brandlsetresolution: not a bug -> fixed
messages: + msg73491
2008-09-20 03:00:21dangyogisetmessages: + msg73456
2008-09-20 02:13:06benjamin.petersonsetmessages: + msg73454
2008-09-20 01:48:11dangyogisetmessages: + msg73453
2008-09-20 01:03:57benjamin.petersonsetstatus: open -> closed
nosy: + benjamin.peterson
resolution: not a bug
messages: + msg73450
2008-09-20 00:59:55dangyogicreate