`else` block in `try` statement swallows exceptions
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Idoneità per principianti
- 35/100
- Tipo di issue
- Bug
- Chiarezza
- Abbastanza chiara
- Stato di attività
- Ferma
- Stack tecnologico
- javascript, python
- Ambito
- compilers
Direzione di ricerca
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.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
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?
- Lingua principale
- Python
- Stelle
- 2.9k
- Fork
- 218
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Guida per i contributori
Nessuna guida per i contributori indicizzata per questo repository
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di TranscryptOrg/Transcrypt
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 84/100
TranscryptOrg/Transcrypt#913 ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 88/100
TranscryptOrg/Transcrypt#911 · 2 commenti ·
-
IS: bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
TranscryptOrg/Transcrypt#908 ·
-
SUB: documentation
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 62/100
TranscryptOrg/Transcrypt#656 · 7 commenti ·
-
Difficoltà 3/5 1-2 giorni Idoneità per principianti 76/100
TranscryptOrg/Transcrypt#914 ·
Tutte le issue di TranscryptOrg/Transcrypt
Issue simili
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 90/100
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 86/100
zostera/django-bootstrap4#894 ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
use-agent-os/agent-os#3276 ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 88/100
zephyrproject-rtos/zephyr#119726 ·
-
area/auth bug comp/agent P3 platform/discord type/security
Difficoltà 2/5 1-3 ore Idoneità per principianti 88/100
NousResearch/hermes-agent#117848 ·