TypeError

10 views
Skip to first unread message

mcot

unread,
Feb 8, 2011, 4:27:17 PM2/8/11
to PyV8
I am getting a very strange error which seems to be popping up only
sporadically:

On my global object I have a write function which will just print out
values.

def write(self, val):
print val

I have code like this:

write(obj)
write(obj)

(obj is the global object itself)

The first call to write will succeed and the second call *sometimes*
fails with:

TypeError: Property 'write' of object #<error> is not a function

Sometimes it takes more than two calls:

write(obj)
write(obj)
write(obj)
write(obj) <--- TypeError: Property 'write' of object #<error> is
not a function

I can't really provide a specific piece of code that will result in
this error each time, but the code is so simple I can't see how the
global object becomes "#<error>" all of a sudden.

Flier Lu

unread,
Feb 9, 2011, 2:51:16 AM2/9/11
to PyV8
It seems caused by a reference count error, I will troubleshooting it
a few days later, just back from vacation :)

I have added a context based object cache to PyV8 weeks ago, I doubt
it introduce the issue.

thanks for your reporting

Flier Lu

unread,
Feb 13, 2011, 4:06:51 AM2/13/11
to PyV8
Hi mcot,

Could you give me some hints and examples to reproduce it? I can't
reproduce it on Windows and Ubuntu x64 with following scene.

Thanks

import PyV8

__author__ = 'Flier Lu'

class Global(PyV8.JSClass):
def write(self, val):
print val

with PyV8.JSContext(Global()) as ctxt:
ctxt.eval("""
var obj = this;

write(obj);
write(obj);
write(obj);
write(obj);
write(obj);
write(obj);
write(obj);
write(obj);

""")

for i in range(10):
ctxt.eval("write(obj);")

On Feb 9, 5:27 am, mcot <atm1...@gmail.com> wrote:

mcot

unread,
Feb 14, 2011, 4:31:18 PM2/14/11
to PyV8
This is solved for now. I had an extra context.enter() being called
from some old code. I guess thats a good case for moving to using the
"with" statement.
Reply all
Reply to author
Forward
0 new messages