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: Fix @decorator evaluation order
Type: Stage:
Components: Interpreter Core Versions:
process
Status: closed Resolution: accepted
Dependencies: Superseder:
Assigned To: anthonybaxter Nosy List: anthonybaxter, mark_t_russell, mwh
Priority: normal Keywords: patch

Created on 2004-08-15 15:07 by mark_t_russell, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
at-deco.diff--2004-08-15-v2 mark_t_russell, 2004-08-15 19:43
Messages (3)
msg46712 - (view) Author: Mark Russell (mark_t_russell) Date: 2004-08-15 15:07
This patch fixes decorator evaluation order
and makes newlines between decorators
mandatory.

Changes in this patch:

     - Change Grammar/Grammar to require
       newlines between adjacent decorators.
       
     - Fix order of evaluation of decorators
       in the C (compile.c) and python
       (Lib/compiler/pycodegen.py) compilers
     
     - Add better order of evaluation check
       to test_decorators.py (test_eval_order)

     - Update the decorator documentation in
       the reference manual (improve description
       of evaluation order and update syntax
       description)

The order of evaluation issue is slightly
more subtle than it first appears - there
are two orders involved:

    - evaluation of decorator expressions
    - evaluation of the returned decorators

This patch arranges for the evaluation order
to be exactly the same as you get with the
manual way of writing decorators, which I
think is the least surprising way of doing
things.
msg46713 - (view) Author: Mark Russell (mark_t_russell) Date: 2004-08-15 19:42
Logged In: YES 
user_id=1017234

Used Brett's evaluation order (see
http://mail.python.org/pipermail/python-dev/2004-August/047835.html)
msg46714 - (view) Author: Michael Hudson (mwh) (Python committer) Date: 2004-08-17 17:32
Logged In: YES 
user_id=6656

Anthony couldn't get SF CVS to talk to him, so I've checked
this in as

Doc/ref/ref7.tex revision 1.40
Grammar/Grammar revision 1.51
Lib/compiler/pycodegen.py revision 1.72
Lib/compiler/transformer.py revision 1.43
Lib/test/test_decorators.py revision 1.5
Modules/parsermodule.c revision 2.84
Python/compile.c revision 2.319
Python/graminit.c revision 2.37
History
Date User Action Args
2022-04-11 14:56:06adminsetgithub: 40762
2004-08-15 15:07:41mark_t_russellcreate