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

Abierto
#901 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
3/5
Tiempo estimado
1-2 días
Aptitud para principiantes
48/100
Tipo de issue
Error
Claridad
Bastante claro
Estado de actividad
Estancado
Stack tecnológico
javascript, python
Área
compilers

Línea de trabajo

Start by running the supplied reproducer with Transcrypt 3.9.4 and compare its generated JavaScript behavior with Python's bare return semantics. Check the list.pop() path and the handling of undefined values; done means the example prints the list and removes the first element without raising IndexError.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

IS: bug?

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.

Lenguaje dominante
Python
Estrellas
2.9k
Forks
218
Métricas de merge de PR
Sin PR fusionados en 30 d

Guía de contribución

No hay ninguna guía de contribución indexada para este repositorio

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de TranscryptOrg/Transcrypt

Todos los issues de TranscryptOrg/Transcrypt

Issues similares

Más issues de Python

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.