python stack frames not initialized (inspect.currentframe() fails)
- 主要语言
- Julia
- 星标
- 1.5k
- 派生
- 186
- PR 合并指标
- 30 天内没有已合并 PR
描述
I was trying to use `PyCall` to import `ggplot` from https://github.com/yhat/ggplot/
The `qplot` function works fine.
```
ggplot.qplot([1,2],[3,4])
```
However, I can never get the `ggplot` function working. Specially, I can never create the `aes` class
```
julia> using PyCall
julia> @pyimport ggplot
julia> ggplot.aes
PyObject
julia> ggplot.aes(x="x",y="y")
ERROR: type: apply: expected Function, got PyObject
julia> pycall(ggplot.aes, PyObject, x="x",y="y")
ERROR: PyError (PyObject_Call)
AttributeError("'NoneType' object has no attribute 'f_locals'",)
File "/Users/Randy/.pyenv/versions/2.7.6/Python.framework/Versions/2.7/lib/python2.7/site-packages/ggplot/components/aes.py", line 68, in __init__
self.__eval_env__ = EvalEnvironment.capture(1)
File "/Users/Randy/.pyenv/versions/2.7.6/Python.framework/Versions/2.7/lib/python2.7/site-packages/patsy/eval.py", line 179, in capture
return cls([frame.f_locals, frame.f_globals],
in pyerr_check at /Users/Randy/.julia/v0.3/PyCall/src/exception.jl:58
in pycall at /Users/Randy/.julia/v0.3/PyCall/src/PyCall.jl:85
```
It seems that `ggplot` is calling `patsy` and checking some stack frame stuff.
---
Further study reveals that the root of the error is `.../patsy/eval.py` line 179
```
frame = inspect.currentframe()
try:
for i in xrange(depth + 1):
if frame is None:
raise ValueError, "call-stack is not that deep!"
frame = frame.f_back
return cls([frame.f_locals, frame.f_globals],
frame.f_code.co_flags & _ALL_FUTURE_FLAGS)
```
I have no idea what happens here...
贡献指南
这个仓库没有索引到贡献指南
调研方向
通过 PyCall 调用 ggplot.aes 重现该故障,然后检查第 179 行的 patsy/eval.py,以及 src/exception.jl 和 src/PyCall.jl 中相关的 PyCall 路径。确定为什么在此调用路径中 inspect.currentframe() 没有可用的 frame;当 aes 构造函数完成且不再出现所报告的 AttributeError 时,即表示完成。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- julia, python
- 领域
- tooling
- Issue 类型
- 缺陷
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 活跃度
- 停滞
- 描述清晰度
- 需要澄清
- 新手友好度
- 30/100