`else` block in `try` statement swallows exceptions
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 4/5
- Tiempo estimado
- 3-5 días
- Aptitud para principiantes
- 35/100
- Tipo de issue
- Error
- Claridad
- Bastante claro
- Estado de actividad
- Estancado
- Stack tecnológico
- javascript, python
- Área
- compilers
Línea de trabajo
No source file or test is named. Start by tracing how the compiler translates the provided Python try/except/else example, then verify that an exception raised in the else block reaches the outer context instead of being swallowed; issue #99 may provide related history.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
Exceptions raised in the else block should bubble out, but instead they currently get suppressed.
This:
try:
pass
except:
pass
else:
raise Exception('something wrong happened in the `else`')
compiles to:
try {
// pass;
try {
var __except0__ = Exception ('something wrong happened in the `else`');
__except0__.__cause__ = null;
throw __except0__;
}
catch (__except0__) {
}
}
catch (__except0__) {
// pass;
}
I suggest: set a temporary boolean variable to true before the try, then flip it to false as the very first statement inside the catch, and then have an if statement on that boolean as the very first statement after the catch block (it might be better to just always generate that if inside a finally in the JavaScript even if there is no finally in the Python, because it has to execute before any finally if it does exist).
(My reasoning for flipping the boolean as the first statement in the catch instead of the last statement in the try is that if for some reason ever a JavaScript implementation existed that raised an exception while trying to set that internal implementation book-keeping variable, I think it better that our generated code explode that up a level, instead of it being caught by the local except block, because logically that is an error within the try statement itself, not the block of code inside it.)
P.S. In similar situations in the future, would you prefer I reopened #99 instead of creating this new issue?
- 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
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de TranscryptOrg/Transcrypt
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 84/100
TranscryptOrg/Transcrypt#913 ·
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 88/100
TranscryptOrg/Transcrypt#911 · 2 comentarios ·
-
IS: bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 70/100
TranscryptOrg/Transcrypt#908 ·
-
SUB: documentation
Dificultad 1/5 Menos de una hora Aptitud para principiantes 62/100
TranscryptOrg/Transcrypt#656 · 7 comentarios ·
-
Dificultad 3/5 1-2 días Aptitud para principiantes 76/100
TranscryptOrg/Transcrypt#914 ·
Todos los issues de TranscryptOrg/Transcrypt
Issues similares
-
bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 86/100
zostera/django-bootstrap4#894 ·
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
use-agent-os/agent-os#3276 ·
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 88/100
zephyrproject-rtos/zephyr#119726 ·
-
area/auth bug comp/agent P3 platform/discord type/security
Dificultad 2/5 1-3 horas Aptitud para principiantes 88/100
NousResearch/hermes-agent#117848 ·
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 82/100
zilliztech/memsearch#759 ·