FromManagedObject wasn't handling this correctly - I've added
a fix for the next release. In the meantime, the easiest thing
to do is something like:
PyObject module = PythonEngine.ImportModule("script")
PyObject none = module.GetAttr("aliasForNone")
(this presumes that in the module you have created the name
'aliasForNone' and assigned it to None)
Brian Lloyd [EMAIL PROTECTED]
V.P. Engineering 540.361.1716
Zope Corporation http://www.zope.com
> -----Original Message-----
> From: [EMAIL PROTECTED]
> [mailto:[EMAIL PROTECTED] Behalf Of Boris Capitanu
> Sent: Thursday, April 14, 2005 1:38 PM
> To: [email protected]
> Subject: [Python.NET] How to get 'None' from .NET?
>
>
> Hello,
>
> I'm trying to call from .NET some function defined in
> a Python script, and pass 'null' as one of the
> parameters of the function in certain situations. I
> was expecting that the bridge would map the 'null' in
> .NET to 'None' in Python, however I receive an
> exception in .NET when I execute the code.
>
> I have something like the following:
>
> --------------
> 1. PyObject module =
> PythonEngine.ImportModule("script")
> 2. PyObject func = module.GetAttr("someFunction")
>
> 3. object aNullObject = null
>
> 4. PyObject[] arguments = new PyObject[2]
> 5. arguments[0] = PyObject.FromManagedObject("a
> string")
> 6. arguments[1] =
> PyObject.FromManagedObject(aNullObject)
> // I also tried: arguments[1] = null directly
>
> 8. func.Invoke(arguments)
> --------------------
>
> When executed, line 6 throws a NullReferenceException
> if I use 'arguments[1] = null' instead of line 6, I
> get a NullReferenceException in line 8.
>
> How can I pass 'null' to a script?
>
> Thank you.
>
> Boris
>
>
>
> __________________________________
> Do you Yahoo!?
> Yahoo! Small Business - Try our new resources site!
> http://smallbusiness.yahoo.com/resources/
> _________________________________________________
> Python.NET mailing list - [email protected]
> http://mail.python.org/mailman/listinfo/pythondotnet
>
_________________________________________________
Python.NET mailing list - [email protected]
http://mail.python.org/mailman/listinfo/pythondotnet