Re: [Python.NET] Experimental C Extensions from IronPython with Python.NET - code and article
2007/10/24, Michael Foord
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
participants (2)
-
Michael Foord
-
Sanghyeon Seo