2007/10/24, Michael Foord <[EMAIL PROTECTED]>:
> I've just posted the experimental code for accessing CPython extensions
> from IronPython.
>
> Article: http://www.voidspace.org.uk/ironpython/cpython_extensions.shtml
>
> Comments, bugfixes and improvements welcomed!
* Strings from .NET come in as unicode on the CPython type
An evil workaround is to define PyStringConvert as:
def PyStringConvert(obj):
# evil
return PyString(obj).GetAttr('encode').Invoke()
This could be improved on Python.NET side. Any idea?
* Can't yet pass in keyword args to function calls.
This is related to the previous item, because:
>>> def f(a): pass
>>> f(**{u'a': 1})
TypeError: f() keywords must be strings
With the previous workaround in place, replace PythonObject.__call__ with:
def __call__(self, *args, **kw):
args = ConvertToPy(args)
kw = ConvertToPy(kw)
return ConvertToIpy(self.real.Invoke(args, kw))
This is more straightforward than creating PyObject[].
--
Seo Sanghyeon
_________________________________________________
Python.NET mailing list - [email protected]
http://mail.python.org/mailman/listinfo/pythondotnet