CWD is not in sys.path when "-P" is used
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 3/5
- Tiempo estimado
- 1-2 días
- Aptitud para principiantes
- 48/100
Línea de trabajo
Comienza con la función init_path y el cambio vinculado; después, reproduce la invocación de IPython al estilo de Fedora /usr/bin/python3 -P mientras inspeccionas sys.path. Compara el comportamiento entre los modos de ejecución de Python documentados y actualiza la implementación o el docstring para que el manejo de CWD coincida con el modo real; se considera terminado cuando la inconsistencia reportada esté resuelta y verificada.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
I've got a report from a user after the fresh release of Fedora 44, where IPython 9.9 is included. You can read it here, but I'll sum it up below as well: https://bugzilla.redhat.com/show_bug.cgi?id=2479711
Since IPython 9.7.0, CWD is not in sys.path when you use a system-installed IPython from RPM packages.
The problem is caused by this change: https://github.com/ipython/ipython/commit/bb8b2bab0f68088b15a4da0cd7ec6e6bfcafd6c9
and the fact that "-P" flag is by default in all Python shebangs for all executable files in Fedora. For IPython, /usr/bin/ipython looks like:
#! /usr/bin/python3 -P
import sys
from IPython import start_ipython
if __name__ == '__main__':
if sys.argv[0].endswith('.exe'):
sys.argv[0] = sys.argv[0][:-4]
sys.exit(start_ipython())
The commit linked above mentions this:
sys.flags.safe_path is python's equivalent to of the ipython flag
ignore_cwd. It is most often set by PYTHONSAFEPATH or by running
python with -P.
which is not entirely true because what is omitted from sys.path when you use "-P" depends on how the python/script/module is run, see: https://docs.python.org/3/using/cmdline.html#cmdoption-P
We've implemented the default "-P" option in this Fedora change because we wanted to avoid /usr/bin to be in the sys.path which caused strange behavior sometimes.
So now, with "-P" in the shebang, we don't have CWD in sys.path but when we remove the flag, we do have /usr/bin/ there, which we want to avoid.
Because the commit message and the docstring of the init_path function are not entirely correct, I consider this to be a bug in IPython. Whether CWD should be omitted or not depends on how the Python is executed, not just on the "-P" flag or the corresponding env variable.
- Lenguaje dominante
- Python
- Estrellas
- 16.8k
- Forks
- 4.5k
- Merge medio
- 1 d 2 h
- PR fusionados (30 d)
- 6
Guía de contribución
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 ipython/ipython
-
Dificultad 1/5 Menos de una hora Aptitud para principiantes 78/100
-
autoreload breaks on partial Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 64/100
-
bug magics
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
-
Dificultad 5/5 Más de una semana Aptitud para principiantes 25/100
Todos los issues de ipython/ipython
Issues similares
-
triage/confirmed
Dificultad 2/5 1-3 horas Aptitud para principiantes 88/100
agentscope-ai/agentscope#2775 ·
-
comp/desktop P3 type/bug
Dificultad 1/5 Menos de una hora Aptitud para principiantes 92/100
NousResearch/hermes-agent#118866 ·
-
bug
Dificultad 1/5 Menos de una hora Aptitud para principiantes 90/100
apache/cloudstack#14222 ·
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
-
bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 82/100