[pywin32-checkins] pywin32/win32/src PyLARGE_INTEGER.cpp, 1.13, 1.14
OLD project page for the Python extensions for Windows
Brought to you by:
mhammond
From: Mark H. <mha...@us...> - 2008-12-11 00:46:37
|
Update of /cvsroot/pywin32/pywin32/win32/src In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv14098 Modified Files: PyLARGE_INTEGER.cpp Log Message: Correct large-int handling from last checking: * Allow ints and longs in py2x * reinstate support for 2 ints, but raise a PendingDeprecationWarning Index: PyLARGE_INTEGER.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/src/PyLARGE_INTEGER.cpp,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** PyLARGE_INTEGER.cpp 11 Dec 2008 00:25:40 -0000 1.13 --- PyLARGE_INTEGER.cpp 11 Dec 2008 00:46:31 -0000 1.14 *************** *** 22,33 **** BOOL PyWinObject_AsLARGE_INTEGER(PyObject *ob, LARGE_INTEGER *pResult) { ! pResult->QuadPart=PyLong_AsLongLong(ob); ! return !(pResult->QuadPart == -1 && PyErr_Occurred()); } BOOL PyWinObject_AsULARGE_INTEGER(PyObject *ob, ULARGE_INTEGER *pResult) { ! pResult->QuadPart=PyLong_AsUnsignedLongLong(ob); ! return !(pResult->QuadPart == (ULONGLONG) -1 && PyErr_Occurred()); } --- 22,74 ---- BOOL PyWinObject_AsLARGE_INTEGER(PyObject *ob, LARGE_INTEGER *pResult) { ! if (PyInt_Check(ob)) { ! // 32 bit integer value. ! int x = PyInt_AS_LONG(ob); ! if (x==(int)-1 && PyErr_Occurred()) ! return FALSE; ! LISet32(*pResult, x); ! return TRUE; ! } else if (PyLong_Check(ob)) { ! pResult->QuadPart=PyLong_AsLongLong(ob); ! return !(pResult->QuadPart == -1 && PyErr_Occurred()); ! } else { ! PyErr_Warn(PyExc_PendingDeprecationWarning, "Support for passing 2 integers to create a 64bit value is deprecated - pass a long instead"); ! long hiVal, loVal; ! if (!PyArg_ParseTuple(ob, "ll", &hiVal, &loVal)) { ! PyErr_SetString(PyExc_TypeError, "LARGE_INTEGER must be 'int', or '(int, int)'"); ! return FALSE; ! } ! // ### what to do about a "negative" loVal?! ! pResult->QuadPart = (((__int64)hiVal) << 32) | loVal; ! return TRUE; ! } ! assert(0); // not reached. } BOOL PyWinObject_AsULARGE_INTEGER(PyObject *ob, ULARGE_INTEGER *pResult) { ! if (PyInt_Check(ob)) { ! // 32 bit integer value. ! int x = PyInt_AS_LONG(ob); ! if (x==(int)-1 && PyErr_Occurred()) ! return FALSE; ! // ### what to do with "negative" integers? Nothing - they ! // get treated as unsigned! ! ULISet32(*pResult, x); ! return TRUE; ! } else if (PyLong_Check(ob)) { ! pResult->QuadPart=PyLong_AsUnsignedLongLong(ob); ! return !(pResult->QuadPart == (ULONGLONG) -1 && PyErr_Occurred()); ! } else { ! PyErr_Warn(PyExc_PendingDeprecationWarning, "Support for passing 2 integers to create a 64bit value is deprecated - pass a long instead"); ! long hiVal, loVal; ! if (!PyArg_ParseTuple(ob, "ll", &hiVal, &loVal)) { ! PyErr_SetString(PyExc_TypeError, "ULARGE_INTEGER must be 'int', or '(int, int)'"); ! return FALSE; ! } ! pResult->QuadPart = (((__int64)hiVal) << 32) | loVal; ! return TRUE; ! } ! assert(0); // not reached. } |