Update of /cvsroot/pywin32/pywin32/win32/src
In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv24579/win32/src
Modified Files:
Tag: py3k
PySID.cpp PySecurityObjects.h win32apimodule.cpp
win32trace.cpp
Log Message:
merge recent changes from the trunk
Index: win32apimodule.cpp
===================================================================
RCS file: /cvsroot/pywin32/pywin32/win32/src/win32apimodule.cpp,v
retrieving revision 1.89.2.4
retrieving revision 1.89.2.5
diff -C2 -d -r1.89.2.4 -r1.89.2.5
*** win32apimodule.cpp 28 Dec 2008 10:58:11 -0000 1.89.2.4
--- win32apimodule.cpp 25 Jan 2009 04:52:20 -0000 1.89.2.5
***************
*** 105,108 ****
--- 105,135 ----
return PyWin_SetAPIError(fnName, err);
}
+
+ PyObject *PyTuple_FromSYSTEMTIME(SYSTEMTIME &st)
+ {
+ return Py_BuildValue("iiiiiiii",
+ st.wYear,
+ st.wMonth,
+ st.wDayOfWeek,
+ st.wDay,
+ st.wHour,
+ st.wMinute,
+ st.wSecond,
+ st.wMilliseconds);
+ }
+
+ BOOL PyTuple_AsSYSTEMTIME(PyObject *ob, SYSTEMTIME &st)
+ {
+ return PyArg_ParseTuple(ob, "iiiiiiii",
+ &st.wYear,
+ &st.wMonth,
+ &st.wDayOfWeek,
+ &st.wDay,
+ &st.wHour,
+ &st.wMinute,
+ &st.wSecond,
+ &st.wMilliseconds);
+ }
+
// @pymethod |win32api|Beep|Generates simple tones on the speaker.
static PyObject *
***************
*** 2345,2349 ****
PyGetTimeZoneInformation(PyObject * self, PyObject * args)
{
! if (!PyArg_ParseTuple (args, ":GetTimeZoneInformation"))
return NULL;
TIME_ZONE_INFORMATION tzinfo;
--- 2372,2378 ----
PyGetTimeZoneInformation(PyObject * self, PyObject * args)
{
! int bTimesAsTuples = 0;
! // @pyparm bool|times_as_tuples|False|If true, the SYSTEMTIME elements are returned as tuples instead of a time object.
! if (!PyArg_ParseTuple (args, "|i:GetTimeZoneInformation", &bTimesAsTuples))
return NULL;
TIME_ZONE_INFORMATION tzinfo;
***************
*** 2370,2377 ****
tzinfo.Bias,
PyWinObject_FromWCHAR(tzinfo.StandardName),
! PyWinObject_FromSYSTEMTIME(tzinfo.StandardDate),
tzinfo.StandardBias,
PyWinObject_FromWCHAR(tzinfo.DaylightName),
! PyWinObject_FromSYSTEMTIME(tzinfo.DaylightDate),
tzinfo.DaylightBias );
--- 2399,2410 ----
tzinfo.Bias,
PyWinObject_FromWCHAR(tzinfo.StandardName),
! bTimesAsTuples ?
! PyTuple_FromSYSTEMTIME(tzinfo.StandardDate) :
! PyWinObject_FromSYSTEMTIME(tzinfo.StandardDate),
tzinfo.StandardBias,
PyWinObject_FromWCHAR(tzinfo.DaylightName),
! bTimesAsTuples ?
! PyTuple_FromSYSTEMTIME(tzinfo.DaylightDate) :
! PyWinObject_FromSYSTEMTIME(tzinfo.DaylightDate),
tzinfo.DaylightBias );
***************
*** 2385,2393 ****
// @tupleitem 0|int|bias|Specifies the current bias, in minutes, for local time translation on this computer. The bias is the difference, in minutes, between Coordinated Universal Time (UTC) and local time. All translations between UTC and local time are based on the following formula:<nl><nl>UTC = local time + bias <nl><nl>
// @tupleitem 1|unicode|standardName|Specifies a string associated with standard time on this operating system. For example, this member could contain "EST" to indicate Eastern Standard Time. This string is not used by the operating system, so anything stored there using the SetTimeZoneInformation function is returned unchanged by the GetTimeZoneInformation function. This string can be empty.
! // @tupleitem 2|<o PyTime>|standardTime|Specifies a SYSTEMTIME object that contains a date and local time when the transition from daylight saving time to standard time occurs on this operating system. If this date is not specified, the wMonth member in the SYSTEMTIME structure must be zero. If this date is specified, the DaylightDate value in the TIME_ZONE_INFORMATION structure must also be specified.
// <nl>To select the correct day in the month, set the wYear member to zero, the wDayOfWeek member to an appropriate weekday, and the wDay member to a value in the range 1 through 5. Using this notation, the first Sunday in April can be specified, as can the last Thursday in October (5 is equal to "the last").
// @tupleitem 3|int|standardBias|Specifies a bias value to be used during local time translations that occur during standard time. This member is ignored if a value for the StandardDate member is not supplied. <nl>This value is added to the value of the Bias member to form the bias used during standard time. In most time zones, the value of this member is zero.
// @tupleitem 4|unicode|daylightName|
! // @tupleitem 5|<o PyTime>|daylightTime|
// @tupleitem 6|int|daylightBias|Specifies a bias value to be used during local time translations that occur during daylight saving time. This member is ignored if a value for the DaylightDate member is not supplied.
// <nl>This value is added to the value of the Bias member to form the bias used during daylight saving time. In most time zones, the value of this member is 60.
--- 2418,2426 ----
// @tupleitem 0|int|bias|Specifies the current bias, in minutes, for local time translation on this computer. The bias is the difference, in minutes, between Coordinated Universal Time (UTC) and local time. All translations between UTC and local time are based on the following formula:<nl><nl>UTC = local time + bias <nl><nl>
// @tupleitem 1|unicode|standardName|Specifies a string associated with standard time on this operating system. For example, this member could contain "EST" to indicate Eastern Standard Time. This string is not used by the operating system, so anything stored there using the SetTimeZoneInformation function is returned unchanged by the GetTimeZoneInformation function. This string can be empty.
! // @tupleitem 2|<o PyTime>/tuple|standardTime|Specifies a SYSTEMTIME object that contains a date and local time when the transition from daylight saving time to standard time occurs on this operating system. If this date is not specified, the wMonth member in the SYSTEMTIME structure must be zero. If this date is specified, the DaylightDate value in the TIME_ZONE_INFORMATION structure must also be specified.
// <nl>To select the correct day in the month, set the wYear member to zero, the wDayOfWeek member to an appropriate weekday, and the wDay member to a value in the range 1 through 5. Using this notation, the first Sunday in April can be specified, as can the last Thursday in October (5 is equal to "the last").
// @tupleitem 3|int|standardBias|Specifies a bias value to be used during local time translations that occur during standard time. This member is ignored if a value for the StandardDate member is not supplied. <nl>This value is added to the value of the Bias member to form the bias used during standard time. In most time zones, the value of this member is zero.
// @tupleitem 4|unicode|daylightName|
! // @tupleitem 5|<o PyTime>/tuple|daylightTime|
// @tupleitem 6|int|daylightBias|Specifies a bias value to be used during local time translations that occur during daylight saving time. This member is ignored if a value for the DaylightDate member is not supplied.
// <nl>This value is added to the value of the Bias member to form the bias used during daylight saving time. In most time zones, the value of this member is 60.
***************
*** 2395,2398 ****
--- 2428,2483 ----
}
+ // @pymethod tuple|win32api|SetTimeZoneInformation|Sets the system time-zone information.
+ static PyObject *
+ PySetTimeZoneInformation(PyObject * self, PyObject * args)
+ {
+ // @pyparm tuple|tzi||A tuple with the timezone info
+ // @desc The tuple is of form.
+ TIME_ZONE_INFORMATION tzi;
+ PyObject *obStdName, *obStdDate;
+ PyObject *obDaylightName, *obDaylightDate;
+ if (!PyArg_ParseTuple (args, "(iOOiOOi):SetTimeZoneInformation",
+ &tzi.Bias, // @tupleitem 0|int|Bias|
+ &obStdName, // @tupleitem 1|string|StandardName
+ &obStdDate, // @tupleitem 2|SYSTEMTIME tuple|StandardDate
+ &tzi.StandardBias, // @tupleitem 3|int|StandardBias
+ &obDaylightName, // @tupleitem 4|string|DaylightName
+ &obDaylightDate, // @tupleitem 5|SYSTEMTIME tuple|DaylightDate
+ &tzi.DaylightBias))// @tupleitem 6|int|DaylightBias
+ return NULL;
+ WCHAR *temp;
+ if (!PyWinObject_AsWCHAR(obStdName, &temp))
+ return NULL;
+ if (wcslen(temp)>31) {
+ PyWinObject_FreeWCHAR(temp);
+ return PyErr_Format(PyExc_ValueError, "Time zone names must be < 32 chars long");
+ }
+ wcscpy(tzi.StandardName, temp);
+ PyWinObject_FreeWCHAR(temp);
+ // second string...
+ if (!PyWinObject_AsWCHAR(obDaylightName, &temp))
+ return NULL;
+ if (wcslen(temp)>31) {
+ PyWinObject_FreeWCHAR(temp);
+ return PyErr_Format(PyExc_ValueError, "Time zone names must be < 32 chars long");
+ }
+ wcscpy(tzi.DaylightName, temp);
+ PyWinObject_FreeWCHAR(temp);
+
+ // tuples with a SYSTEMTIME
+ if (!PyTuple_AsSYSTEMTIME(obStdDate, tzi.StandardDate))
+ return NULL;
+ if (!PyTuple_AsSYSTEMTIME(obDaylightDate, tzi.DaylightDate))
+ return NULL;
+
+ BOOL rc;
+ PyW32_BEGIN_ALLOW_THREADS
+ rc = ::SetTimeZoneInformation(&tzi);
+ PyW32_END_ALLOW_THREADS
+ if(!rc)
+ return ReturnAPIError("SetTimeZoneInformation");
+ Py_RETURN_NONE;
+ }
+
// @pymethod string|win32api|GetDateFormat|Formats a date as a date string for a specified locale. The function formats either a specified date or the local system date.
static PyObject *PyGetDateFormat(PyObject *self, PyObject *args)
***************
*** 6240,6243 ****
--- 6325,6329 ----
{"SetSystemPowerState", PySetSystemPowerState, 1}, // @pymeth SetSystemPowerState|Powers machine down to a suspended state
{"SetThreadLocale", PySetThreadLocale, 1}, // @pymeth SetThreadLocale|Sets the current thread's locale.
+ {"SetTimeZoneInformation",PySetTimeZoneInformation,1}, // @pymeth SetTimeZoneInformation|Sets the system time-zone information.
{"SetWindowLong", PySetWindowLong,1}, // @pymeth SetWindowLong|Places a long value at the specified offset into the extra window memory of the given window.
{"ShellExecute", PyShellExecute, 1}, // @pymeth ShellExecute|Executes an application.
Index: win32trace.cpp
===================================================================
RCS file: /cvsroot/pywin32/pywin32/win32/src/win32trace.cpp,v
retrieving revision 1.14.2.5
retrieving revision 1.14.2.6
diff -C2 -d -r1.14.2.5 -r1.14.2.6
*** win32trace.cpp 14 Jan 2009 12:42:03 -0000 1.14.2.5
--- win32trace.cpp 25 Jan 2009 04:52:20 -0000 1.14.2.6
***************
*** 115,129 ****
}
static PyObject *PyTraceObject_write(PyObject *self, PyObject *args)
{
int len;
! char *data;
! if (!PyArg_ParseTuple(args, "s#:write", &data, &len))
return NULL;
BOOL ok = static_cast<PyTraceObject*>(self)->WriteData(data, len);
if (!ok)
return NULL;
! Py_INCREF(Py_None);
! return Py_None;
}
--- 115,133 ----
}
+ // In an attempt to allow py2k and py3k readers and writers to work together,
+ // we assume a 'latin1' encoding for the bytes on the wire. When pulling the
+ // bytes off the wire, in py2k we return a string while in py3k we return
+ // a latin-1 decoded unicode object.
static PyObject *PyTraceObject_write(PyObject *self, PyObject *args)
{
int len;
! char *data = NULL;
! if (!PyArg_ParseTuple(args, "et#:write", "latin-1", &data, &len))
return NULL;
BOOL ok = static_cast<PyTraceObject*>(self)->WriteData(data, len);
+ PyMem_Free(data);
if (!ok)
return NULL;
! Py_RETURN_NONE;
}
***************
*** 137,141 ****
--- 141,149 ----
if (!ok)
return NULL;
+ #if (PY_VERSION_HEX < 0x03000000)
PyObject *result = PyString_FromStringAndSize(data, len);
+ #else
+ PyObject *result = PyUnicode_DecodeLatin1(data, len, "replace");
+ #endif
free(data);
return result;
***************
*** 152,156 ****
--- 160,168 ----
if (!ok)
return NULL;
+ #if (PY_VERSION_HEX < 0x03000000)
PyObject *result = PyString_FromStringAndSize(data, len);
+ #else
+ PyObject *result = PyUnicode_DecodeLatin1(data, len, "replace");
+ #endif
free(data);
return result;
***************
*** 648,651 ****
--- 660,664 ----
// no local one exists - see if we can create it globally - if
// we can, we go global, else we stick with local.
+ use_global_namespace = TRUE;
HANDLE h2 = CreateFileMapping((HANDLE)-1, &sa, PAGE_READWRITE,
0, BUFFER_SIZE,
Index: PySecurityObjects.h
===================================================================
RCS file: /cvsroot/pywin32/pywin32/win32/src/PySecurityObjects.h,v
retrieving revision 1.13.2.1
retrieving revision 1.13.2.2
diff -C2 -d -r1.13.2.1 -r1.13.2.2
*** PySecurityObjects.h 29 Aug 2008 04:59:25 -0000 1.13.2.1
--- PySecurityObjects.h 25 Jan 2009 04:52:20 -0000 1.13.2.2
***************
*** 102,108 ****
--- 102,110 ----
/* Python support */
int compare(PyObject *ob);
+ PyObject *richcompare(PyObject *other, int op);
static void deallocFunc(PyObject *ob);
static int compareFunc(PyObject *ob1, PyObject *ob2);
+ static PyObject *richcompareFunc(PyObject *ob1, PyObject *ob2, int op);
static PyObject *strFunc(PyObject *ob);
Index: PySID.cpp
===================================================================
RCS file: /cvsroot/pywin32/pywin32/win32/src/PySID.cpp,v
retrieving revision 1.12.2.1
retrieving revision 1.12.2.2
diff -C2 -d -r1.12.2.1 -r1.12.2.2
*** PySID.cpp 29 Aug 2008 04:59:25 -0000 1.12.2.1
--- PySID.cpp 25 Jan 2009 04:52:20 -0000 1.12.2.2
***************
*** 261,265 ****
0, /* tp_traverse */
0, /* tp_clear */
! 0, /* tp_richcompare */
0, /* tp_weaklistoffset */
0, /* tp_iter */
--- 261,265 ----
0, /* tp_traverse */
0, /* tp_clear */
! PySID::richcompareFunc, /* tp_richcompare */
0, /* tp_weaklistoffset */
0, /* tp_iter */
***************
*** 314,317 ****
--- 314,336 ----
}
+ PyObject *PySID::richcompare(PyObject *other, int op)
+ {
+ BOOL e;
+ if (PySID_Check(other))
+ e=compare((PyHANDLE *)other)==0;
+ else
+ e=FALSE;
+ PyObject *ret;
+ if (op==Py_EQ)
+ ret = e ? Py_True : Py_False;
+ else if (op==Py_NE)
+ ret = !e ? Py_True : Py_False;
+ else {
+ PyErr_SetString(PyExc_TypeError, "SIDs only compare equal or not equal");
+ ret = NULL;
+ }
+ Py_XINCREF(ret);
+ return ret;
+ }
// @pymethod int|PySID|__cmp__|Used when objects are compared.
***************
*** 322,325 ****
--- 341,349 ----
}
+ PyObject *PySID::richcompareFunc(PyObject *ob1, PyObject *ob2, int op)
+ {
+ return ((PySID *)ob1)->richcompare(ob2, op);
+ }
+
/*static*/ void PySID::deallocFunc(PyObject *ob)
{
|