Commit 753e262f authored by Stefan Behnel's avatar Stefan Behnel

Switch off special methods for closure classes the hard way.

parent bff0e5cb
......@@ -1200,6 +1200,8 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode):
self.generate_traverse_function(scope, code, entry)
if scope.needs_tp_clear():
self.generate_clear_function(scope, code, entry)
if not scope.is_closure_class_scope:
# in closure classes, these are user defined variable names
if scope.defines_any(["__getitem__"]):
self.generate_getitem_int_function(scope, code)
if scope.defines_any(["__setitem__", "__delitem__"]):
......
......@@ -304,6 +304,8 @@ class MethodSlot(SlotDescriptor):
method_name_to_slot[method_name] = self
def slot_code(self, scope):
if scope.is_closure_class_scope:
return "0"
entry = scope.lookup_here(self.method_name)
if entry and entry.func_cname:
return entry.func_cname
......@@ -404,6 +406,8 @@ class SyntheticSlot(InternalMethodSlot):
class RichcmpSlot(MethodSlot):
def slot_code(self, scope):
if scope.is_closure_class_scope:
return "0"
entry = scope.lookup_here(self.method_name)
if entry and entry.func_cname:
return entry.func_cname
......@@ -456,6 +460,8 @@ class SuiteSlot(SlotDescriptor):
substructures.append(self)
def is_empty(self, scope):
if scope.is_closure_class_scope:
return True
for slot in self.sub_slots:
if slot.slot_code(scope) != "0":
return False
......
......@@ -24,8 +24,16 @@ def func():
def __dict__(a):
return 'dict'
def __setitem__(x):
return '__setitem__'
def __getslice__(x):
return '__getslice__'
def list_from_gen(g):
return list(g)
# move into closure by using inside of generator expression
return list_from_gen([__eq__, __str__, __weakref__, __new__, __dict__][i] for i in range(5))
return list_from_gen(
[__eq__, __str__, __weakref__, __new__, __dict__, __setitem__, __getslice__][i]
for i in range(5))
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment