Summary: cannot use a global object that is an instance of a class that
inherits from "object".
Steps to reproduce:
1.
$ cat global_object_error.py
import spidermonkey
rt=spidermonkey.Runtime()
class Glob(object):
pass
c=rt.new_context(Glob())
$ python global_object_error.py
binding a global class: <class '__main__.Glob'>
registering a python class as name type
ProxyClass context_get_class - cl.jsc.name == type
Traceback (most recent call last):
File "global_object_error.py", line 5, in <module>
c=rt.new_context(Glob())
File "spidermonkey.pyx", line 463, in spidermonkey.Runtime.new_context
File "spidermonkey.pyx", line 517, in spidermonkey.Context.__init__
File "spidermonkey.pyx", line 690, in spidermonkey.context_get_class
ValueError: no class named 'Glob' is bound
2.
now just remove the (object):
$ cat global_old_object.py
import spidermonkey
rt=spidermonkey.Runtime()
class Glob:
pass
c=rt.new_context(Glob())
$ python global_old_object.py
binding a global class: __main__.Glob
registering a python class as name Glob
ProxyClass context_get_class - cl.jsc.name == Glob
3. the printout is some debug code I inserted into spidermonkey.pyx:
$ svn diff
Index: spidermonkey.pyx
===================================================================
--- spidermonkey.pyx (revision 23)
+++ spidermonkey.pyx (working copy)
@@ -512,6 +512,7 @@
self._evaled_script = []
if globj:
+ print "binding a global class: %s" % (globj.__class__)
self.bind_class(globj.__class__, False, True)
proxy_class = context_get_class(self, js_classname(globj))
self.globj = JS_NewObject(self.cx, proxy_class.jsc, NULL, NULL)
@@ -683,6 +684,7 @@
cdef ProxyClass context_get_class(Context self, name):
cdef ProxyClass cl
for cl in self._classes:
+ print "ProxyClass context_get_class - cl.jsc.name == %s" % cl.jsc.name
if cl.jsc.name == name:
return cl
raise ValueError("no class named '%s' is bound" % name)
@@ -700,6 +702,7 @@
name = js_classname(klass)
self.jsc.name = <char *> xmalloc((len(name)+1)*sizeof(char))
strcpy(self.jsc.name, name)
+ print "registering a python class as name %s" % name
# not using Get/SetPrivate ATM
#self.jsc.flags = JSCLASS_HAS_PRIVATE
What is the expected output? What do you see instead?
What version of the product are you using? On what operating system?
svn revision 23.
linux (ubuntu intrepid beta)
Please provide any additional information below.
I love the ability to access my xul javascript from python - too bad I need
to reimplement all the API (dom + mozilla specific).
Original issue reported on code.google.com by alonle...@gmail.com on 14 Oct 2008 at 11:35
Original issue reported on code.google.com by
alonle...@gmail.com
on 14 Oct 2008 at 11:35