mirror of
https://github.com/davidhalter/jedi.git
synced 2025-12-06 22:14:27 +08:00
property compatibility python 2.5
This commit is contained in:
@@ -24,3 +24,27 @@ try:
|
|||||||
from ast import literal_eval
|
from ast import literal_eval
|
||||||
except ImportError:
|
except ImportError:
|
||||||
literal_eval = eval
|
literal_eval = eval
|
||||||
|
|
||||||
|
|
||||||
|
# properties in 2.5
|
||||||
|
try:
|
||||||
|
property.setter
|
||||||
|
except AttributeError:
|
||||||
|
import sys
|
||||||
|
|
||||||
|
class property(property):
|
||||||
|
def __init__(self, fget, *args, **kwargs):
|
||||||
|
self.__doc__ = fget.__doc__
|
||||||
|
super(property, self).__init__(fget, *args, **kwargs)
|
||||||
|
|
||||||
|
def setter(self, fset):
|
||||||
|
cls_ns = sys._getframe(1).f_locals
|
||||||
|
for k, v in cls_ns.iteritems():
|
||||||
|
if v == self:
|
||||||
|
propname = k
|
||||||
|
break
|
||||||
|
cls_ns[propname] = property(self.fget, fset,
|
||||||
|
self.fdel, self.__doc__)
|
||||||
|
return cls_ns[propname]
|
||||||
|
else:
|
||||||
|
property = property
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ TODO class decorators
|
|||||||
TODO annotations ? how ? type evaluation and return?
|
TODO annotations ? how ? type evaluation and return?
|
||||||
TODO nonlocal statement
|
TODO nonlocal statement
|
||||||
"""
|
"""
|
||||||
from _compatibility import next
|
from _compatibility import next, property
|
||||||
|
|
||||||
import itertools
|
import itertools
|
||||||
import copy
|
import copy
|
||||||
|
|||||||
Reference in New Issue
Block a user