Closed
Description
I added the M__exit__ method to file to support "with open() as f" but the execution fails as following:
>>> with open("testfile") as f:
... print("hello")
...
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
FIXME line of source goes here
AttributeError: AttributeError: "'file' has no attribute '__exit__'"
The code in this case is only checking for the exit attribute instead of also checking for the implemented interface.
I see this comment:
// exit := py.ObjectLookupSpecial(mgr, "__exit__")
But I am not sure of how ObjectLookSpecial could be implemented.
An easier way to do this, but it feels "wrong", would be to add an exit method in the object dictionary.
Metadata
Metadata
Assignees
Labels
No labels