Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,33 @@ def read_attr(obj):
assert read_attr(K()) == 43


def test_property_subclass_copy():
class CustomProperty(property):
pass

class K:
@CustomProperty
def attr(self):
return self._attr

@attr.setter
def attr(self, value):
self._attr = value

@attr.deleter
def attr(self):
del self._attr

p = K.__dict__['attr']
assert type(p) is CustomProperty
assert type(p.getter(lambda self: 1)) is CustomProperty
k = K()
k.attr = 5
assert k.attr == 5
del k.attr
assert not hasattr(k, '_attr')


def test_property_without_getter():
class K:
attr = property()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,6 @@
import com.oracle.graal.python.nodes.function.builtins.PythonUnaryBuiltinNode;
import com.oracle.graal.python.nodes.function.builtins.PythonVarargsBuiltinNode;
import com.oracle.graal.python.nodes.object.BuiltinClassProfiles.IsBuiltinClassExactProfile;
import com.oracle.graal.python.nodes.object.BuiltinClassProfiles.IsBuiltinClassProfile;
import com.oracle.graal.python.nodes.object.GetClassNode;
import com.oracle.graal.python.nodes.object.GetClassNode.GetPythonObjectClassNode;
import com.oracle.graal.python.runtime.ExecutionContext.BoundaryCallContext;
Expand Down Expand Up @@ -342,14 +341,16 @@ static Object copy(PProperty pold, Object getArg, Object setArg, Object delArg)
}

// shortcut: create new property object directly
if (IsBuiltinClassProfile.profileClassSlowPath(type, PythonBuiltinClassType.PProperty)) {
if (IsBuiltinClassExactProfile.profileClassSlowPath(type, PythonBuiltinClassType.PProperty)) {
PProperty copy = PFactory.createProperty(PythonLanguage.get(null));
PropertyInitNode.doGenericBoundary(copy, get, set, del, doc);
copy.setPropertyName(pold.getPropertyName());
return copy;
}
PProperty newProp = (PProperty) CallNode.executeUncached(type, get, set, del, doc);
newProp.setPropertyName(pold.getPropertyName());
Object newProp = CallNode.executeUncached(type, get, set, del, doc);
if (newProp instanceof PProperty property) {
property.setPropertyName(pold.getPropertyName());
}
return newProp;
}

Expand Down