ipython / ipython/ipynb

__package__ = None

オープン
#39 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る
主要言語
Jupyter Notebook
スター
258
フォーク
71
PR マージ指標
30日以内にマージされた PR はありません

説明

Hi,

I found that under certain circumstances `__package__` is not defined and hence FSFinder has no package_prefix set. This leads to an error when trying to import a notebook.

Can it be that this is because `__package__` is expected to be the same as __spec__.parent beginning with Python 3.6?
https://docs.python.org/3/reference/import.html#__package__

Anyway, relying on `__package__` seems to be a risk.

Best,
Jens Henrik

---------------------
```
...python3.6/site-packages/ipynb-0.5.1-py3.6.egg/ipynb/fs/finder.py in find_spec(self=, fullname='ipynb.fs.full.job_submit', path=['...site-packages/ipynb-0.5.1-py3.6.egg/ipynb/fs/full'], target=None)
41 Claims modules that are under ipynb.fs
42 """
---> 43 if fullname.startswith(self.package_prefix):
fullname.startswith =
self.package_prefix = None
44 for path in self._get_paths(fullname):
45 if os.path.exists(path):

TypeError: startswith first arg must be str or a tuple of str, not NoneType
```

コントリビューションガイド

このリポジトリのコントリビューションガイドは索引されていません

調査の方向性

ipynb/fs/finder.py の FSFinder.find_spec から始め、package_prefix が __package__ からどのように導出されるかを調べます。報告されている状況で notebook の import を再現しながら、その値を __spec__.parent と比較します。finder が startswith に None を渡さなくなり、notebook の import が成功すれば完了です。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
jupyter-notebook, python
領域
tooling
issue の種類
バグ
難易度
3/5
見積もり時間
1〜2日
活発さ
停滞
明瞭さ
おおむね明確
初心者へのやさしさ
35/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。