Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

context.__exit__ is not called if with block returns

Aperta
#799 7 commenti 0 reazioni 0 assegnatari Vedi su GitHub

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

Start by reproducing the provided Python context-manager example and tracing the compiler path that generates the shown JavaScript for the with block. The fix is done when exit is called before a return leaves the block, while exception handling still behaves as shown.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

Please transcrypt the following code:

class Context:
    def __enter__(self):
        print("enter")

    def __exit__(self, exc_type, exc_val, exc_tb):
        print("exit")
        return False


def main():
    with Context():
        print("exit is not called")
        return


document.addEventListener('DOMContentLoaded', main)

The main function ist transcripted to

export var main = function () {
	var __withid0__ = Context ();
	try {
		__withid0__.__enter__ ();
		print ('exit is not called');
		return ;
		__withid0__.__exit__ ();
	}
	catch (__except0__) {
		if (! (__withid0__.__exit__ (__except0__.name, __except0__, __except0__.stack))) {
			throw __except0__;
		}
	}
};

As you can see the return statement is generated before calling exit.

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

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di TranscryptOrg/Transcrypt

Tutte le issue di TranscryptOrg/Transcrypt

Issue simili

Altre issue su Python

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.