Update of /cvsroot/pywin32/pywin32/win32/src
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7597
Modified Files:
PyTime.cpp
Log Message:
Allow any date-like object for any method wanting a win32 time object
(eg, datetime objects can be passed directly to COM,
win32file.SetFileTime, etc)
Index: PyTime.cpp
===================================================================
RCS file: /cvsroot/pywin32/pywin32/win32/src/PyTime.cpp,v
retrieving revision 1.12
retrieving revision 1.13
diff -C2 -d -r1.12 -r1.13
*** PyTime.cpp 26 May 2004 08:30:41 -0000 1.12
--- PyTime.cpp 4 Mar 2005 11:56:55 -0000 1.13
***************
*** 36,51 ****
}
! // @pymethod <o PyTime>|pywintypes|Time|Creates a new time object.
! PyObject *PyWinMethod_NewTime(PyObject *self, PyObject *args)
{
- PyObject *timeOb;
- // @pyparm object|timeRepr||An integer/float/tuple time representation.
- // @comm Note that the parameter can be any object that supports
- // int(object) - for example , another PyTime object.
- // <nl>The integer should be as defined by the Python time module.
- // See the description of the <o PyTime> object for more information.
- if ( !PyArg_ParseTuple(args, "O", &timeOb) )
- return NULL;
-
PyObject *result = NULL;
/***** Commented out temporarily
--- 36,41 ----
}
! PyObject *PyWin_NewTime(PyObject *timeOb)
{
PyObject *result = NULL;
/***** Commented out temporarily
***************
*** 100,109 ****
}
else
! {
! PyErr_BadArgument();
return NULL;
- }
! return result;
}
--- 90,111 ----
}
else
! return PyErr_Format(PyExc_TypeError, "Objects of type '%s' can not be used as a time object",
! timeOb->ob_type->tp_name);
! return result;
! }
!
! // @pymethod <o PyTime>|pywintypes|Time|Creates a new time object.
! PyObject *PyWinMethod_NewTime(PyObject *self, PyObject *args)
! {
! PyObject *timeOb;
! // @pyparm object|timeRepr||An integer/float/tuple time representation.
! // @comm Note that the parameter can be any object that supports
! // int(object) - for example , another PyTime object.
! // <nl>The integer should be as defined by the Python time module.
! // See the description of the <o PyTime> object for more information.
! if ( !PyArg_ParseTuple(args, "O", &timeOb) )
return NULL;
! return PyWin_NewTime(timeOb);
}
***************
*** 127,152 ****
BOOL PyWinObject_AsDATE(PyObject *ob, DATE *pDate)
{
if (!PyTime_Check(ob)) {
! PyErr_SetString(PyExc_TypeError, "The object is not a PyTime object");
! return FALSE;
}
! return ((PyTime *)ob)->GetTime(pDate);
}
BOOL PyWinObject_AsFILETIME(PyObject *ob, FILETIME *pDate)
{
if (!PyTime_Check(ob)) {
! PyErr_SetString(PyExc_TypeError, "The object is not a PyTime object");
! return FALSE;
}
! return ((PyTime *)ob)->GetTime(pDate);
}
BOOL PyWinObject_AsSYSTEMTIME(PyObject *ob, SYSTEMTIME *pDate)
{
if (!PyTime_Check(ob)) {
! PyErr_SetString(PyExc_TypeError, "The object is not a PyTime object");
! return FALSE;
}
! return ((PyTime *)ob)->GetTime(pDate);
}
--- 129,169 ----
BOOL PyWinObject_AsDATE(PyObject *ob, DATE *pDate)
{
+ PyObject *newref = NULL;
+ BOOL rc;
if (!PyTime_Check(ob)) {
! if (!(ob = PyWin_NewTime(ob)))
! return FALSE;
! newref = ob;
}
! rc = ((PyTime *)ob)->GetTime(pDate);
! Py_XDECREF(newref);
! return rc;
}
BOOL PyWinObject_AsFILETIME(PyObject *ob, FILETIME *pDate)
{
+ PyObject *newref = NULL;
+ BOOL rc;
if (!PyTime_Check(ob)) {
! if (!(ob = PyWin_NewTime(ob)))
! return FALSE;
! newref = ob;
}
! rc = ((PyTime *)ob)->GetTime(pDate);
! Py_XDECREF(newref);
! return rc;
}
BOOL PyWinObject_AsSYSTEMTIME(PyObject *ob, SYSTEMTIME *pDate)
{
+ PyObject *newref = NULL;
+ BOOL rc;
if (!PyTime_Check(ob)) {
! if (!(ob = PyWin_NewTime(ob)))
! return FALSE;
! newref = ob;
}
! rc = ((PyTime *)ob)->GetTime(pDate);
! Py_XDECREF(newref);
! return rc;
}
|