python / python/cpython

IDLE - there is no known way to trigger atexit functions

Abierto
#98,318 2 comentarios 0 reacciones 0 asignados Ver en GitHub

Nadie ha tomado este issue todavía.

topic-IDLE type-bug
Lenguaje dominante
Python
Estrellas
77.2k
Forks
36k
Merge medio
1 d 9 h
PR fusionados (30 d)
558

Descripción

Bug report

Hello!

So this has been an issue that has probably been bugging many people for a while now. This has bitten me back when I was a newbie as well, learning python using IDLE. This issue does not personally affect me anymore since I've mostly moved on from IDLE, but for the sake of others new to the language, I would like to formalise this issue on the tracker.

Here is a pure python MRE that demonstrates what I'm saying

import atexit
import time

@atexit.register
def done():
    print("Exiting application!")

time.sleep(1)

When I run this on the command-line with no flags, I see the text printed after the program runs for a second and exits. On IDLE, this just runs for a second and exits without printing anything.

So I later realised that IDLE runs programs with the -i flag. But on the commandline I can do a ctrl+z and get the interpreter to actually stop and handle atexit. This is not apparent in IDLE shell, where there does not seem to be any distinction between the "regular interactive state", and the "previous module run interactive state". And neither does ctrl+c/z/d work. A hard shell restart also does not lead to anything being printed.

I've glanced through the issue tracker with a quick search and I didn't find a duplicate of this issue, but incase I'm mistaken, my apologies; this issue can be closed.

Your environment

  • CPython versions tested on: 3.10 (but from my memory, it happened on all previous versions too)
  • Operating system and architecture: Windows 11 64-bit (In my understanding it also happens on other architectures and OSes)

Guía de contribución

Abrir la guía de contribución

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.

Línea de trabajo

Comienza ejecutando el reproductor de atexit proporcionado y escrito únicamente en Python en IDLE y desde la línea de comandos; después, compara los estados normal y posterior a la ejecución del módulo de la shell de IDLE. Se considera terminado cuando IDLE ofrece una forma clara de llegar al estado del intérprete que ejecuta las funciones atexit registradas, y la salida indicada aparece después de que termina el módulo.

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

Evaluación

Stack tecnológico
python
Área
desktop, tooling
Tipo de issue
Error
Dificultad
4/5
Tiempo estimado
3-5 días
Estado de actividad
Estancado
Claridad
Bastante claro
Aptitud para principiantes
35/100

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.