Sanghyeon Seo wrote: > 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() >
Hmm.... definitely evil. :-) Maybe it could be conditional and if the encode fails then leave it as unicode? All adds overhead for converting data of course. > 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[]. > > Definitely looks better. Thanks Seo. Michael _________________________________________________ Python.NET mailing list - PythonDotNet@python.org http://mail.python.org/mailman/listinfo/pythondotnet