marylinh / pyv8

Automatically exported from code.google.com/p/pyv8
0 stars 0 forks source link

__define[GS]etter__ works differently for Python objects #18

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
While trying to port env.js to v8, ran into this issue. Here t1 is defined
in JS, t2 in Python with JSClass(), but __defineGetter__ for t2 returns the
unbound property object:

Python 2.6.4 (r264:75706, Dec  7 2009, 18:45:15)
[GCC 4.4.1] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import PyV8
>>> js = """
...
... var t1 = {};
...
... t1.__defineGetter__('attr', function() {
...     debug('t1.attr');
...     return 't1.attr';
... });
...
... t2.__defineGetter__('attr', function() {
...     debug('t2.attr');
...     return 't2.attr';
... });
...
... debug(t1.attr);
... debug(t2.attr);
...
... """
>>>
>>> class Globals(PyV8.JSClass):
...     t2 = PyV8.JSClass()
...     def debug(self, str):
...         print str
...
>>> with PyV8.JSContext(Globals()) as ctx:
...     ctx.eval(js)
...
t1.attr
t1.attr
<property object at 0xb7655a54>

Original issue reported on code.google.com by sciyoshi on 30 Dec 2009 at 9:55

GoogleCodeExporter commented 9 years ago
The root cause is python handle property in different way with javascript, I 
have add 
the automatic bi-way support, please check out the source from SVN after 
revision #185 
to verify it.

Original comment by flier...@gmail.com on 31 Dec 2009 at 6:32

GoogleCodeExporter commented 9 years ago
Fixed, and quickly too :-)

Thanks a lot!

Original comment by sciyoshi on 31 Dec 2009 at 6:41

GoogleCodeExporter commented 9 years ago
just finish it in 2009, happy new year :D

Original comment by flier...@gmail.com on 31 Dec 2009 at 7:12