[omniORB] omniORBpy and Python 2.0 Unicode

uche.ogbuji@fourthought.com uche.ogbuji@fourthought.com
Tue, 12 Dec 2000 00:18:08 -0700


Well, I didn't get any help on my unicode problem, and I needed to get around 
it, so I worked up the following patch to allow omniORBpy marshall Python 2.0 
Unicode objects by converting them to UTF-8 strings.

This is not a comprehensive fix, of course (more of a hack), but it is enough 
for most systems where all strings are assumed to be encoded, which is true of 
4Suite Server.

Hopefully it comes in handy for someone else.


diff -Naur omniORBpy.orig/modules/common/pyMarshal.cc 
omniORBpy/modules/common/pyMarshal.cc
--- omniORBpy.orig/modules/common/pyMarshal.cc	Thu Sep 21 07:20:15 2000
+++ omniORBpy/modules/common/pyMarshal.cc	Tue Dec 12 00:12:35 2000
@@ -541,6 +541,12 @@
 
       CORBA::ULong max_len = PyInt_AS_LONG(t_o);
 
+      if (PyUnicode_Check(a_o)){
+        t_o = a_o;
+        a_o = PyUnicode_AsEncodedString(t_o, NULL, NULL);
+        Py_XINCREF(a_o);
+        Py_XDECREF(t_o);
+      }
       if (!PyString_Check(a_o)) AS_THROW_BAD_PARAM;
 
       CORBA::ULong len = PyString_GET_SIZE(a_o);


-- 
Uche Ogbuji                               Principal Consultant
uche.ogbuji@fourthought.com               +1 303 583 9900 x 101
Fourthought, Inc.                         http://Fourthought.com 
4735 East Walnut St, Ste. C, Boulder, CO 80301-2537, USA
Software-engineering, knowledge-management, XML, CORBA, Linux, Python