Ticket #593 (closed defect: fixed)

Opened 3 years ago

Last modified 3 years ago

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

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

Change History

Changed 3 years ago by vitja

Testcase for issue

Changed 3 years ago by scoder

  • owner changed from somebody to scoder
  • status changed from new to assigned
  • milestone changed from wishlist to 0.14.1

Changed 3 years ago by scoder

  • status changed from closed to reopened
  • resolution fixed deleted
  • milestone changed from 0.14.1 to wishlist

Changed 3 years ago by scoder

  • owner changed from scoder to somebody
  • status changed from reopened to new

Changed 3 years ago by scoder

  • owner changed from somebody to scoder
  • status changed from new to assigned

Changed 3 years ago by scoder

  • status changed from assigned to closed
  • resolution set to fixed
  • milestone changed from wishlist to 0.15.1

Changed 3 years ago by scoder

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