ipython / ipython/ipykernel

Exception in script in ~/.ipython/profile_default/startup causes other scripts to not execute

未關閉
#1,158 0 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視
主要語言
Python
星號
734
分支
412
平均合併
1 天 5 小時
30 天內合併 PR
8

描述

# Summary
If one of the files in your `~/.ipython/profile_default/startup` throws an exception, then any other file that executes later (i.e. is lexicographically higher, because startup scripts are executed in lexicographical order) will not be executed.

# To reproduce
1. Run these commands:
```
echo 'raise Exception' > ~/.ipython/profile_default/startup/a.py
echo 'x = 123' > ~/.ipython/profile_default/startup/b.py
```
2. Open a Jupyter notebook, type `x` into a cell, and press enter
# Expected behavior
It outputs 123. Ideally it also shows some information indicating that `a.py` failed to run.

# Actual behavior
It shows `NameError: name 'x' is not defined`. It also doesn't give any indication that `a.py` (or `b.py`) failed to run.

# System configuration
Kernel version:
```
Python 3.11.6 (main, Oct 2 2023, 20:46:14) [Clang 14.0.3 (clang-1403.0.22.14.1)]
Type 'copyright', 'credits' or 'license' for more information
IPython 8.16.1 -- An enhanced Interactive Python. Type '?' for help.
```

Python packages:
```
$ python3 -m pip show ipykernel | grep Version
Version: 6.25.2
```

OS version: macOS 13.3.1

# Notes
If you run
```
mv ~/.ipython/profile_default/startup/{a,c}.py
```
then it will successfully define `x` (because `b.py` runs before `c.py`).

貢獻指南

開啟貢獻指南

研究方向

Reproduce the failure with ~/.ipython/profile_default/startup/a.py and b.py, then trace the kernel's startup-script execution entry point. Verify the behavior in a Jupyter notebook: later scripts should still run after an earlier exception, and the failed script should produce some indication of the error.

由索引模型根據 Issue 內容生成。

評估

技術堆疊
jupyter-notebook, python
領域
backend
Issue 類型
缺陷
難度
3/5
預估耗時
1-2 天
活躍度
停滯
描述清晰度
基本清楚
新手友好度
48/100

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。