I'm trying to run in Brython a python application of which I'm not the main author, and I encountered a corner case where Brythin and regular python have a different behaviour.
I know that this piece of python code is ugly - I'm not even sure it is correct - but it works with regular python (3.10.12) and pypy (3.8.13/7.3.9), so maybe it should work also with Brython 🤷🏻♂️
I'll try to make the original code more sensible, but so far this is a minimal reproducer.
It looks like with Brython one cannot call explicitly the member function __call__ if it has the attribute @staticmethod:
class MyClass(object):
@staticmethod
def __call__(arg):
print(f"MyClass.__call__({arg})")
return arg
Disclaimer
I'm trying to run in Brython a python application of which I'm not the main author, and I encountered a corner case where Brythin and regular python have a different behaviour.
I know that this piece of python code is ugly - I'm not even sure it is correct - but it works with regular python (3.10.12) and pypy (3.8.13/7.3.9), so maybe it should work also with Brython 🤷🏻♂️
I'll try to make the original code more sensible, but so far this is a minimal reproducer.
It looks like with Brython one cannot call explicitly the member function
__call__
if it has the attribute@staticmethod
:With python and pypy I get
With Brython it looks like the function call is not executed, and I get