[pywin32-checkins] pywin32/com/win32com/src PyRecord.cpp, 1.11.4.2, 1.11.4.3
OLD project page for the Python extensions for Windows
Brought to you by:
mhammond
From: Mark H. <mha...@us...> - 2008-10-01 12:53:15
|
Update of /cvsroot/pywin32/pywin32/com/win32com/src In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv25499/com/win32com/src Modified Files: Tag: py3k PyRecord.cpp Log Message: * PyUnicode_Size dies. * PyWinObject_FromTCHAR returns a unicode object in py3k, even for non-UNICODE builds. * New PyWinCoreString_FromString() helper that always returns a string in py2x and unicode in py3k * PyString_FromUnicode dies (its very rare you want a 2x style string object from unicode, and all those cases are now handled by PyWinCoreString_FromString * PyUnicodeObject_FromString takes an optional length arg. * PyWinStringObject_FromIID/PyWinUnicodeObject_FromIID replaced with PyWinCoreString_FromIID. Index: PyRecord.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/win32com/src/PyRecord.cpp,v retrieving revision 1.11.4.2 retrieving revision 1.11.4.3 diff -C2 -d -r1.11.4.2 -r1.11.4.3 *** PyRecord.cpp 13 Sep 2008 04:26:17 -0000 1.11.4.2 --- PyRecord.cpp 1 Oct 2008 12:53:00 -0000 1.11.4.3 *************** *** 3,6 **** --- 3,21 ---- // @doc + + // A refugee from pywintypes and should die + PyObject *PyString_FromUnicode( const OLECHAR *str ) + { + if (str==NULL) { + Py_INCREF(Py_None); + return Py_None; + } + PyObject *uo = PyWinObject_FromOLECHAR(str); + if (uo==NULL) return NULL; + PyObject *ret = PyUnicode_EncodeMBCS(PyUnicode_AS_UNICODE(uo), PyUnicode_GET_SIZE(uo), NULL); + Py_DECREF(uo); + return ret; + } + #ifdef LINK_AGAINST_RECORDINFO // Helpers to avoid linking directly to these newer functions *************** *** 671,680 **** ret = 0; PyObject *obattrname; ! #if (PY_VERSION_HEX < 0x03000000) ! obattrname=PyString_FromUnicode(strings[i]); ! #else ! // Py3k passes attr names as unicode ! obattrname=PyWinObject_FromWCHAR(strings[i]); ! #endif if (obattrname==NULL) return -2; --- 686,690 ---- ret = 0; PyObject *obattrname; ! obattrname=PyWinCoreString_FromString(strings[i]); if (obattrname==NULL) return -2; |