Description:
It seems that using a context manager that returns a tuple in __enter__ and unpacking it with as (c1, c2) raises an unhandled runtime error.
Example:
class MyContext:
def __enter__(self):
return "a", "b"
def __exit__(self, exc_type, exc_val, exc_tb):
pass
with MyContext() as (c1, c2):
print(c1, c2)
Clone link: Anvil | Login
Expected behavior:
This should work as in regular Python.
Actual behavior:
Skulpt raises an unhandled runtime error:
[An internal error has occurred] - see browser console for more details
TypeError: Cannot read properties of undefined (reading 'v')
at a.nameop (https://gqkpoioo2fhlto7m.anvil.app/debug/I6IITLBHAZZL236JAT7JM4EGAZLAYCXJ%3DXR76A4DWGIF4B5XDEB2H3SO6/_/static/runtime/js/lib/skulpt.min.js?sha=a687db4bddb8:1055:497)
at a.cwith (https://gqkpoioo2fhlto7m.anvil.app/debug/I6IITLBHAZZL236JAT7JM4EGAZLAYCXJ%3DXR76A4DWGIF4B5XDEB2H3SO6/_/static/runtime/js/lib/skulpt.min.js?sha=a687db4bddb8:1025:412)
at a.vstmt (https://gqkpoioo2fhlto7m.anvil.app/debug/I6IITLBHAZZL236JAT7JM4EGAZLAYCXJ%3DXR76A4DWGIF4B5XDEB2H3SO6/_/static/runtime/js/lib/skulpt.min.js?sha=a687db4bddb8:1054:205)
at a.cbody (https://gqkpoioo2fhlto7m.anvil.app/debug/I6IITLBHAZZL236JAT7JM4EGAZLAYCXJ%3DXR76A4DWGIF4B5XDEB2H3SO6/_/static/runtime/js/lib/skulpt.min.js?sha=a687db4bddb8:1061:341)
at a.cmod (https://gqkpoioo2fhlto7m.anvil.app/debug/I6IITLBHAZZL236JAT7JM4EGAZLAYCXJ%3DXR76A4DWGIF4B5XDEB2H3SO6/_/static/runtime/js/lib/skulpt.min.js?sha=a687db4bddb8:1065:162)
at Sk.compile (https://gqkpoioo2fhlto7m.anvil.app/debug/I6IITLBHAZZL236JAT7JM4EGAZLAYCXJ%3DXR76A4DWGIF4B5XDEB2H3SO6/_/static/runtime/js/lib/skulpt.min.js?sha=a687db4bddb8:1066:27)
at Arguments.<anonymous> (https://gqkpoioo2fhlto7m.anvil.app/debug/I6IITLBHAZZL236JAT7JM4EGAZLAYCXJ%3DXR76A4DWGIF4B5XDEB2H3SO6/_/static/runtime/js/lib/skulpt.min.js?sha=a687db4bddb8:1071:239)
at Sk.misceval.chain (https://gqkpoioo2fhlto7m.anvil.app/debug/I6IITLBHAZZL236JAT7JM4EGAZLAYCXJ%3DXR76A4DWGIF4B5XDEB2H3SO6/_/static/runtime/js/lib/skulpt.min.js?sha=a687db4bddb8:445:408)
at Arguments.<anonymous> (https://gqkpoioo2fhlto7m.anvil.app/debug/I6IITLBHAZZL236JAT7JM4EGAZLAYCXJ%3DXR76A4DWGIF4B5XDEB2H3SO6/_/static/runtime/js/lib/skulpt.min.js?sha=a687db4bddb8:1071:166)
at Sk.misceval.chain (https://gqkpoioo2fhlto7m.anvil.app/debug/I6IITLBHAZZL236JAT7JM4EGAZLAYCXJ%3DXR76A4DWGIF4B5XDEB2H3SO6/_/static/runtime/js/lib/skulpt.min.js?sha=a687db4bddb8:445:408)
Work around
Return a single value and unpack in within the context:
with MyContext() as my_context:
c1, c2 = my_context
print(c1, c2)