Opened 4 years ago

Closed 3 years ago

Last modified 3 years ago

#593 closed defect (fixed)

Decorators implementation

Reported by: vitja Owned by: scoder
Priority: major Milestone: 0.16
Component: Code Generation Keywords:
Cc:

Description

Now decorators are implemented like this:

def foo():
   pass

foo = decorator(foo)
  • first declare function in current scope
  • then decorate it

This is not a big issue now, but when we will support function reassignment take a look at this example:

class Foo(object):
    _x = 0
    @property
    def x(self):
        return self._x
    @x.setter
    def x(self, value):
        self._x = value

# this code will be transformed into this

class Foo(object):
    _x = 0

    def x(self):
        return self._x
    x = property(x)

    def x(self, value):
        self._x = value
    x = x.setter(x)
    # this will raise AttributeError exception
    # as second x() doesn't have setter attribute

Attachments (1)

testcase.patch (1.6 KB) - added by vitja 4 years ago.
Testcase for issue

Download all attachments as: .zip

Change History (8)

Changed 4 years ago by vitja

Testcase for issue

comment:1 Changed 4 years ago by scoder

  • Milestone changed from wishlist to 0.14.1
  • Owner changed from somebody to scoder
  • Status changed from new to assigned

comment:3 Changed 4 years ago by scoder

  • Milestone changed from 0.14.1 to wishlist
  • Resolution fixed deleted
  • Status changed from closed to reopened

comment:4 Changed 4 years ago by scoder

  • Owner changed from scoder to somebody
  • Status changed from reopened to new

comment:5 Changed 3 years ago by scoder

  • Owner changed from somebody to scoder
  • Status changed from new to assigned

comment:6 Changed 3 years ago by scoder

  • Milestone changed from wishlist to 0.15.1
  • Resolution set to fixed
  • Status changed from assigned to closed

comment:7 Changed 3 years ago by scoder

  • Milestone changed from 0.15.1 to 0.16
Note: See TracTickets for help on using tickets.