tbodt / v8py

Write Python APIs, then call them from JavaScript using the V8 engine.
GNU Lesser General Public License v3.0
443 stars 29 forks source link

Is greenstack required? #17

Closed AlexHill closed 7 years ago

AlexHill commented 7 years ago

More questions!

In greenstack.cpp:

     PyGreenstack_Import();
    if (_PyGreenstack_API == NULL) {
        // No greenlets? No problems!
        return 0;
}

And in v8py.cpp:

 if (greenstack_init() < 0) return FAIL;

This and the fact that the package isn't a dependency in setup.py makes me think greenstack isn't meant to be required. But if I just pip install v8py, open Python and import v8py, I get ImportError: PyCapsule_Import could not import module "greenstack" during from _v8py import *, I guess because as well as returning NULL, PyCapsule_Import sets an exception.

What's meant to happen here?

AlexHill commented 7 years ago

This is on Python 2.7.12 on Ubuntu 16.04, latest v8py master and 0.9.12.

tbodt commented 7 years ago

Yes, greenstack is not suppose to be required. This is a bug, I'll investigate. For what it's worth, it seems to work fine on Python 3.

tbodt commented 7 years ago

The solution is probably PyErr_Clear if greenstack is not present.

AlexHill commented 7 years ago

I get the same error in Python 3.5.2, but with an extra exception:

(v8py-env) $ python
Python 3.5.2 (default, Sep 14 2017, 22:51:06) 
[GCC 5.4.0 20160609] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import v8py
ImportError: PyCapsule_Import could not import module "greenstack"

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/alexh/v8py-env/lib/python3.5/site-packages/v8py/__init__.py", line 1, in <module>
    from _v8py import *
  File "<frozen importlib._bootstrap>", line 968, in _find_and_load
SystemError: PyEval_EvalFrameEx returned a result with an error set
>>> 
tbodt commented 7 years ago

Uh oh!

Looks like I was wrong.

tbodt commented 7 years ago

Fix should still just be PyErr_Clear.

AlexHill commented 7 years ago

Fixed in #18