Update of /cvsroot/pywin32/pywin32/com/win32com/src/extensions
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12983/win32com/src/extensions
Modified Files:
PyVARDESC.cpp
Log Message:
Fix issue [ 1651025 ] Use the specified type for constant values
This makes constants in a typelib > sys.maxint to correctly be a long
Index: PyVARDESC.cpp
===================================================================
RCS file: /cvsroot/pywin32/pywin32/com/win32com/src/extensions/PyVARDESC.cpp,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** PyVARDESC.cpp 1 Sep 1999 23:03:33 -0000 1.1
--- PyVARDESC.cpp 7 Feb 2007 23:12:31 -0000 1.2
***************
*** 144,150 ****
if (pVD->varkind == VAR_PERINSTANCE)
value = PyInt_FromLong(pVD->oInst);
! else if (pVD->varkind == VAR_CONST)
! value = PyCom_PyObjectFromVariant(pVD->lpvarValue);
! else {
value = Py_None;
Py_INCREF(Py_None);
--- 144,162 ----
if (pVD->varkind == VAR_PERINSTANCE)
value = PyInt_FromLong(pVD->oInst);
! else if (pVD->varkind == VAR_CONST) {
! VARIANT varValue;
!
! // 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 {
value = Py_None;
Py_INCREF(Py_None);
|