[Python-Dev] Decorator order implemented backwards?

Mark Russell marktrussell at btopenworld.com
Tue Aug 10 23:07:20 CEST 2004


On Tue, 2004-08-10 at 06:08, Anthony Baxter wrote:
> Mark, is it possible that this changed between the first and
> final versions of the decorator patch? The SF report doesn't
> list any of the older versions...

No, it has always been this way round.  In fact test_order was inherited
from Guido's original version of test_decorators.py (from patch #926860)
where it read:

    def test_order(self):
        class C(object):
            [funcattrs(abc=1), staticmethod]
            def foo(): return 42
        # This wouldn't work if staticmethod was called first
        self.assertEqual(C.foo(), 42)
        self.assertEqual(C().foo(), 42)

(i.e. identical to the current version except for the change in
syntax).  In fact I relied on the fact that this test passed to convince
me I had the order right!  But I should have spotted the inconsistency
between that and the documentation that I wrote for the reference
manual.

I'll do a patch to fix the order and the corresponding tests.

While I'm at it, do we want to drop support for multiple decorators on a
single line?  Nobody has spoken up for it, and in fact forcing
one-per-line would simplify the grammar (as well as making it easier for
toy parsers to find decorators).

Mark



More information about the Python-Dev mailing list