Transcrypt icon indicating copy to clipboard operation
Transcrypt copied to clipboard

list.pop() in a list with 'undefined' returned from a function raises IndexError

Open warrenchopin opened this issue 8 months ago • 0 comments

Hi,

I encountered an error in list.pop() in Transcrypt3.9.4. It had no problem in previous versions. When a list contains an element 'undefined' returned from a function, list.pop() raises IndexError. The return command with no argument returns None in Python. But, 'undefined' is returned in Transcrypt3.9.4.

test code:

sMsg= "list.pop() in a list with 'undefined' returned from a function raises IndexError in Transcrypt3.9.4"
def x():
    return  # Python returns None, but Transcrypt3.9.4 returns 'undefined'
def main():
    print('\n'+sMsg)
    l= [x(), x(), x()]
    print(l)
    print(l.pop(0))

if __name__ == '__main__':
    main()

output:

list.pop() in a list with 'undefined' returned from a function raises IndexError in Transcrypt3.9.4
msgWhileLoading.js:64 [None, None, None]
localhost/:1 Uncaught Function {__args__: Array(1), stack: 'Error\n    at Array.py_pop (https://localhost:8443/…/compiled.DEBUG/main_frontend.js:6:2', __class__: ƒ}

The exception can be caught by try... except IndexError.

Thanks.

warrenchopin avatar Jun 30 '25 08:06 warrenchopin