Skip to content

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

@warrenchopin

Description

@warrenchopin

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions