[pywin32-checkins] pywin32/com/win32com/src/extensions PyVARDESC.cpp, 1.4, 1.5
OLD project page for the Python extensions for Windows
Brought to you by:
mhammond
From: Mark H. <mha...@us...> - 2008-05-24 02:55:30
|
Update of /cvsroot/pywin32/pywin32/com/win32com/src/extensions In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19630/win32com/src/extensions Modified Files: PyVARDESC.cpp Log Message: Fix [ 1960311 ] 'None' returned for COM string constants Index: PyVARDESC.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/win32com/src/extensions/PyVARDESC.cpp,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** PyVARDESC.cpp 18 May 2008 13:43:06 -0000 1.4 --- PyVARDESC.cpp 24 May 2008 02:55:34 -0000 1.5 *************** *** 152,164 **** // Cast the variant type here to the correct value for this constant // so that the correct Python type will be created below. ! // ! // I am not sure why is there a difference between the variant data ! // passed in from the type library and the exported type... ! VariantInit(&varValue); ! VariantChangeType(&varValue, pVD->lpvarValue, 0, pVD->elemdescVar.tdesc.vt); ! value = PyCom_PyObjectFromVariant(&varValue); ! VariantClear(&varValue); } else { PyCom_LoggerWarning(NULL, "PyVARDESC ctor has unknown varkind (%d) - returning None", varkind); --- 152,179 ---- // Cast the variant type here to the correct value for this constant // so that the correct Python type will be created below. ! // The problem seems to exist for unsigned types (the variant has ! // a signed type, but the typelib has an unsigned one). However, ! // doing this unconditionally has side-effects, as the typelib ! // has VT_LPWSTR for the type of strings - and VariantChangeType ! // returns a VT_EMPTY variant in that case. ! // So we only perform this conversion for types known to be a problem: ! switch (pVD->elemdescVar.tdesc.vt) { ! case VT_UI1: ! case VT_UI2: ! case VT_UI4: ! case VT_UI8: ! case VT_UINT: ! case VT_UINT_PTR: ! VariantInit(&varValue); ! VariantChangeType(&varValue, pVD->lpvarValue, 0, pVD->elemdescVar.tdesc.vt); ! value = PyCom_PyObjectFromVariant(&varValue); ! VariantClear(&varValue); ! break; ! default: ! value = PyCom_PyObjectFromVariant(pVD->lpvarValue); ! break; ! } } else { PyCom_LoggerWarning(NULL, "PyVARDESC ctor has unknown varkind (%d) - returning None", varkind); |