python / python/cpython

pyrepl should provide full traceback if possible to help debug possible buggy failures.

Abierto
#127,442 0 comentarios 1 reacción 0 asignados Ver en GitHub

Nadie ha tomado este issue todavía.

topic-repl type-feature
Lenguaje dominante
Python
Estrellas
77.2k
Forks
35.9k
Métricas de merge de PR
Métricas de PR pendientes

Descripción

Bug report

Bug description:

Currently pyrepl has the following bug that is hard to debug:

config.site_import is value: '0'
config.user_site_directory is value: '0'
config.site_import is value: '0'
config.user_site_directory is value: '0'
Python 3.14.0a2+ (heads/main-dirty:49f15d8667e, Nov 29 2024, 21:28:03) [MSC v.1943 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
C:\Users\user\AppData\Roaming\Python\Python314\site-packages\easy-install.pth
warning: can't use pyrepl: 'NoneType' object does not support the context manager protocol (missed __exit__ method)
>>> 

This bug then results in site.py getting imported anyways despite my setting config.site_import AND config.user_site_directory in my own version of Py_Initialize in my C program that embeds the interpreter on Windows (exe). This results in the incorrect appending of the user site-packages folder at the end of sys.path that I did NOT OPT into at all. I did NOT want the interpreter to go about trying to open any pth file for which my own OpenCodeHook successfully captured and printed to my console to let me know that site.py was imported when it should not have been imported at all.

As such if tracebacks were printed whenever it would print the warning that pyrepl cannot be used it would help all possible situations where pyrepl cannot be used and give the user more information into fixing the root problem itself (even if it means pull requesting this repository with a fix for pyrepl itself).

Long story short EXTRA information is better than NOT ENOUGH information to debug and fix problems with pyrepl on embedded interpreters. Likewise site.py and the user site packages folder should be optional and not a hard requirement to using pyrepl either. Basically any and all places in this repository that imports site.py without checking if both config.site_import and config.user_site_directory should be made to check them first before attempting to import it, even if pyrepl cannot be used.

CPython versions tested on:

3.14, CPython main branch

Operating systems tested on:

Windows

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 rastreando dónde pyrepl emite la advertencia de que no se puede utilizar y dónde se importa site.py durante la inicialización del intérprete. Comprueba cómo se gestionan config.site_import y config.user_site_directory, y luego identifica las pruebas que cubren intérpretes embebidos o fallos de pyrepl. Se considera completado cuando la advertencia incluye un traceback completo y se respeta la configuración indicada antes de importar site.py.

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

Evaluación

Stack tecnológico
python
Área
cli
Tipo de issue
Error
Dificultad
4/5
Tiempo estimado
3-5 días
Estado de actividad
Estancado
Claridad
Necesita aclaración
Aptitud para principiantes
30/100

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.