Skip to content

Commit d52209d

Browse files
committed
Fixed a few generated methods
1 parent 661e5f0 commit d52209d

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

code_generation/mini_lambda_methods_generation.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ def define_what_needs_to_be_written() -> Tuple[Set[Override], Set[OverExc]]:
160160
# Actually this COULD work but creates infinite loops when a list comprehension is used in the expression [i for i in x]
161161
# so we prefer to raise an exception and tell users that list comprehensions are forbidden
162162
# to_skip.update({'__iter__'})
163-
to_override_with_exception.update({OverExc('__iter__')})
163+
to_override_with_exception.update({OverExc('__iter__', unbound_method=iter)})
164164

165165
# ** Iterator and Generator **
166166
# .__next__
@@ -193,11 +193,11 @@ def define_what_needs_to_be_written() -> Tuple[Set[Override], Set[OverExc]]:
193193
# ** Hashable Object **
194194
# .__hash__
195195
# to_override.update(__get_all_magic_methods(Hashable))
196-
to_override_with_exception.update({OverExc('__hash__')})
196+
to_override_with_exception.update({OverExc('__hash__', unbound_method=hash)})
197197

198198
# ** Truth-testable Object **
199199
# .__bool__
200-
to_override_with_exception.update({OverExc('__bool__')})
200+
to_override_with_exception.update({OverExc('__bool__', unbound_method=bool)})
201201

202202
# ** Object = Field container **
203203
# .__getattribute__ (to avoid)
@@ -233,7 +233,7 @@ def define_what_needs_to_be_written() -> Tuple[Set[Override], Set[OverExc]]:
233233

234234
# ** Sized Container **
235235
# .__len__, .__length_hint__
236-
to_override_with_exception.add(OverExc('__len__'))
236+
to_override_with_exception.add(OverExc('__len__', unbound_method=len))
237237

238238
# ** Iterable Container : see Iterable **
239239
# ** Reversible Container **

mini_lambda/generated.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -757,7 +757,7 @@ def __hex__(self, *args):
757757
# ******* All replacement methods for the magic methods throwing exceptions ********
758758
def Iter(evaluator: _LambdaExpressionGenerated):
759759
""" This is a replacement method for _LambdaExpression '__iter__' magic method """
760-
return evaluator.add_bound_method_to_stack('__iter__')
760+
return evaluator.add_unbound_method_to_stack(iter)
761761

762762

763763
def Str(evaluator: _LambdaExpressionGenerated):
@@ -787,17 +787,17 @@ def Sizeof(evaluator: _LambdaExpressionGenerated):
787787

788788
def Hash(evaluator: _LambdaExpressionGenerated):
789789
""" This is a replacement method for _LambdaExpression '__hash__' magic method """
790-
return evaluator.add_bound_method_to_stack('__hash__')
790+
return evaluator.add_unbound_method_to_stack(hash)
791791

792792

793793
def Bool(evaluator: _LambdaExpressionGenerated):
794794
""" This is a replacement method for _LambdaExpression '__bool__' magic method """
795-
return evaluator.add_bound_method_to_stack('__bool__')
795+
return evaluator.add_unbound_method_to_stack(bool)
796796

797797

798798
def Len(evaluator: _LambdaExpressionGenerated):
799799
""" This is a replacement method for _LambdaExpression '__len__' magic method """
800-
return evaluator.add_bound_method_to_stack('__len__')
800+
return evaluator.add_unbound_method_to_stack(len)
801801

802802

803803
def Int(evaluator: _LambdaExpressionGenerated):

0 commit comments

Comments
 (0)