ravipudi / pyv8

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

There is no way to return undefined from python into javascript, or to distinguish between null & undefined #192

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?

Run this code:

import PyV8

class Global(object):
    def returnNone(self):
        return None

    def out(self, var):
        print var, type(var)

ctxt = PyV8.JSContext(Global())
with ctxt:
    ctxt.eval("""
out(undefined);
out(null);
out(returnNone() === null);
out(returnNone() === undefined);
""")

What is the expected output? What do you see instead?

I would like a difference between undefined & null in Python, instead of both 
being None, and a way to return null/undefined from Python, instead of only 
being able to return 'null'.

What version of the product are you using? On what operating system?

r443, Py 2.6.6, Win 7

Please provide any additional information below.

I'd suggest having both JSNull and JSUndefined if you want to be explicit, 
otherwise None can act as it does now. 

I ask because it would be practically useful. I wrote a function that required 
distinguishing between undefined (no value) and null (a value of None), and I 
would have liked to implement it in Python, but I ended up having to do it in 
javascript.

Original issue reported on code.google.com by csaft...@gmail.com on 19 Jul 2013 at 9:58

GoogleCodeExporter commented 9 years ago
Agree, please verify the fix with SVN trunk code after r526

https://code.google.com/p/pyv8/source/detail?r=526

You can return null/undefined from Python side with JSNull/JSUndefined

Original comment by flier...@gmail.com on 12 Aug 2013 at 7:46