pywin32-checkins Mailing List for Python for Windows Extensions (Page 90)
OLD project page for the Python extensions for Windows
Brought to you by:
mhammond
You can subscribe to this list here.
2003 |
Jan
|
Feb
|
Mar
|
Apr
(2) |
May
(1) |
Jun
(6) |
Jul
(50) |
Aug
(11) |
Sep
(24) |
Oct
(184) |
Nov
(118) |
Dec
(22) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2004 |
Jan
(31) |
Feb
(25) |
Mar
(34) |
Apr
(105) |
May
(49) |
Jun
(38) |
Jul
(39) |
Aug
(7) |
Sep
(98) |
Oct
(79) |
Nov
(20) |
Dec
(17) |
2005 |
Jan
(66) |
Feb
(32) |
Mar
(43) |
Apr
(30) |
May
(58) |
Jun
(30) |
Jul
(16) |
Aug
(4) |
Sep
(21) |
Oct
(42) |
Nov
(11) |
Dec
(14) |
2006 |
Jan
(42) |
Feb
(30) |
Mar
(22) |
Apr
(1) |
May
(9) |
Jun
(15) |
Jul
(20) |
Aug
(9) |
Sep
(8) |
Oct
(1) |
Nov
(9) |
Dec
(43) |
2007 |
Jan
(52) |
Feb
(45) |
Mar
(20) |
Apr
(12) |
May
(59) |
Jun
(39) |
Jul
(35) |
Aug
(31) |
Sep
(17) |
Oct
(20) |
Nov
(4) |
Dec
(4) |
2008 |
Jan
(28) |
Feb
(111) |
Mar
(4) |
Apr
(27) |
May
(40) |
Jun
(27) |
Jul
(32) |
Aug
(94) |
Sep
(87) |
Oct
(153) |
Nov
(336) |
Dec
(331) |
2009 |
Jan
(298) |
Feb
(127) |
Mar
(20) |
Apr
(8) |
May
|
Jun
(10) |
Jul
(6) |
Aug
|
Sep
(2) |
Oct
(2) |
Nov
|
Dec
(1) |
2010 |
Jan
(7) |
Feb
(1) |
Mar
|
Apr
|
May
(15) |
Jun
(4) |
Jul
(3) |
Aug
(28) |
Sep
(1) |
Oct
(19) |
Nov
(16) |
Dec
(6) |
2011 |
Jan
(2) |
Feb
(18) |
Mar
(17) |
Apr
(12) |
May
(5) |
Jun
(11) |
Jul
(7) |
Aug
(2) |
Sep
(2) |
Oct
(4) |
Nov
(4) |
Dec
|
2012 |
Jan
(6) |
Feb
(2) |
Mar
|
Apr
(8) |
May
(4) |
Jun
(3) |
Jul
(13) |
Aug
(27) |
Sep
(8) |
Oct
(9) |
Nov
(3) |
Dec
(2) |
2013 |
Jan
|
Feb
(1) |
Mar
(5) |
Apr
(10) |
May
|
Jun
(2) |
Jul
|
Aug
|
Sep
|
Oct
|
Nov
(1) |
Dec
(9) |
2014 |
Jan
(2) |
Feb
(4) |
Mar
(4) |
Apr
(1) |
May
(4) |
Jun
(2) |
Jul
|
Aug
|
Sep
|
Oct
(2) |
Nov
|
Dec
(1) |
2015 |
Jan
(1) |
Feb
|
Mar
|
Apr
(6) |
May
(2) |
Jun
|
Jul
|
Aug
(1) |
Sep
|
Oct
|
Nov
|
Dec
|
2016 |
Jan
(3) |
Feb
(2) |
Mar
|
Apr
(3) |
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2017 |
Jan
|
Feb
|
Mar
(1) |
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
(1) |
Oct
|
Nov
|
Dec
|
From: Roger U. <ru...@us...> - 2007-06-02 08:18:26
|
Update of /cvsroot/pywin32/pywin32/com/win32comext/shell/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20650/com/win32comext/shell/src Modified Files: shell.cpp Log Message: Define PY_SSIZE_T_CLEAN Index: shell.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/win32comext/shell/src/shell.cpp,v retrieving revision 1.54 retrieving revision 1.55 diff -C2 -d -r1.54 -r1.55 *** shell.cpp 30 May 2007 00:54:44 -0000 1.54 --- shell.cpp 2 Jun 2007 08:18:27 -0000 1.55 *************** *** 47,50 **** --- 47,53 ---- #include "PythonCOMRegister.h" // For simpler registration of IIDs etc. + // Any python API functions that use 's#' format must use Py_ssize_t for length + #define PY_SSIZE_T_CLEAN + // We should not be using this! #define OleSetOleError PyCom_BuildPyException |
From: Mark H. <mha...@us...> - 2007-06-01 14:57:22
|
Update of /cvsroot/pywin32/pywin32/win32/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7399/test Modified Files: test_win32api.py Log Message: Correct VkKeyScan arg handling and add tests Index: test_win32api.py =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/test/test_win32api.py,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** test_win32api.py 16 Jul 2006 11:04:20 -0000 1.11 --- test_win32api.py 1 Jun 2007 14:57:19 -0000 1.12 *************** *** 158,161 **** --- 158,169 ---- self.failUnlessEqual(x, win32api.GetLastError()) + def testVkKeyScan(self): + # hopefully ' ' doesn't depend on the locale! + self.failUnlessEqual(win32api.VkKeyScan(' '), 32) + + def testVkKeyScanEx(self): + # hopefully ' ' doesn't depend on the locale! + self.failUnlessEqual(win32api.VkKeyScanEx(' ', 0), 32) + if __name__ == '__main__': unittest.main() |
From: Mark H. <mha...@us...> - 2007-06-01 14:57:22
|
Update of /cvsroot/pywin32/pywin32/win32/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7399/src Modified Files: win32apimodule.cpp Log Message: Correct VkKeyScan arg handling and add tests Index: win32apimodule.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/src/win32apimodule.cpp,v retrieving revision 1.75 retrieving revision 1.76 diff -C2 -d -r1.75 -r1.76 *** win32apimodule.cpp 27 May 2007 17:32:14 -0000 1.75 --- win32apimodule.cpp 1 Jun 2007 14:57:19 -0000 1.76 *************** *** 1329,1333 **** PyVkKeyScan(PyObject * self, PyObject * args) { ! char *key; // @pyparm chr|char||Specifies a character if (!PyArg_ParseTuple(args, "c:VkKeyScan", &key)) --- 1329,1333 ---- PyVkKeyScan(PyObject * self, PyObject * args) { ! char key; // @pyparm chr|char||Specifies a character if (!PyArg_ParseTuple(args, "c:VkKeyScan", &key)) *************** *** 1336,1340 **** PyW32_BEGIN_ALLOW_THREADS // @pyseeapi VkKeyScan ! ret = VkKeyScan(key[0]); PyW32_END_ALLOW_THREADS return PyInt_FromLong(ret); --- 1336,1340 ---- PyW32_BEGIN_ALLOW_THREADS // @pyseeapi VkKeyScan ! ret = VkKeyScan(key); PyW32_END_ALLOW_THREADS return PyInt_FromLong(ret); |
From: Mark H. <mha...@us...> - 2007-06-01 13:36:54
|
Update of /cvsroot/pywin32/pywin32/win32/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8297/src Modified Files: win32clipboardmodule.cpp Log Message: Add test for SetClipboardText and mark this module as being "Py_ssize_t safe" Index: win32clipboardmodule.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/src/win32clipboardmodule.cpp,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -d -r1.18 -r1.19 *** win32clipboardmodule.cpp 30 May 2007 04:17:45 -0000 1.18 --- win32clipboardmodule.cpp 1 Jun 2007 13:36:53 -0000 1.19 *************** *** 16,19 **** --- 16,20 ---- ******************************************************************************/ + #define PY_SSIZE_T_CLEAN // this should be Py_ssize_t clean! #include "windows.h" |
From: Mark H. <mha...@us...> - 2007-06-01 13:36:54
|
Update of /cvsroot/pywin32/pywin32/win32/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8297/test Modified Files: test_clipboard.py Log Message: Add test for SetClipboardText and mark this module as being "Py_ssize_t safe" Index: test_clipboard.py =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/test/test_clipboard.py,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** test_clipboard.py 24 May 2007 06:01:06 -0000 1.5 --- test_clipboard.py 1 Jun 2007 13:36:53 -0000 1.6 *************** *** 63,66 **** --- 63,70 ---- SetClipboardData(win32con.CF_UNICODETEXT, val) self.failUnlessEqual(GetClipboardData(win32con.CF_UNICODETEXT), val) + def test_unicode_text(self): + val = "test-val" + SetClipboardText(val) + self.failUnlessEqual(GetClipboardData(win32con.CF_TEXT), val) def test_string(self): val = "test" |
From: Mark H. <mha...@us...> - 2007-06-01 12:57:00
|
Update of /cvsroot/pywin32/pywin32/win32/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25327 Modified Files: win32service.i Log Message: Move decl of variable from loop to fix compile error Index: win32service.i =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/src/win32service.i,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** win32service.i 14 Mar 2007 22:28:53 -0000 1.12 --- win32service.i 1 Jun 2007 12:57:00 -0000 1.13 *************** *** 722,727 **** int numStrings = PySequence_Length(obDeps); // Need to loop twice - once to get the buffer length ! int len = 0; ! for (int i=0;i<numStrings;i++) { PyObject *obString = PySequence_GetItem(obDeps, i); if (obString==NULL) --- 722,727 ---- int numStrings = PySequence_Length(obDeps); // Need to loop twice - once to get the buffer length ! int i, len = 0; ! for (i=0;i<numStrings;i++) { PyObject *obString = PySequence_GetItem(obDeps, i); if (obString==NULL) |
From: Roger U. <ru...@us...> - 2007-05-30 07:59:49
|
Update of /cvsroot/pywin32/pywin32/com/win32com/src/extensions In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16670/com/win32com/src/extensions Modified Files: PyIStream.cpp Log Message: Fix 's#' 64-bit issue Index: PyIStream.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/win32com/src/extensions/PyIStream.cpp,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** PyIStream.cpp 19 Nov 1999 04:03:23 -0000 1.2 --- PyIStream.cpp 30 May 2007 07:59:49 -0000 1.3 *************** *** 56,65 **** PyObject *PyIStream::Write(PyObject *self, PyObject *args) { ! char *strValue; ! int strSize; // @pyparm string|data||The binary data to write. ! if (!PyArg_ParseTuple(args, "s#:Read", &strValue, &strSize)) return NULL; - IStream *pMy = GetI(self); if (pMy==NULL) return NULL; --- 56,67 ---- PyObject *PyIStream::Write(PyObject *self, PyObject *args) { ! void *strValue; ! PyObject *obstrValue; ! DWORD strSize; // @pyparm string|data||The binary data to write. ! if (!PyArg_ParseTuple(args, "O:Write", &obstrValue)) ! return NULL; ! if (!PyWinObject_AsReadBuffer(obstrValue, &strValue, &strSize, FALSE)) return NULL; IStream *pMy = GetI(self); if (pMy==NULL) return NULL; |
From: Mark H. <mha...@us...> - 2007-05-30 07:06:11
|
Update of /cvsroot/pywin32/pywin32/win32/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29102 Modified Files: win32gui.i Log Message: Fix x64 handling of LPARAM in DialogBoxIndirect Fix a couple of other x64 warnings Index: win32gui.i =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/src/win32gui.i,v retrieving revision 1.108 retrieving revision 1.109 diff -C2 -d -r1.108 -r1.109 *** win32gui.i 27 May 2007 13:25:42 -0000 1.108 --- win32gui.i 30 May 2007 07:06:11 -0000 1.109 *************** *** 765,769 **** PyObject *obWndProc = PyTuple_GET_ITEM(obTuple, 0); // Replace the lParam with the one the user specified. ! lParam = PyInt_AsLong( PyTuple_GET_ITEM(obTuple, 1) ); PyObject *key = PyWinLong_FromHANDLE(hWnd); --- 765,771 ---- PyObject *obWndProc = PyTuple_GET_ITEM(obTuple, 0); // Replace the lParam with the one the user specified. ! lParam = 0; ! if (PyTuple_GET_ITEM(obTuple, 1) != Py_None) ! PyWinObject_AsPARAM( PyTuple_GET_ITEM(obTuple, 1), &lParam ); PyObject *key = PyWinLong_FromHANDLE(hWnd); *************** *** 1613,1617 **** PyObject *O = NULL; void *addr = NULL; ! int len = 0; // @pyparm int|obj||the buffer object --- 1615,1619 ---- PyObject *O = NULL; void *addr = NULL; ! Py_ssize_t len = 0; // @pyparm int|obj||the buffer object *************** *** 2083,2099 **** static PyObject *PyDialogBoxIndirect(PyObject *self, PyObject *args) { - /// XXX - todo - add support for a dialogproc! HINSTANCE hinst; HWND hwnd; ! LPARAM param=0; PyObject *obhinst, *obhwnd, *obList, *obDlgProc; BOOL bFreeString = FALSE; ! ! if (!PyArg_ParseTuple(args, "OOOO|l", &obhinst, // @pyparm <o PyHANDLE>|hInstance||Handle to module creating the dialog box &obList, // @pyparm list|controlList||List containing a <o Dialog Header Tuple>, followed by variable number of <o Dialog Item Tuple>s &obhwnd, // @pyparm <o PyHANDLE>|hWndParent||Handle to dialog's parent window &obDlgProc, // @pyparm function|DialogFunc||Dialog box procedure to process messages ! ¶m)) // @pyparm int|InitParam|0|Initialization data to be passed to above procedure during WM_INITDIALOG processing return NULL; if (!PyWinObject_AsHANDLE(obhinst, (HANDLE *)&hinst, FALSE)) --- 2085,2100 ---- static PyObject *PyDialogBoxIndirect(PyObject *self, PyObject *args) { HINSTANCE hinst; HWND hwnd; ! PyObject *obParam = Py_None; PyObject *obhinst, *obhwnd, *obList, *obDlgProc; BOOL bFreeString = FALSE; ! ! if (!PyArg_ParseTuple(args, "OOOO|O", &obhinst, // @pyparm <o PyHANDLE>|hInstance||Handle to module creating the dialog box &obList, // @pyparm list|controlList||List containing a <o Dialog Header Tuple>, followed by variable number of <o Dialog Item Tuple>s &obhwnd, // @pyparm <o PyHANDLE>|hWndParent||Handle to dialog's parent window &obDlgProc, // @pyparm function|DialogFunc||Dialog box procedure to process messages ! &obParam)) // @pyparm long|InitParam|0|Initialization data to be passed to above procedure during WM_INITDIALOG processing return NULL; if (!PyWinObject_AsHANDLE(obhinst, (HANDLE *)&hinst, FALSE)) *************** *** 2101,2104 **** --- 2102,2110 ---- if (!PyWinObject_AsHANDLE(obhwnd, (HANDLE *)&hwnd, TRUE)) return NULL; + // We unpack the object in the dlgproc - but check validity now + if (obParam != Py_None && !PyInt_Check(obParam) && !PyLong_Check(obParam)) { + return PyErr_Format(PyExc_TypeError, "optional param must be None, or an integer (got %s)", + obParam->ob_type->tp_name); + } HGLOBAL h = MakeResourceFromDlgList(obList); *************** *** 2106,2114 **** return NULL; ! PyObject *obExtra = Py_BuildValue("Ol", obDlgProc, param); INT_PTR rc; Py_BEGIN_ALLOW_THREADS - HGLOBAL templ = (HGLOBAL) GlobalLock(h); rc = DialogBoxIndirectParam(hinst, (const DLGTEMPLATE *) templ, hwnd, PyDlgProcHDLG, (LPARAM)obExtra); GlobalUnlock(h); --- 2112,2125 ---- return NULL; ! HGLOBAL templ = (HGLOBAL) GlobalLock(h); ! if (!templ) { ! GlobalFree(h); ! return PyWin_SetAPIError("GlobalLock (for template)"); ! } ! ! PyObject *obExtra = Py_BuildValue("OO", obDlgProc, obParam); INT_PTR rc; Py_BEGIN_ALLOW_THREADS rc = DialogBoxIndirectParam(hinst, (const DLGTEMPLATE *) templ, hwnd, PyDlgProcHDLG, (LPARAM)obExtra); GlobalUnlock(h); *************** *** 2378,2382 **** PyObject *PyCreateAcceleratorTable(PyObject *self, PyObject *args) { ! int num, i; ACCEL *accels = NULL; PyObject *ret = NULL; --- 2389,2393 ---- PyObject *PyCreateAcceleratorTable(PyObject *self, PyObject *args) { ! Py_ssize_t num, i; ACCEL *accels = NULL; PyObject *ret = NULL; |
From: Roger U. <ru...@us...> - 2007-05-30 06:51:48
|
Update of /cvsroot/pywin32/pywin32/win32/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24211/win32/src Modified Files: win32security_sspi.cpp Log Message: Fix 's#' 64-bit issue Index: win32security_sspi.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/src/win32security_sspi.cpp,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** win32security_sspi.cpp 24 May 2007 06:01:06 -0000 1.7 --- win32security_sspi.cpp 30 May 2007 06:51:48 -0000 1.8 *************** *** 863,867 **** PSecPkgContext_IssuerListInfoEx li; li=(PSecPkgContext_IssuerListInfoEx)&buf; ! ret=Py_BuildValue("lu#", li->cIssuers, li->aIssuers->pbData, li->aIssuers->cbData); (*psecurityfunctiontable->FreeContextBuffer)(li->aIssuers); break; --- 863,869 ---- PSecPkgContext_IssuerListInfoEx li; li=(PSecPkgContext_IssuerListInfoEx)&buf; ! ret=Py_BuildValue("lN", ! li->cIssuers, ! PyString_FromStringAndSize((char *)li->aIssuers->pbData, li->aIssuers->cbData)); (*psecurityfunctiontable->FreeContextBuffer)(li->aIssuers); break; |
From: Roger U. <ru...@us...> - 2007-05-30 06:48:02
|
Update of /cvsroot/pywin32/pywin32/win32/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22718/win32/src Modified Files: win32credmodule.cpp Log Message: Fix 's#' 64-bit issue Index: win32credmodule.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/src/win32credmodule.cpp,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** win32credmodule.cpp 24 May 2007 06:01:06 -0000 1.5 --- win32credmodule.cpp 30 May 2007 06:48:02 -0000 1.6 *************** *** 19,26 **** return NULL; for (DWORD attr_ind=0;attr_ind<attr_cnt;attr_ind++){ ! ret_item=Py_BuildValue("{s:u,s:k,s:s#}", "Keyword", attrs[attr_ind].Keyword, "Flags", attrs[attr_ind].Flags, ! "Value", attrs[attr_ind].Value, attrs[attr_ind].ValueSize); if (ret_item==NULL){ Py_DECREF(ret); --- 19,26 ---- return NULL; for (DWORD attr_ind=0;attr_ind<attr_cnt;attr_ind++){ ! ret_item=Py_BuildValue("{s:u,s:k,s:N}", "Keyword", attrs[attr_ind].Keyword, "Flags", attrs[attr_ind].Flags, ! "Value", PyString_FromStringAndSize((char *)attrs[attr_ind].Value, attrs[attr_ind].ValueSize)); if (ret_item==NULL){ Py_DECREF(ret); |
From: Roger U. <ru...@us...> - 2007-05-30 06:08:04
|
Update of /cvsroot/pywin32/pywin32/win32/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7664/win32/src Modified Files: odbc.cpp Log Message: Fix 's#' 64-bit issue Index: odbc.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/src/odbc.cpp,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -d -r1.18 -r1.19 *** odbc.cpp 24 May 2007 06:01:05 -0000 1.18 --- odbc.cpp 30 May 2007 06:08:04 -0000 1.19 *************** *** 15,19 **** #include <string.h> ! #include <pywintypes.h> #include <sql.h> #include <sqlext.h> --- 15,19 ---- #include <string.h> ! #include "PyWinTypes.h" #include <sql.h> #include <sqlext.h> *************** *** 1814,1818 **** ret = NULL; } else ! ret = Py_BuildValue("s#s#", svr, svr_size, desc, desc_size); return ret; } --- 1814,1820 ---- ret = NULL; } else ! ret = Py_BuildValue("NN", ! PyString_FromStringAndSize((char *)svr, svr_size), ! PyString_FromStringAndSize((char *)desc, desc_size)); return ret; } |
From: Roger U. <ru...@us...> - 2007-05-30 04:17:46
|
Update of /cvsroot/pywin32/pywin32/win32/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv32218/win32/src Modified Files: win32clipboardmodule.cpp Log Message: Fix 's#' 64-bit issue Index: win32clipboardmodule.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/src/win32clipboardmodule.cpp,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -d -r1.17 -r1.18 *** win32clipboardmodule.cpp 24 May 2007 06:01:05 -0000 1.17 --- win32clipboardmodule.cpp 30 May 2007 04:17:45 -0000 1.18 *************** *** 962,966 **** int format = CF_TEXT; char *text; ! int size; if (!PyArg_ParseTuple(args, "s#:SetClipboardText", &text, &size)) { --- 962,966 ---- int format = CF_TEXT; char *text; ! Py_ssize_t size; if (!PyArg_ParseTuple(args, "s#:SetClipboardText", &text, &size)) { *************** *** 971,975 **** LPTSTR pszDst; ! hMem = GlobalAlloc(GHND, (DWORD)(size+1)); if (hMem == NULL) { return ReturnAPIError("GlobalAlloc"); --- 971,975 ---- LPTSTR pszDst; ! hMem = GlobalAlloc(GHND, size+1); if (hMem == NULL) { return ReturnAPIError("GlobalAlloc"); |
From: Roger U. <ru...@us...> - 2007-05-30 02:37:01
|
Update of /cvsroot/pywin32/pywin32/win32/src/win32print In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28441/win32/src/win32print Modified Files: win32print.cpp Log Message: Fix 's#' 64-bit issue Index: win32print.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/src/win32print/win32print.cpp,v retrieving revision 1.25 retrieving revision 1.26 diff -C2 -d -r1.25 -r1.26 *** win32print.cpp 24 May 2007 06:01:06 -0000 1.25 --- win32print.cpp 30 May 2007 02:37:01 -0000 1.26 *************** *** 864,868 **** } ! // @pymethod int|win32print|WritePrinter|Copies the specified bytes to the specified printer. Suitable for copying raw Postscript or HPGL files to a printer. StartDocPrinter and EndDocPrinter should be called before and after. Returns number of bytes written to printer. static PyObject *PyWritePrinter(PyObject *self, PyObject *args) { --- 864,871 ---- } ! // @pymethod int|win32print|WritePrinter|Copies the specified bytes to the specified printer. ! // Suitable for copying raw Postscript or HPGL files to a printer. ! // StartDocPrinter and EndDocPrinter should be called before and after. ! // @rdesc Returns number of bytes written to printer. static PyObject *PyWritePrinter(PyObject *self, PyObject *args) { *************** *** 871,882 **** DWORD buf_size; DWORD bufwritten_size; ! ! if (!PyArg_ParseTuple(args, "O&s#:WritePrinter", ! PyWinObject_AsPrinterHANDLE, &hprinter, // @pyparm <o PyPrinterHANDLE>|hprinter||Handle to printer (from OpenPrinter) ! &buf, // @pyparm string|buf||String to send to printer. Embedded NULL bytes are allowed. ! &buf_size ! )) return NULL; - if (!WritePrinter(hprinter, buf, buf_size, &bufwritten_size)) return PyWin_SetAPIError("WritePrinter"); --- 874,884 ---- DWORD buf_size; DWORD bufwritten_size; ! PyObject *obbuf; ! if (!PyArg_ParseTuple(args, "O&O:WritePrinter", ! PyWinObject_AsPrinterHANDLE, &hprinter, // @pyparm <o PyPrinterHANDLE>|hprinter||Handle to printer as returned by <om win32print.OpenPrinter>. ! &obbuf)) // @pyparm string|buf||String or buffer containing data to send to printer. Embedded NULL bytes are allowed. ! return NULL; ! if (!PyWinObject_AsReadBuffer(obbuf, &buf, &buf_size, FALSE)) return NULL; if (!WritePrinter(hprinter, buf, buf_size, &bufwritten_size)) return PyWin_SetAPIError("WritePrinter"); |
From: Roger U. <ru...@us...> - 2007-05-30 00:54:46
|
Update of /cvsroot/pywin32/pywin32/com/win32comext/shell/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24183/com/win32comext/shell/src Modified Files: shell.cpp Log Message: Changle 's#' formats to Py_ssize_t Index: shell.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/win32comext/shell/src/shell.cpp,v retrieving revision 1.53 retrieving revision 1.54 diff -C2 -d -r1.53 -r1.54 *** shell.cpp 24 May 2007 06:01:05 -0000 1.53 --- shell.cpp 30 May 2007 00:54:44 -0000 1.54 *************** *** 1661,1665 **** { char *szPIDL; ! int pidllen; // @pyparm string|pidl||The PIDL as a raw string. if (!PyArg_ParseTuple(args, "s#:StringAsPIDL", &szPIDL, &pidllen)) --- 1661,1665 ---- { char *szPIDL; ! Py_ssize_t pidllen; // @pyparm string|pidl||The PIDL as a raw string. if (!PyArg_ParseTuple(args, "s#:StringAsPIDL", &szPIDL, &pidllen)) *************** *** 1676,1684 **** if (!PyArg_ParseTuple(args, "O:AddressAsPIDL", &obpidl)) return NULL; ! lpidl=(LPCITEMIDLIST)PyLong_AsVoidPtr(obpidl); ! if (lpidl==NULL && PyErr_Occurred()) return NULL; return PyObject_FromPIDL(lpidl, FALSE); ! } // @pymethod <o PyIDL>, list|shell|StringAsCIDA|Given a CIDA as a raw string, return the folder PIDL and list of children --- 1676,1683 ---- if (!PyArg_ParseTuple(args, "O:AddressAsPIDL", &obpidl)) return NULL; ! if (!PyWinLong_AsVoidPtr(obpidl, (void **)&lpidl)) return NULL; return PyObject_FromPIDL(lpidl, FALSE); ! } // @pymethod <o PyIDL>, list|shell|StringAsCIDA|Given a CIDA as a raw string, return the folder PIDL and list of children *************** *** 1686,1690 **** { char *szCIDA; ! int pidllen; // @pyparm string|pidl||The PIDL as a raw string. if (!PyArg_ParseTuple(args, "s#:StringAsCIDA", &szCIDA, &pidllen)) --- 1685,1689 ---- { char *szCIDA; ! Py_ssize_t pidllen; // @pyparm string|pidl||The PIDL as a raw string. if (!PyArg_ParseTuple(args, "s#:StringAsCIDA", &szCIDA, &pidllen)) *************** *** 1943,1947 **** FILEGROUPDESCRIPTORW *fgdw = NULL; void *buf; ! int i, cb, size_a, size_w, num; BOOL ok = FALSE; // @pyparm buffer|buf||A string packed as either FILEGROUPDESCRIPTORW or FILEGROUPDESCRIPTORW --- 1942,1947 ---- FILEGROUPDESCRIPTORW *fgdw = NULL; void *buf; ! int i, num; ! Py_ssize_t cb, size_a, size_w; BOOL ok = FALSE; // @pyparm buffer|buf||A string packed as either FILEGROUPDESCRIPTORW or FILEGROUPDESCRIPTORW *************** *** 1951,1955 **** // you will need to specify this parameter. int make_unicode = -1; ! if (!PyArg_ParseTuple(args, "z#|i", &buf, &cb, make_unicode)) return NULL; if (!buf) { --- 1951,1955 ---- // you will need to specify this parameter. int make_unicode = -1; ! if (!PyArg_ParseTuple(args, "z#|i", &buf, &cb, &make_unicode)) return NULL; if (!buf) { |
From: Mark H. <mha...@us...> - 2007-05-29 13:03:28
|
Update of /cvsroot/pywin32/pywin32/win32/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5904/win32/src Modified Files: win32dynamicdialog.cpp win32dynamicdialog.h Log Message: remove 64bit warnings for dynamic dialogs. Index: win32dynamicdialog.h =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/src/win32dynamicdialog.h,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** win32dynamicdialog.h 9 Oct 2000 22:43:44 -0000 1.1 --- win32dynamicdialog.h 29 May 2007 13:03:26 -0000 1.2 *************** *** 103,107 **** protected: HGLOBAL m_h; ! int m_alloc, m_len; #ifdef WIN32 DLGTEMPLATE *m_ptr; --- 103,107 ---- protected: HGLOBAL m_h; ! size_t m_alloc, m_len; #ifdef WIN32 DLGTEMPLATE *m_ptr; Index: win32dynamicdialog.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/src/win32dynamicdialog.cpp,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** win32dynamicdialog.cpp 10 Jan 2006 03:43:21 -0000 1.3 --- win32dynamicdialog.cpp 29 May 2007 13:03:26 -0000 1.4 *************** *** 219,223 **** DwordAlign((PCHAR*)&ptr); #endif ! int len = (BYTE*)ptr - (BYTE*)hdr; ASSERT(len <= m_alloc); m_len = len; --- 219,223 ---- DwordAlign((PCHAR*)&ptr); #endif ! ssize_t len = (BYTE*)ptr - (BYTE*)hdr; ASSERT(len <= m_alloc); m_len = len; *************** *** 245,249 **** RESCSTR wclass = MAKERESSTR(wc); RESCSTR txt = MAKERESSTR(text); ! int len = sizeof(DLGITEMTEMPLATE) + alloclenR(wclass) + datalen + 20; if (txt) { --- 245,249 ---- RESCSTR wclass = MAKERESSTR(wc); RESCSTR txt = MAKERESSTR(text); ! size_t len = sizeof(DLGITEMTEMPLATE) + alloclenR(wclass) + datalen + 20; if (txt) { *************** *** 307,311 **** #endif RESCSTR txt = MAKERESSTR(text); ! int len = sizeof(DLGITEMTEMPLATE) + 20; if (txt) { --- 307,311 ---- #endif RESCSTR txt = MAKERESSTR(text); ! ssize_t len = sizeof(DLGITEMTEMPLATE) + 20; if (txt) { *************** *** 419,423 **** static void FillList(PyObject *list, int n) { ! int size = PyList_Size(list); while (n > size) { --- 419,423 ---- static void FillList(PyObject *list, int n) { ! Py_ssize_t size = PyList_Size(list); while (n > size) { *************** *** 604,608 **** if (!PyList_Check(tmpl)) return NULL; ! int size = PyList_Size(tmpl); if (size < 3 || size > 7) return NULL; --- 604,608 ---- if (!PyList_Check(tmpl)) return NULL; ! Py_ssize_t size = PyList_Size(tmpl); if (size < 3 || size > 7) return NULL; *************** *** 715,719 **** if (!PyList_Check(tmpl)) return FALSE; ! int size = PyList_Size(tmpl); if (size < 5 || size > 7) return FALSE; --- 715,719 ---- if (!PyList_Check(tmpl)) return FALSE; ! Py_ssize_t size = PyList_Size(tmpl); if (size < 5 || size > 7) return FALSE; *************** *** 808,812 **** // @tupleitem 6|string|extraData|A string of bytes used as extra data for the control. The value depends on the control. BYTE *data = NULL; ! int datalen = 0; if (size > 6) { --- 808,812 ---- // @tupleitem 6|string|extraData|A string of bytes used as extra data for the control. The value depends on the control. BYTE *data = NULL; ! Py_ssize_t datalen = 0; if (size > 6) { *************** *** 824,829 **** dlg->Add(bclass, &tpl, text); else ! dlg->Add(wclass, &tpl, text, datalen, data); ! return TRUE; } --- 824,830 ---- dlg->Add(bclass, &tpl, text); else ! dlg->Add(wclass, &tpl, text, ! PyWin_SAFE_DOWNCAST(datalen, Py_ssize_t, int), ! data); return TRUE; } *************** *** 836,840 **** RETURN_ERR("Passed object must be a dialog template list"); } ! int size = PyList_Size(tmpl); if (size < 1) { --- 837,841 ---- RETURN_ERR("Passed object must be a dialog template list"); } ! Py_ssize_t size = PyList_Size(tmpl); if (size < 1) { |
From: Mark H. <mha...@us...> - 2007-05-29 12:28:46
|
Update of /cvsroot/pywin32/pywin32/win32/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24879/win32/src Modified Files: PyWinTypes.h Log Message: Add an inline PyWinObject_AsPARAM taking an LPARAM* Index: PyWinTypes.h =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/src/PyWinTypes.h,v retrieving revision 1.41 retrieving revision 1.42 diff -C2 -d -r1.41 -r1.42 *** PyWinTypes.h 27 May 2007 17:32:14 -0000 1.41 --- PyWinTypes.h 29 May 2007 12:28:45 -0000 1.42 *************** *** 409,412 **** --- 409,415 ---- return PyWinObject_FromULONG_PTR(param); } + inline BOOL PyWinObject_AsPARAM(PyObject *ob, LPARAM *pparam) { + return PyWinObject_AsPARAM(ob, (WPARAM *)pparam); + } inline PyObject *PyWinObject_FromPARAM(LPARAM param) { return PyWinObject_FromULONG_PTR(param); |
From: Mark H. <mha...@us...> - 2007-05-29 12:22:29
|
Update of /cvsroot/pywin32/pywin32/win32/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22633 Modified Files: testall.py Log Message: run the majority of the demos as part of the tests Index: testall.py =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/test/testall.py,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** testall.py 24 May 2007 05:39:13 -0000 1.5 --- testall.py 29 May 2007 12:22:28 -0000 1.6 *************** *** 2,8 **** import unittest def import_all(): # Some hacks for import order - dde depends on win32ui ! import win32ui import win32api --- 2,60 ---- import unittest + # A list of demos that depend on user-interface of *any* kind. Tests listed + # here are not suitable for unattended testing. + ui_demos = """GetSaveFileName print_desktop win32cred_demo win32gui_demo + win32gui_dialog win32gui_menu win32gui_taskbar + win32rcparser_demo winprocess win32console_demo""".split() + # Other demos known as 'bad' (or at least highly unlikely to work) + # cerapi: no CE module is built (CE via pywin32 appears dead) + # desktopmanager: hangs (well, hangs for 60secs or so...) + bad_demos = "cerapi desktopmanager win32comport_demo".split() + + argvs = { + "rastest": ("-l",), + } + + ok_exceptions = { + "RegCreateKeyTransacted": ("NotImplementedError"), + } + + class TestRunner: + def __init__(self, argv): + self.argv = argv + def __call__(self): + # subprocess failed in strange ways for me?? + fin, fout, ferr = os.popen3(" ".join(self.argv)) + fin.close() + output = fout.read() + ferr.read() + fout.close() + rc = ferr.close() + if rc: + base = os.path.basename(self.argv[1]) + raise AssertionError, "%s failed with exit code %s. Output is:\n%s" % (base, rc, output) + + def get_demo_tests(): + import win32api + ret = [] + demo_dir = os.path.abspath(os.path.join(os.path.dirname(win32api.__file__), "Demos")) + assert os.path.isdir(demo_dir), demo_dir + for name in os.listdir(demo_dir): + base, ext = os.path.splitext(name) + if ext != ".py" or base in ui_demos or base in bad_demos: + continue + if base in ok_exceptions: + print "Ack - can't handle test %s - can't catch specific exceptions" % (base,) + continue + argv = (sys.executable, os.path.join(demo_dir, base+".py")) + \ + argvs.get(base, ()) + ret.append(unittest.FunctionTestCase(TestRunner(argv), description="win32/demos/" + name)) + return ret + def import_all(): # Some hacks for import order - dde depends on win32ui ! try: ! import win32ui ! except ImportError: ! pass # 'what-ev-a....' import win32api *************** *** 47,50 **** --- 99,104 ---- test = unittest.defaultTestLoader.loadTestsFromModule(mod) suite.addTest(test) + for test in get_demo_tests(): + suite.addTest(test) return suite |
From: Roger U. <ru...@us...> - 2007-05-28 23:25:44
|
Update of /cvsroot/pywin32/pywin32/win32/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25854/win32/src Modified Files: win32security.i Log Message: Fix 's#' 64 bit issues Index: win32security.i =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/src/win32security.i,v retrieving revision 1.37 retrieving revision 1.38 diff -C2 -d -r1.37 -r1.38 *** win32security.i 24 May 2007 06:01:06 -0000 1.37 --- win32security.i 28 May 2007 23:25:43 -0000 1.38 *************** *** 152,159 **** PyObject *PyWinObject_FromSecHandle(PSecHandle h) { ! ULARGE_INTEGER ul; ! ul.LowPart=h->dwLower; ! ul.HighPart=h->dwUpper; ! return PyWinObject_FromULARGE_INTEGER(ul); } --- 152,161 ---- PyObject *PyWinObject_FromSecHandle(PSecHandle h) { ! // SecInvalidateHandle sets both parts of struct to -1. ! // PyWinObject_FromULARGE_INTEGER which was formerly used to translate to a long returned this as -1, ! // but _PyLong_FromByteArray returns it as a large positive integer ! if (!SecIsValidHandle(h)) ! return PyLong_FromLong(-1); ! return _PyLong_FromByteArray((unsigned char *)h, sizeof(*h), TRUE, FALSE); } *************** *** 426,444 **** } BOOL PyWinObject_AsLSA_UNICODE_STRING(PyObject *obstr, LSA_UNICODE_STRING *plsaus, BOOL bNoneOk) { ! TCHAR *ret_string = NULL; ! USHORT strlen = 0; ! if (!PyWinObject_AsTCHAR(obstr, &ret_string, bNoneOk)) { ! plsaus->Buffer = ret_string; return FALSE; ! } ! if (ret_string == NULL) ! strlen=0; ! else ! strlen = wcslen(ret_string); ! plsaus->Buffer = ret_string; ! plsaus->Length = strlen * sizeof(WCHAR); ! plsaus->MaximumLength= (strlen+1) * sizeof(WCHAR); return TRUE; } --- 428,463 ---- } + BOOL PyWinObject_AsLSA_STRING(PyObject *obname, PLSA_STRING plsas) + { + Py_ssize_t len; + if (PyString_AsStringAndSize(obname, &plsas->Buffer, &len)==-1) + return FALSE; + if (len>USHRT_MAX){ + PyErr_Format(PyExc_ValueError,"String can be at most %d characters", USHRT_MAX); + return FALSE; + } + plsas->Length=(USHORT)len; + plsas->MaximumLength=plsas->Length; + return TRUE; + } + BOOL PyWinObject_AsLSA_UNICODE_STRING(PyObject *obstr, LSA_UNICODE_STRING *plsaus, BOOL bNoneOk) { ! DWORD len = 0; ! ZeroMemory(plsaus, sizeof(plsaus)); ! if (!PyWinObject_AsWCHAR(obstr, &plsaus->Buffer, bNoneOk, &len)) return FALSE; ! // Length is in bytes, not characters, and does not include null terminator ! static USHORT max_len = USHRT_MAX/sizeof(WCHAR) - 1; ! if (len > max_len){ ! PyErr_Format(PyExc_ValueError,"String can be at most %d characters", max_len); ! PyWinObject_FreeWCHAR(plsaus->Buffer); ! plsaus->Buffer=NULL; ! return FALSE; ! } ! if (plsaus->Buffer){ ! plsaus->Length = (USHORT)len * sizeof(WCHAR); ! plsaus->MaximumLength=plsaus->Length+sizeof(WCHAR); ! } return TRUE; } *************** *** 628,632 **** ADD_UNICODE_CONSTANT(SE_REMOTE_INTERACTIVE_LOGON_NAME); ADD_UNICODE_CONSTANT(SE_DENY_REMOTE_INTERACTIVE_LOGON_NAME); ! PyDict_SetItemString(d,"MSV1_0_PACKAGE_NAME",PyString_FromString(MSV1_0_PACKAGE_NAME)); PyDict_SetItemString(d,"MICROSOFT_KERBEROS_NAME_A",PyString_FromString(MICROSOFT_KERBEROS_NAME_A)); --- 647,659 ---- ADD_UNICODE_CONSTANT(SE_REMOTE_INTERACTIVE_LOGON_NAME); ADD_UNICODE_CONSTANT(SE_DENY_REMOTE_INTERACTIVE_LOGON_NAME); ! ADD_UNICODE_CONSTANT(SE_IMPERSONATE_NAME); ! ADD_UNICODE_CONSTANT(SE_CREATE_GLOBAL_NAME); ! /* ! ADD_UNICODE_CONSTANT(SE_TRUSTED_CREDMAN_ACCESS_NAME); ! ADD_UNICODE_CONSTANT(SE_RELABEL_NAME); ! ADD_UNICODE_CONSTANT(SE_INC_WORKING_SET_NAME); ! ADD_UNICODE_CONSTANT(SE_TIME_ZONE_NAME); ! ADD_UNICODE_CONSTANT(SE_CREATE_SYMBOLIC_LINK_NAME); ! */ PyDict_SetItemString(d,"MSV1_0_PACKAGE_NAME",PyString_FromString(MSV1_0_PACKAGE_NAME)); PyDict_SetItemString(d,"MICROSOFT_KERBEROS_NAME_A",PyString_FromString(MICROSOFT_KERBEROS_NAME_A)); *************** *** 1637,1643 **** TOKEN_SOURCE *ts = (TOKEN_SOURCE *)buf; PLUID pluid = &ts->SourceIdentifier; ! PyObject *obluid = PyWinObject_FromLARGE_INTEGER(*((LARGE_INTEGER *) pluid)); ! ret = Py_BuildValue("(s#O)",ts->SourceName,8,obluid); ! Py_DECREF(obluid); break; } --- 1664,1670 ---- TOKEN_SOURCE *ts = (TOKEN_SOURCE *)buf; PLUID pluid = &ts->SourceIdentifier; ! ret = Py_BuildValue("NN", ! PyString_FromStringAndSize(ts->SourceName,8), ! PyWinObject_FromLARGE_INTEGER(*((LARGE_INTEGER *) pluid))); break; } *************** *** 2062,2076 **** return NULL; if (!PyWinObject_AsLSA_UNICODE_STRING(obsystem_name, &system_name, TRUE)) ! goto done; ntsResult = LsaOpenPolicy(&system_name, &ObjectAttributes, access_mask, &lsahPolicyHandle); ! if (ntsResult != STATUS_SUCCESS){ PyWin_SetAPIError("LsaOpenPolicy",LsaNtStatusToWinError(ntsResult)); ! goto done; ! } ! ret = PyWinObject_FromLSA_HANDLE(lsahPolicyHandle); ! done: ! PyWinObject_FreeTCHAR(system_name.Buffer); ! return ret; } %} --- 2089,2101 ---- return NULL; if (!PyWinObject_AsLSA_UNICODE_STRING(obsystem_name, &system_name, TRUE)) ! return NULL; ntsResult = LsaOpenPolicy(&system_name, &ObjectAttributes, access_mask, &lsahPolicyHandle); ! if (ntsResult != STATUS_SUCCESS) PyWin_SetAPIError("LsaOpenPolicy",LsaNtStatusToWinError(ntsResult)); ! else ! ret = PyWinObject_FromLSA_HANDLE(lsahPolicyHandle); ! PyWinObject_FreeWCHAR(system_name.Buffer); ! return ret; } %} *************** *** 2967,2976 **** HANDLE lsahandle; NTSTATUS err; LSA_STRING LogonProcessName; LSA_OPERATIONAL_MODE dummy; // sdk says this should be ignored // @pyparm string|LogonProcessName||Name to use for this logon process ! if (!PyArg_ParseTuple(args, "s#:LsaRegisterLogonProcess", &LogonProcessName.Buffer, &LogonProcessName.Length)) return NULL; - LogonProcessName.MaximumLength=LogonProcessName.Length+1; err=(*pfnLsaRegisterLogonProcess)(&LogonProcessName, &lsahandle, &dummy); if (err==STATUS_SUCCESS) --- 2992,3003 ---- HANDLE lsahandle; NTSTATUS err; + PyObject *obname; LSA_STRING LogonProcessName; LSA_OPERATIONAL_MODE dummy; // sdk says this should be ignored // @pyparm string|LogonProcessName||Name to use for this logon process ! if (!PyArg_ParseTuple(args, "O:LsaRegisterLogonProcess", &obname)) ! return NULL; ! if (!PyWinObject_AsLSA_STRING(obname, &LogonProcessName)) return NULL; err=(*pfnLsaRegisterLogonProcess)(&LogonProcessName, &lsahandle, &dummy); if (err==STATUS_SUCCESS) *************** *** 3028,3042 **** NTSTATUS err; HANDLE lsahandle; ! PyObject *obhandle; LSA_STRING packagename; ULONG packageid; // @pyparm <o PyLsaLogon_HANDLE>|LsaHandle||An Lsa handle as returned by <om win32security.LsaConnectUntrusted> or <om win32security.LsaRegisterLogonProcess> // @pyparm string|PackageName||Name of security package to be identified ! if (!PyArg_ParseTuple(args,"Os#:LsaLookupAuthenticationPackage", &obhandle, &packagename.Buffer, &packagename.Length)) return NULL; if (!PyWinObject_AsHANDLE(obhandle, &lsahandle, FALSE)) return NULL; ! ! packagename.MaximumLength=packagename.Length+1; err=(*pfnLsaLookupAuthenticationPackage)(lsahandle, &packagename, &packageid); if (err!=STATUS_SUCCESS) --- 3055,3070 ---- NTSTATUS err; HANDLE lsahandle; ! PyObject *obhandle, *obname; LSA_STRING packagename; ULONG packageid; // @pyparm <o PyLsaLogon_HANDLE>|LsaHandle||An Lsa handle as returned by <om win32security.LsaConnectUntrusted> or <om win32security.LsaRegisterLogonProcess> // @pyparm string|PackageName||Name of security package to be identified ! if (!PyArg_ParseTuple(args,"OO:LsaLookupAuthenticationPackage", ! &obhandle, &obname)) return NULL; if (!PyWinObject_AsHANDLE(obhandle, &lsahandle, FALSE)) return NULL; ! if (!PyWinObject_AsLSA_STRING(obname, &packagename)) ! return NULL; err=(*pfnLsaLookupAuthenticationPackage)(lsahandle, &packagename, &packageid); if (err!=STATUS_SUCCESS) |
From: Roger U. <ru...@us...> - 2007-05-27 17:32:19
|
Update of /cvsroot/pywin32/pywin32/win32/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11699/win32/src Modified Files: PyWinTypes.h PyWinTypesmodule.cpp win32apimodule.cpp win32file.i Log Message: Move PyWinObject_AsReadBuffer into Pywintypes Fix some 's#' 64-bit issues in win32api Fix memory leak in GetShortPathName Index: win32apimodule.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/src/win32apimodule.cpp,v retrieving revision 1.74 retrieving revision 1.75 diff -C2 -d -r1.74 -r1.75 *** win32apimodule.cpp 6 Mar 2007 19:42:34 -0000 1.74 --- win32apimodule.cpp 27 May 2007 17:32:14 -0000 1.75 *************** *** 1330,1339 **** { char *key; - int len; // @pyparm chr|char||Specifies a character ! if (!PyArg_ParseTuple(args, "s#:VkKeyScan", &key, &len)) return (NULL); - if (len != 1) - return PyErr_Format(PyExc_ValueError, "arg must be a string of length 1"); int ret; PyW32_BEGIN_ALLOW_THREADS --- 1330,1336 ---- { char *key; // @pyparm chr|char||Specifies a character ! if (!PyArg_ParseTuple(args, "c:VkKeyScan", &key)) return (NULL); int ret; PyW32_BEGIN_ALLOW_THREADS *************** *** 1403,1407 **** return ReturnAPIError("GetLogicalDriveStrings"); } else { ! PyObject * retval = Py_BuildValue ("s#", buffer, result); delete [] buffer; return (retval); --- 1400,1404 ---- return ReturnAPIError("GetLogicalDriveStrings"); } else { ! PyObject * retval = PyString_FromStringAndSize (buffer, result); delete [] buffer; return (retval); *************** *** 1797,1804 **** char *szSection; char *data; - int dataSize; // @pyparm string|section||The section in the INI file to retrieve a entries for. // @pyparm string|data||The data to write. This must be string, with each entry terminated with '\0', followed by another terminating '\0' ! if (!PyArg_ParseTuple(args, "ss#:WriteProfileSection", &szSection, &data, &dataSize)) return NULL; PyW32_BEGIN_ALLOW_THREADS --- 1794,1800 ---- char *szSection; char *data; // @pyparm string|section||The section in the INI file to retrieve a entries for. // @pyparm string|data||The data to write. This must be string, with each entry terminated with '\0', followed by another terminating '\0' ! if (!PyArg_ParseTuple(args, "ss:WriteProfileSection", &szSection, &data)) return NULL; PyW32_BEGIN_ALLOW_THREADS *************** *** 1806,1810 **** PyW32_END_ALLOW_THREADS if (!ok) ! return ReturnAPIError("GetTempPath"); Py_INCREF(Py_None); return Py_None; --- 1802,1806 ---- PyW32_END_ALLOW_THREADS if (!ok) ! return ReturnAPIError("WriteProfileSection"); Py_INCREF(Py_None); return Py_None; *************** *** 1872,1875 **** --- 1868,1872 ---- DWORD rc = GetShortPathName(path, szOutPath, sizeof(szOutPath)); PyW32_END_ALLOW_THREADS + PyWinObject_FreeString(path); if (rc==0) return ReturnAPIError("GetShortPathName"); *************** *** 1886,1889 **** --- 1883,1887 ---- DWORD rc = GetShortPathNameW(path, szOutPath, sizeof(szOutPath)); PyW32_END_ALLOW_THREADS + PyWinObject_FreeWCHAR(path); if (rc==0) return ReturnAPIError("GetShortPathNameW"); *************** *** 3207,3211 **** obData = Py_None; } else ! obData = Py_BuildValue("s#", (char *)retDataBuf, retDataSize); break; } --- 3205,3209 ---- obData = Py_None; } else ! obData = PyString_FromStringAndSize((char *)retDataBuf, retDataSize); break; } *************** *** 4738,4741 **** --- 4736,4740 ---- PyObject *obName; PyObject *ret=NULL; + PyObject *obData; LPVOID lpData; DWORD cbData; *************** *** 4743,4752 **** LPWSTR lpType=NULL,lpName=NULL; ! if ( !PyArg_ParseTuple(args, "OOOs#|H:UpdateResource", &obhUpdate, // @pyparm <o PyHANDLE>|handle||The update-file handle. &obType, // @pyparm <o PyResourceId>|type||The type of resource to update &obName, // @pyparm <o PyResourceId>|name||The id/name of the resource to update ! &lpData, // @pyparm string|data||The data to place into the resource. ! &cbData, &wLanguage // @pyparm int|language|NEUTRAL|Language to use, defaults to LANG_NEUTRAL. ) ) --- 4742,4750 ---- LPWSTR lpType=NULL,lpName=NULL; ! if ( !PyArg_ParseTuple(args, "OOOO|H:UpdateResource", &obhUpdate, // @pyparm <o PyHANDLE>|handle||The update-file handle. &obType, // @pyparm <o PyResourceId>|type||The type of resource to update &obName, // @pyparm <o PyResourceId>|name||The id/name of the resource to update ! &obData, // @pyparm string|data||The data to place into the resource. &wLanguage // @pyparm int|language|NEUTRAL|Language to use, defaults to LANG_NEUTRAL. ) ) *************** *** 4755,4759 **** if (PyWinObject_AsHANDLE(obhUpdate, (HANDLE *)&hUpdate, FALSE) &&PyWinObject_AsResourceIdW(obType, &lpType) ! &&PyWinObject_AsResourceIdW(obName, &lpName)){ if (UpdateResourceW(hUpdate, lpType, lpName, wLanguage, lpData, cbData)){ Py_INCREF(Py_None); --- 4753,4758 ---- if (PyWinObject_AsHANDLE(obhUpdate, (HANDLE *)&hUpdate, FALSE) &&PyWinObject_AsResourceIdW(obType, &lpType) ! &&PyWinObject_AsResourceIdW(obName, &lpName) ! &&PyWinObject_AsReadBuffer(obData, &lpData, &cbData, FALSE)){ if (UpdateResourceW(hUpdate, lpType, lpName, wLanguage, lpData, cbData)){ Py_INCREF(Py_None); Index: PyWinTypesmodule.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/src/PyWinTypesmodule.cpp,v retrieving revision 1.28 retrieving revision 1.29 diff -C2 -d -r1.28 -r1.29 *** PyWinTypesmodule.cpp 7 May 2007 03:41:21 -0000 1.28 --- PyWinTypesmodule.cpp 27 May 2007 17:32:14 -0000 1.29 *************** *** 669,672 **** --- 669,725 ---- } + // Buffer conversion functions that use DWORD for length + BOOL PyWinObject_AsReadBuffer(PyObject *ob, void **buf, DWORD *buf_len, BOOL bNoneOk) + { + if (ob==Py_None){ + if (bNoneOk){ + *buf_len=0; + *buf=NULL; + return TRUE; + } + PyErr_SetString(PyExc_TypeError, "Buffer cannot be None"); + return FALSE; + } + Py_ssize_t py_len; + if (PyObject_AsReadBuffer(ob, (const void **)buf, &py_len)==-1) + return FALSE; + + #ifdef _WIN64 + if (py_len>MAXDWORD){ + PyErr_Format(PyExc_ValueError,"Buffer length can be at most %d characters", MAXDWORD); + return FALSE; + } + #endif + + *buf_len=(DWORD)py_len; + return TRUE; + } + + BOOL PyWinObject_AsWriteBuffer(PyObject *ob, void **buf, DWORD *buf_len, BOOL bNoneOk) + { + if (ob==Py_None){ + if (bNoneOk){ + *buf_len=0; + *buf=NULL; + return TRUE; + } + PyErr_SetString(PyExc_TypeError, "Buffer cannot be None"); + return FALSE; + } + Py_ssize_t py_len; + if (PyObject_AsWriteBuffer(ob, buf, &py_len)==-1) + return FALSE; + + #ifdef _WIN64 + if (py_len>MAXDWORD){ + PyErr_Format(PyExc_ValueError,"Buffer length can be at most %d characters", MAXDWORD); + return FALSE; + } + #endif + + *buf_len=(DWORD)py_len; + return TRUE; + } + /* List of functions exported by this module */ Index: PyWinTypes.h =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/src/PyWinTypes.h,v retrieving revision 1.40 retrieving revision 1.41 diff -C2 -d -r1.40 -r1.41 *** PyWinTypes.h 24 May 2007 06:54:50 -0000 1.40 --- PyWinTypes.h 27 May 2007 17:32:14 -0000 1.41 *************** *** 155,158 **** --- 155,159 ---- #endif // NO_PYWINTYPES_BSTR + // Given a string or Unicode object, get WCHAR characters. PYWINTYPES_EXPORT BOOL PyWinObject_AsWCHAR(PyObject *stringObject, WCHAR **pResult, BOOL bNoneOK = FALSE, DWORD *pResultLen = NULL); *************** *** 174,178 **** #endif - // Given a PyObject (string, Unicode, etc) create a "char *" with the value // if pResultLen != NULL, it will be set to the result size NOT INCLUDING --- 175,178 ---- *************** *** 183,186 **** --- 183,191 ---- PYWINTYPES_EXPORT void PyWinObject_FreeString(WCHAR *pResult); + // Buffer functions that can be used in place of 's#' input format or PyString_AsStringAndSize + // for 64-bit compatibility and API consistency + PYWINTYPES_EXPORT BOOL PyWinObject_AsReadBuffer(PyObject *ob, void **buf, DWORD *buf_len, BOOL bNoneOk=FALSE); + PYWINTYPES_EXPORT BOOL PyWinObject_AsWriteBuffer(PyObject *ob, void **buf, DWORD *buf_len, BOOL bNoneOk=FALSE); + /* ANSI/Unicode Support */ /* If UNICODE defined, will be a BSTR - otherwise a char * Index: win32file.i =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/src/win32file.i,v retrieving revision 1.81 retrieving revision 1.82 diff -C2 -d -r1.81 -r1.82 *** win32file.i 26 May 2007 15:45:38 -0000 1.81 --- win32file.i 27 May 2007 17:32:14 -0000 1.82 *************** *** 26,84 **** %include "pywin32.i" - %{ - // Helper functions that use DWORD for length - BOOL PyWinObject_AsReadBuffer(PyObject *ob, void **buf, DWORD *buf_len, BOOL bNoneOk=FALSE) - { - if (ob==Py_None){ - if (bNoneOk){ - *buf_len=0; - *buf=NULL; - return TRUE; - } - PyErr_SetString(PyExc_TypeError, "Buffer cannot be None"); - return FALSE; - } - Py_ssize_t py_len; - if (PyObject_AsReadBuffer(ob, (const void **)buf, &py_len)==-1) - return FALSE; - - #ifdef _WIN64 - if (py_len>MAXDWORD){ - PyErr_Format(PyExc_ValueError,"Buffer length can be at most %d characters", MAXDWORD); - return FALSE; - } - #endif - - *buf_len=(DWORD)py_len; - return TRUE; - } - - BOOL PyWinObject_AsWriteBuffer(PyObject *ob, void **buf, DWORD *buf_len, BOOL bNoneOk=FALSE) - { - if (ob==Py_None){ - if (bNoneOk){ - *buf_len=0; - *buf=NULL; - return TRUE; - } - PyErr_SetString(PyExc_TypeError, "Buffer cannot be None"); - return FALSE; - } - Py_ssize_t py_len; - if (PyObject_AsWriteBuffer(ob, buf, &py_len)==-1) - return FALSE; - - #ifdef _WIN64 - if (py_len>MAXDWORD){ - PyErr_Format(PyExc_ValueError,"Buffer length can be at most %d characters", MAXDWORD); - return FALSE; - } - #endif - - *buf_len=(DWORD)py_len; - return TRUE; - } - %} - #define FILE_GENERIC_READ FILE_GENERIC_READ #define FILE_GENERIC_WRITE FILE_GENERIC_WRITE --- 26,29 ---- *************** *** 1487,1491 **** else{ PyErr_Clear(); ! if (!PyWinObject_AsReadBuffer(obBuffer, &buf, &bufSize, FALSE)){ PyErr_SetString(PyExc_TypeError, "buffer param must be an integer or a buffer object"); goto done; --- 1432,1436 ---- else{ PyErr_Clear(); ! if (!PyWinObject_AsWriteBuffer(obBuffer, &buf, &bufSize, FALSE)){ PyErr_SetString(PyExc_TypeError, "buffer param must be an integer or a buffer object"); goto done; *************** *** 3567,3572 **** HANDLE h; BYTE *buf; ! Py_ssize_t buflen; ! DWORD bytes_requested, bytes_read; BOOL bAbort,bProcessSecurity; LPVOID ctxt; --- 3512,3516 ---- HANDLE h; BYTE *buf; ! DWORD buflen, bytes_requested, bytes_read; BOOL bAbort,bProcessSecurity; LPVOID ctxt; *************** *** 3583,3587 **** if (obbufout==NULL) return NULL; ! if (PyObject_AsWriteBuffer(obbufout, (void **)&buf, &buflen)==-1){ Py_DECREF(obbufout); return NULL; --- 3527,3531 ---- if (obbufout==NULL) return NULL; ! if (!PyWinObject_AsWriteBuffer(obbufout, (void **)&buf, &buflen)){ Py_DECREF(obbufout); return NULL; *************** *** 3590,3596 **** else{ obbufout=obbuf; ! if (PyObject_AsWriteBuffer(obbufout, (void **)&buf, &buflen)==-1) return NULL; ! if ((DWORD)buflen < bytes_requested) return PyErr_Format(PyExc_ValueError,"Buffer size (%d) less than requested read size (%d)", buflen, bytes_requested); Py_INCREF(obbufout); --- 3534,3540 ---- else{ obbufout=obbuf; ! if (!PyWinObject_AsWriteBuffer(obbufout, (void **)&buf, &buflen)) return NULL; ! if (buflen < bytes_requested) return PyErr_Format(PyExc_ValueError,"Buffer size (%d) less than requested read size (%d)", buflen, bytes_requested); Py_INCREF(obbufout); |
From: Mark H. <mha...@us...> - 2007-05-27 13:25:44
|
Update of /cvsroot/pywin32/pywin32/win32/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17551 Modified Files: win32gui.i win32helpmodule.cpp Log Message: Replace all uses of T_INT to deal with pointer/handle properties with explicit get/setattr code. Index: win32helpmodule.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/src/win32helpmodule.cpp,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** win32helpmodule.cpp 1 Oct 2004 00:11:56 -0000 1.3 --- win32helpmodule.cpp 27 May 2007 13:25:42 -0000 1.4 *************** *** 1044,1051 **** {"showState", T_INT, OFF(m_HH_WINTYPE.nShowState)}, // HWND hwndHelp; // @prop int|hwndHelp|Specifies the handle of the window if the window has //been created. - {"hwndHelp", T_INT, OFF(m_HH_WINTYPE.hwndHelp)}, // HWND hwndCaller; --- 1044,1051 ---- {"showState", T_INT, OFF(m_HH_WINTYPE.nShowState)}, + // These params handled below... // HWND hwndHelp; // @prop int|hwndHelp|Specifies the handle of the window if the window has //been created. // HWND hwndCaller; *************** *** 1053,1070 **** //notification messages. Notification messages are sent via Windows //WM_NOTIFY messages. - {"hwndCaller", T_INT, OFF(m_HH_WINTYPE.hwndCaller)}, // HWND hwndToolBar; // @prop int|hwndToolBar|Specifies the handle of the toolbar. - {"hwndToolBar", T_INT, OFF(m_HH_WINTYPE.hwndToolBar)}, // HWND hwndNavigation; // @prop int|hwndNavigation|Specifies the handle of the Navigation pane. - {"hwndNavigation", T_INT, OFF(m_HH_WINTYPE.hwndNavigation)}, // HWND hwndHTML; // @prop int|hwndHTML|Specifies the handle of the Topic pane, which hosts //Shdocvw.dll. - {"hwndHTML", T_INT, OFF(m_HH_WINTYPE.hwndHTML)}, // int iNavWidth; --- 1053,1066 ---- *************** *** 1343,1346 **** --- 1339,1356 ---- } + if (strcmp("hwndHelp", name)==0) + return PyWinLong_FromVoidPtr(pO->m_HH_WINTYPE.hwndHelp); + + if (strcmp("hwndCaller", name)==0) + return PyWinLong_FromVoidPtr(pO->m_HH_WINTYPE.hwndCaller); + + if (strcmp("hwndToolBar", name)==0) + return PyWinLong_FromVoidPtr(pO->m_HH_WINTYPE.hwndToolBar); + + if (strcmp("hwndNavigation", name)==0) + return PyWinLong_FromVoidPtr(pO->m_HH_WINTYPE.hwndNavigation); + + if (strcmp("hwndHTML", name)==0) + return PyWinLong_FromVoidPtr(pO->m_HH_WINTYPE.hwndHTML); return PyMember_Get((char *)self, memberlist, name); } *************** *** 1476,1479 **** --- 1486,1504 ---- return -1; } + if (strcmp("hwndHelp", name)==0) + return PyWinLong_AsVoidPtr(v, (void **)&pO->m_HH_WINTYPE.hwndHelp) ? 0 : -1; + + if (strcmp("hwndCaller", name)==0) + return PyWinLong_AsVoidPtr(v, (void **)&pO->m_HH_WINTYPE.hwndCaller) ? 0 : -1; + + if (strcmp("hwndToolBar", name)==0) + return PyWinLong_AsVoidPtr(v, (void **)&pO->m_HH_WINTYPE.hwndToolBar) ? 0 : -1; + + if (strcmp("hwndNavigation", name)==0) + return PyWinLong_AsVoidPtr(v, (void **)&pO->m_HH_WINTYPE.hwndNavigation) ? 0 : -1; + + if (strcmp("hwndHTML", name)==0) + return PyWinLong_AsVoidPtr(v, (void **)&pO->m_HH_WINTYPE.hwndHTML) ? 0 : -1; + return PyMember_Set((char *)self, memberlist, name, v); } Index: win32gui.i =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/src/win32gui.i,v retrieving revision 1.107 retrieving revision 1.108 diff -C2 -d -r1.107 -r1.108 *** win32gui.i 24 May 2007 06:01:06 -0000 1.107 --- win32gui.i 27 May 2007 13:25:42 -0000 1.108 *************** *** 864,872 **** // {"cbClsExtra", T_INT, OFF(m_WNDCLASS.cbClsExtra)}, // @prop integer|cbClsExtra| {"cbWndExtra", T_INT, OFF(m_WNDCLASS.cbWndExtra)}, // @prop integer|cbWndExtra| ! {"hInstance", T_INT, OFF(m_WNDCLASS.hInstance)}, // @prop integer|hInstance| ! {"hIcon", T_INT, OFF(m_WNDCLASS.hIcon)}, // @prop integer|hIcon| ! {"hCursor", T_INT, OFF(m_WNDCLASS.hCursor)}, // @prop integer|hCursor| ! {"hbrBackground", T_INT, OFF(m_WNDCLASS.hbrBackground)}, // @prop integer|hbrBackground| ! {NULL} /* Sentinel */ // These 3 handled manually in PyWNDCLASS::getattr/setattr. The pymeth below is used as an // end tag, so these props will be lost if below it --- 864,875 ---- // {"cbClsExtra", T_INT, OFF(m_WNDCLASS.cbClsExtra)}, // @prop integer|cbClsExtra| {"cbWndExtra", T_INT, OFF(m_WNDCLASS.cbWndExtra)}, // @prop integer|cbWndExtra| ! {NULL} ! ! // ack - these are also handled now explicitly, as T_LONGLONG is too ! // stupid to handle ints :( ! // @prop integer|hInstance| ! // @prop integer|hIcon| ! // @prop integer|hCursor| ! // @prop integer|hbrBackground| // These 3 handled manually in PyWNDCLASS::getattr/setattr. The pymeth below is used as an // end tag, so these props will be lost if below it *************** *** 933,936 **** --- 936,951 ---- return ret; } + if (strcmp("hInstance", name)==0) + return PyWinLong_FromVoidPtr(pW->m_WNDCLASS.hInstance); + + if (strcmp("hIcon", name)==0) + return PyWinLong_FromVoidPtr(pW->m_WNDCLASS.hIcon); + + if (strcmp("hCursor", name)==0) + return PyWinLong_FromVoidPtr(pW->m_WNDCLASS.hCursor); + + if (strcmp("hbrBackground", name)==0) + return PyWinLong_FromVoidPtr(pW->m_WNDCLASS.hbrBackground); + return PyMember_Get((char *)self, memberlist, name); } *************** *** 983,986 **** --- 998,1013 ---- return 0; } + if (strcmp("hInstance", name)==0) + return PyWinLong_AsVoidPtr(v, (void **)&pW->m_WNDCLASS.hInstance) ? 0 : -1; + + if (strcmp("hIcon", name)==0) + return PyWinLong_AsVoidPtr(v, (void **)&pW->m_WNDCLASS.hIcon) ? 0 : -1; + + if (strcmp("hCursor", name)==0) + return PyWinLong_AsVoidPtr(v, (void **)&pW->m_WNDCLASS.hCursor) ? 0 : -1; + + if (strcmp("hbrBackground", name)==0) + return PyWinLong_AsVoidPtr(v, (void **)&pW->m_WNDCLASS.hbrBackground) ? 0 : -1; + return PyMember_Set((char *)self, memberlist, name, v); } |
From: Mark H. <mha...@us...> - 2007-05-27 12:54:02
|
Update of /cvsroot/pywin32/pywin32/Pythonwin In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5569 Modified Files: win32uiExt.h Log Message: Get pythonwin building again with Python 2.3 and earlier. Index: win32uiExt.h =================================================================== RCS file: /cvsroot/pywin32/pywin32/Pythonwin/win32uiExt.h,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** win32uiExt.h 24 May 2007 12:50:50 -0000 1.10 --- win32uiExt.h 27 May 2007 12:53:48 -0000 1.11 *************** *** 989,996 **** --- 989,1005 ---- template <class T> const AFX_MSGMAP_ENTRY CPythonPrtDlgFramework<T>::_messageEntries[] = { + #if _MFC_VER < 0x0700 + // Python 2.3 (ie, VS6) doesn't like the new version below. + ON_MESSAGE(WM_INITDIALOG, HandleInitDialog) + ON_COMMAND(IDC_PRINT_TO_FILE, HandlePrintToFile) + ON_COMMAND(IDC_PRINT_COLLATE, HandleCollate) + ON_COMMAND_RANGE(IDC_PRINT_RANGE_ALL, IDC_PRINT_RANGE_PAGES, HandlePrintRange) + #else + // Either vista/x64 doesn't like the old version above. ON_MESSAGE(WM_INITDIALOG, &CPythonPrtDlgFramework<T>::HandleInitDialog) ON_COMMAND(IDC_PRINT_TO_FILE, &CPythonPrtDlgFramework<T>::HandlePrintToFile) ON_COMMAND(IDC_PRINT_COLLATE, &CPythonPrtDlgFramework<T>::HandleCollate) ON_COMMAND_RANGE(IDC_PRINT_RANGE_ALL, IDC_PRINT_RANGE_PAGES, &CPythonPrtDlgFramework<T>::HandlePrintRange) + #endif {0, 0, 0, 0, AfxSig_end, (AFX_PMSG)0 } }; |
From: Roger U. <ru...@us...> - 2007-05-26 15:45:42
|
Update of /cvsroot/pywin32/pywin32/win32/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27764/win32/src Modified Files: win32file.i Log Message: Fix a few 's#' and Py_ssize_t 64 bit issues Index: win32file.i =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/src/win32file.i,v retrieving revision 1.80 retrieving revision 1.81 diff -C2 -d -r1.80 -r1.81 *** win32file.i 24 May 2007 06:01:06 -0000 1.80 --- win32file.i 26 May 2007 15:45:38 -0000 1.81 *************** *** 26,29 **** --- 26,84 ---- %include "pywin32.i" + %{ + // Helper functions that use DWORD for length + BOOL PyWinObject_AsReadBuffer(PyObject *ob, void **buf, DWORD *buf_len, BOOL bNoneOk=FALSE) + { + if (ob==Py_None){ + if (bNoneOk){ + *buf_len=0; + *buf=NULL; + return TRUE; + } + PyErr_SetString(PyExc_TypeError, "Buffer cannot be None"); + return FALSE; + } + Py_ssize_t py_len; + if (PyObject_AsReadBuffer(ob, (const void **)buf, &py_len)==-1) + return FALSE; + + #ifdef _WIN64 + if (py_len>MAXDWORD){ + PyErr_Format(PyExc_ValueError,"Buffer length can be at most %d characters", MAXDWORD); + return FALSE; + } + #endif + + *buf_len=(DWORD)py_len; + return TRUE; + } + + BOOL PyWinObject_AsWriteBuffer(PyObject *ob, void **buf, DWORD *buf_len, BOOL bNoneOk=FALSE) + { + if (ob==Py_None){ + if (bNoneOk){ + *buf_len=0; + *buf=NULL; + return TRUE; + } + PyErr_SetString(PyExc_TypeError, "Buffer cannot be None"); + return FALSE; + } + Py_ssize_t py_len; + if (PyObject_AsWriteBuffer(ob, buf, &py_len)==-1) + return FALSE; + + #ifdef _WIN64 + if (py_len>MAXDWORD){ + PyErr_Format(PyExc_ValueError,"Buffer length can be at most %d characters", MAXDWORD); + return FALSE; + } + #endif + + *buf_len=(DWORD)py_len; + return TRUE; + } + %} + #define FILE_GENERIC_READ FILE_GENERIC_READ #define FILE_GENERIC_WRITE FILE_GENERIC_WRITE *************** *** 301,305 **** { OVERLAPPED *pOverlapped; ! PyObject *obhFile; HANDLE hDevice; DWORD readSize; --- 356,360 ---- { OVERLAPPED *pOverlapped; ! PyObject *obhFile, *obwriteData; HANDLE hDevice; DWORD readSize; *************** *** 307,317 **** DWORD dwIoControlCode; ! char *writeData; DWORD writeSize; ! if (!PyArg_ParseTuple(args, "Ols#l|O:DeviceIoControl", &obhFile, // @pyparm int|hFile||Handle to the file &dwIoControlCode, // @pyparm int|dwIoControlCode||IOControl Code to use. ! &writeData, &writeSize, // @pyparm string|data||The data to write. &readSize, // @pyparm int|readSize||Size of the buffer to create for the read. &obOverlapped)) // @pyparm <o PyOVERLAPPED>|ol|None|An overlapped structure --- 362,372 ---- DWORD dwIoControlCode; ! void *writeData; DWORD writeSize; ! if (!PyArg_ParseTuple(args, "OlOl|O:DeviceIoControl", &obhFile, // @pyparm int|hFile||Handle to the file &dwIoControlCode, // @pyparm int|dwIoControlCode||IOControl Code to use. ! &obwriteData, // @pyparm string|data||The data to write. &readSize, // @pyparm int|readSize||Size of the buffer to create for the read. &obOverlapped)) // @pyparm <o PyOVERLAPPED>|ol|None|An overlapped structure *************** *** 325,330 **** if (!PyWinObject_AsHANDLE(obhFile, &hDevice)) return NULL; ! void *readData = malloc(readSize); DWORD numRead; BOOL ok; --- 380,390 ---- if (!PyWinObject_AsHANDLE(obhFile, &hDevice)) return NULL; ! // Some control codes call for NULL input buffer ! if (!PyWinObject_AsReadBuffer(obwriteData, &writeData, &writeSize, TRUE)) ! return NULL; void *readData = malloc(readSize); + if (readData==NULL) + return PyErr_Format(PyExc_MemoryError, "Unable to allocate %d bytes", readSize); + DWORD numRead; BOOL ok; *************** *** 855,865 **** PyObject *MyReadFile(PyObject *self, PyObject *args) { ! OVERLAPPED *pOverlapped; PyObject *obhFile; HANDLE hFile; DWORD bufSize; ! PyObject *obOverlapped = NULL; BOOL bBufMallocd = FALSE; ! PyObject *obBuf; if (!PyArg_ParseTuple(args, "OO|O:ReadFile", --- 915,925 ---- PyObject *MyReadFile(PyObject *self, PyObject *args) { ! OVERLAPPED *pOverlapped=NULL; PyObject *obhFile; HANDLE hFile; DWORD bufSize; ! PyObject *obOverlapped = Py_None; BOOL bBufMallocd = FALSE; ! PyObject *obBuf, *obRet=NULL; if (!PyArg_ParseTuple(args, "OO|O:ReadFile", *************** *** 868,920 **** &obOverlapped)) // @pyparm <o PyOVERLAPPED>|ol|None|An overlapped structure return NULL; // @comm in a multi-threaded overlapped environment, it is likely to be necessary to pre-allocate the read buffer using the <om win32file.AllocateReadBuffer> method, otherwise the I/O operation may complete before you can assign to the resulting buffer. ! if (obOverlapped==NULL) ! pOverlapped = NULL; ! else { if (!PyWinObject_AsOVERLAPPED(obOverlapped, &pOverlapped)) return NULL; ! } ! if (!PyWinObject_AsHANDLE(obhFile, &hFile)) ! return NULL; void *buf = NULL; - PyObject *pORB = NULL; PyBufferProcs *pb = NULL; ! if (PyInt_Check(obBuf)) { ! bufSize = PyInt_AsLong(obBuf); ! #ifndef MS_WINCE ! if (pOverlapped) { ! pORB = PyBuffer_New(bufSize); ! if (pORB==NULL) { ! PyErr_SetString(PyExc_MemoryError, "Allocating read buffer"); return NULL; } - pb = pORB->ob_type->tp_as_buffer; - (*pb->bf_getreadbuffer)(pORB, 0, &buf); - } else { - #endif - buf = malloc(bufSize); - bBufMallocd = TRUE; - #ifndef MS_WINCE } ! #endif ! if (buf==NULL) { ! PyErr_SetString(PyExc_MemoryError, "Allocating read buffer"); return NULL; } - } - #ifndef MS_WINCE - else if (obBuf->ob_type->tp_as_buffer){ - pb = obBuf->ob_type->tp_as_buffer; - pORB = obBuf; - Py_INCREF(pORB); - bufSize = (*pb->bf_getreadbuffer)(pORB, 0, &buf); - } - #endif // MS_WINCE - else { - PyErr_SetString(PyExc_TypeError, "Second param must be an integer or a buffer object"); - return NULL; - } DWORD numRead; --- 928,976 ---- &obOverlapped)) // @pyparm <o PyOVERLAPPED>|ol|None|An overlapped structure return NULL; + if (!PyWinObject_AsHANDLE(obhFile, &hFile)) + return NULL; + // @comm in a multi-threaded overlapped environment, it is likely to be necessary to pre-allocate the read buffer using the <om win32file.AllocateReadBuffer> method, otherwise the I/O operation may complete before you can assign to the resulting buffer. ! if (obOverlapped!=Py_None){ ! #ifdef MS_WINCE ! PyErr_SetString(PyExc_NotImplementedError,"Overlapped operation is not supported on this platform"); ! return NULL; ! #else if (!PyWinObject_AsOVERLAPPED(obOverlapped, &pOverlapped)) return NULL; ! #endif ! } void *buf = NULL; PyBufferProcs *pb = NULL; ! bufSize = PyLong_AsUnsignedLong(obBuf); ! if ((bufSize!=(DWORD)-1) || !PyErr_Occurred()){ ! if (pOverlapped){ // guaranteed to be NULL on CE ! obRet = PyBuffer_New(bufSize); ! if (obRet==NULL) return NULL; + pb = obRet->ob_type->tp_as_buffer; + (*pb->bf_getreadbuffer)(obRet, 0, &buf); + } + else{ + obRet=PyString_FromStringAndSize(NULL, bufSize); + if (obRet==NULL) + return NULL; + buf=PyString_AS_STRING(obRet); + bBufMallocd=TRUE; } } ! else{ ! PyErr_Clear(); ! if (!PyWinObject_AsWriteBuffer(obBuf, &buf, &bufSize,FALSE)){ ! PyErr_SetString(PyExc_TypeError, "Second param must be an integer or a buffer object"); return NULL; + } + if (pOverlapped){ + obRet = obBuf; + Py_INCREF(obBuf); + } } DWORD numRead; *************** *** 927,947 **** err = GetLastError(); if (err!=ERROR_MORE_DATA && err != ERROR_IO_PENDING) { ! Py_XDECREF(pORB); ! if (bBufMallocd) ! free(buf); return PyWin_SetAPIError("ReadFile", err); } } ! PyObject *obRet; ! if (pOverlapped) ! obRet = pORB; ! else ! obRet = PyString_FromStringAndSize((char *)buf, numRead); ! ! PyObject *result = Py_BuildValue("iO", err, obRet); ! Py_XDECREF(obRet); ! if (bBufMallocd) ! free(buf); ! return result; } --- 983,997 ---- err = GetLastError(); if (err!=ERROR_MORE_DATA && err != ERROR_IO_PENDING) { ! Py_XDECREF(obRet); return PyWin_SetAPIError("ReadFile", err); } } ! if (obRet==NULL) ! obRet=PyString_FromStringAndSize((char *)buf, numRead); ! else if (bBufMallocd && (numRead < bufSize)) ! _PyString_Resize(&obRet, numRead); ! if (obRet==NULL) ! return NULL; ! return Py_BuildValue("iN", err, obRet); } *************** *** 959,963 **** PyObject *obhFile; HANDLE hFile; ! char *writeData; DWORD writeSize; PyObject *obWriteData; --- 1009,1013 ---- PyObject *obhFile; HANDLE hFile; ! void *writeData; DWORD writeSize; PyObject *obWriteData; *************** *** 970,986 **** &obOverlapped)) // @pyparm <o PyOVERLAPPED>|ol|None|An overlapped structure return NULL; ! if (PyString_Check(obWriteData)) { ! writeData = PyString_AsString(obWriteData); ! writeSize = PyString_Size(obWriteData); ! } ! #ifndef MS_WINCE ! else if (obWriteData->ob_type->tp_as_buffer) { ! pb = obWriteData->ob_type->tp_as_buffer; ! writeSize = (*pb->bf_getreadbuffer)(obWriteData, 0, (void **)&writeData); ! } ! #endif // MS_WINCE ! else { ! return PyErr_Format(PyExc_TypeError, "Objects of type '%s' can not be directly written to a file", obWriteData->ob_type->tp_name); ! } if (obOverlapped==NULL) pOverlapped = NULL; --- 1020,1026 ---- &obOverlapped)) // @pyparm <o PyOVERLAPPED>|ol|None|An overlapped structure return NULL; ! if (!PyWinObject_AsReadBuffer(obWriteData, &writeData, &writeSize, FALSE)) ! return NULL; ! if (obOverlapped==NULL) pOverlapped = NULL; *************** *** 1434,1441 **** void *buf = NULL; ! int bufSize = 0; BOOL bBufMallocd = FALSE; ! if (PyInt_Check(obBuffer)) { ! bufSize = PyInt_AsLong(obBuffer); buf = malloc(bufSize); if (buf==NULL) { --- 1474,1481 ---- void *buf = NULL; ! DWORD bufSize = 0; BOOL bBufMallocd = FALSE; ! bufSize = PyLong_AsUnsignedLong(obBuffer); ! if ((bufSize!=(DWORD)-1) || !PyErr_Occurred()){ buf = malloc(bufSize); if (buf==NULL) { *************** *** 1445,1456 **** bBufMallocd = TRUE; } ! else if (obBuffer->ob_type->tp_as_buffer) { ! PyBufferProcs *pb = obBuffer->ob_type->tp_as_buffer; ! bufSize = (*pb->bf_getreadbuffer)(obBuffer, 0, &buf); ! } ! else { ! PyErr_SetString(PyExc_TypeError, "buffer param must be an integer or a buffer object"); ! goto done; ! } // OK, have a buffer and a size. --- 1485,1495 ---- bBufMallocd = TRUE; } ! else{ ! PyErr_Clear(); ! if (!PyWinObject_AsReadBuffer(obBuffer, &buf, &bufSize, FALSE)){ ! PyErr_SetString(PyExc_TypeError, "buffer param must be an integer or a buffer object"); ! goto done; ! } ! } // OK, have a buffer and a size. *************** *** 1492,1498 **** // will be smaller than the size of the buffer (and certainly never greater!) // @comm See <om win32file.ReadDirectoryChangesW> for more information. ! int bufSize, size; ! char *buf; ! if (!PyArg_ParseTuple(args, "s#i", &buf, &bufSize, &size)) return NULL; if (size > bufSize) --- 1531,1540 ---- // will be smaller than the size of the buffer (and certainly never greater!) // @comm See <om win32file.ReadDirectoryChangesW> for more information. ! DWORD bufSize, size; ! void *buf; ! PyObject *obbuf; ! if (!PyArg_ParseTuple(args, "Oi", &obbuf, &size)) ! return NULL; ! if (!PyWinObject_AsReadBuffer(obbuf, &buf, &bufSize, FALSE)) return NULL; if (size > bufSize) *************** *** 3125,3144 **** DWORD user_cnt; PENCRYPTION_CERTIFICATE *user_item=NULL; ! PyObject *obsid=NULL, *ret_item=NULL; PyObject *ret=PyTuple_New(pecl->nUsers); ! if (!ret){ ! PyErr_SetString(PyExc_MemoryError,"PyWinObject_FromPENCRYPTION_CERTIFICATE_LIST: unable to allocate return tuple"); return NULL; - } user_item=pecl->pUsers; for (user_cnt=0; user_cnt < pecl->nUsers; user_cnt++){ ! obsid=PyWinObject_FromSID((*user_item)->pUserSid); ! ret_item=Py_BuildValue("Ns#", obsid, (*user_item)->pCertBlob->pbData,(*user_item)->pCertBlob->cbData); if (!ret_item){ - PyErr_SetString(PyExc_MemoryError,"PyWinObject_FromPENCRYPTION_CERTIFICATE_LIST: unable to allocate tuple item"); Py_DECREF(ret); return NULL; } ! PyTuple_SetItem(ret, user_cnt, ret_item); user_item++; } --- 3167,3184 ---- DWORD user_cnt; PENCRYPTION_CERTIFICATE *user_item=NULL; ! PyObject *ret_item=NULL; PyObject *ret=PyTuple_New(pecl->nUsers); ! if (!ret) return NULL; user_item=pecl->pUsers; for (user_cnt=0; user_cnt < pecl->nUsers; user_cnt++){ ! ret_item=Py_BuildValue("NN", ! PyWinObject_FromSID((*user_item)->pUserSid), ! PyString_FromStringAndSize((char *)(*user_item)->pCertBlob->pbData, (*user_item)->pCertBlob->cbData)); if (!ret_item){ Py_DECREF(ret); return NULL; } ! PyTuple_SET_ITEM(ret, user_cnt, ret_item); user_item++; } *************** *** 3150,3174 **** DWORD user_cnt; PENCRYPTION_CERTIFICATE_HASH *user_item=NULL; ! PyObject *obsid=NULL, *obDisplayInformation=NULL, *ret_item=NULL; PyObject *ret=PyTuple_New(pechl->nCert_Hash); ! if (!ret){ ! PyErr_SetString(PyExc_MemoryError,"PyWinObject_FromPENCRYPTION_CERTIFICATE_HASH_LIST: unable to allocate return tuple"); return NULL; - } user_item=pechl->pUsers; for (user_cnt=0; user_cnt < pechl->nCert_Hash; user_cnt++){ ! obsid=PyWinObject_FromSID((*user_item)->pUserSid); ! obDisplayInformation=PyWinObject_FromWCHAR((*user_item)->lpDisplayInformation); ! if (!obDisplayInformation){ ! Py_DECREF(ret); ! return NULL; ! } ! ret_item=Py_BuildValue("Ns#N", obsid, (*user_item)->pHash->pbData,(*user_item)->pHash->cbData, obDisplayInformation); if (!ret_item){ - PyErr_SetString(PyExc_MemoryError,"PyWinObject_FromPENCRYPTION_CERTIFICATE_HASH_LIST: unable to allocate tuple item"); Py_DECREF(ret); return NULL; } ! PyTuple_SetItem(ret, user_cnt, ret_item); user_item++; } --- 3190,3208 ---- DWORD user_cnt; PENCRYPTION_CERTIFICATE_HASH *user_item=NULL; ! PyObject *ret_item=NULL; PyObject *ret=PyTuple_New(pechl->nCert_Hash); ! if (!ret) return NULL; user_item=pechl->pUsers; for (user_cnt=0; user_cnt < pechl->nCert_Hash; user_cnt++){ ! ret_item=Py_BuildValue("NNu", ! PyWinObject_FromSID((*user_item)->pUserSid), ! PyString_FromStringAndSize((char *)(*user_item)->pHash->pbData, (*user_item)->pHash->cbData), ! (*user_item)->lpDisplayInformation); if (!ret_item){ Py_DECREF(ret); return NULL; } ! PyTuple_SET_ITEM(ret, user_cnt, ret_item); user_item++; } |
From: Mark H. <mha...@us...> - 2007-05-25 11:26:00
|
Update of /cvsroot/pywin32/pywin32/win32/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv26384 Modified Files: PyHANDLE.cpp Log Message: Remove 'handle' from memberlist[] - it wasn't used as getattr got there first, and the existing T_INT specification is wrong on x64. Index: PyHANDLE.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/src/PyHANDLE.cpp,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** PyHANDLE.cpp 17 Feb 2007 07:37:47 -0000 1.14 --- PyHANDLE.cpp 25 May 2007 11:25:59 -0000 1.15 *************** *** 169,173 **** /*static*/ struct memberlist PyHANDLE::memberlist[] = { - {"handle", T_INT, OFF(m_handle)}, // @prop integer|handle|The win32 handle itself, as an integer. {NULL} /* Sentinel */ }; --- 169,172 ---- |
From: Mark H. <mha...@us...> - 2007-05-24 13:48:39
|
Update of /cvsroot/pywin32/pywin32/Pythonwin/pywin/framework In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1079 Modified Files: intpyapp.py sgrepmdi.py Added Files: mdi_pychecker.py Log Message: Nice contribution from kxroberto, via "[ 1623093 ] Pychecker Plug-In for PythonWin: mdi_pychecker". Open any Python file, then select 'File->New->Pychecker' - pychecker will run in the background. Index: intpyapp.py =================================================================== RCS file: /cvsroot/pywin32/pywin32/Pythonwin/pywin/framework/intpyapp.py,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** intpyapp.py 5 Mar 2005 03:24:13 -0000 1.9 --- intpyapp.py 24 May 2007 13:48:37 -0000 1.10 *************** *** 15,18 **** --- 15,28 ---- lastLocateFileName = ".py" # used in the "File/Locate" dialog... + # todo - _SetupSharedMenu should be moved to a framework class. + def _SetupSharedMenu_(self): + sharedMenu = self.GetSharedMenu() + from pywin.framework import toolmenu + toolmenu.SetToolsMenu(sharedMenu) + from pywin.framework import help + help.SetHelpMenuOtherHelp(sharedMenu) + from pywin.mfc import docview + docview.DocTemplate._SetupSharedMenu_=_SetupSharedMenu_ + class MainFrame(app.MainFrame): def OnCreate(self, createStruct): *************** *** 273,277 **** # Load the users modules. if moduleNames is None: ! default = "sgrepmdi" moduleNames=win32ui.GetProfileVal('Python','Startup Modules',default) self.DoLoadModules(moduleNames) --- 283,287 ---- # Load the users modules. if moduleNames is None: ! default = "sgrepmdi,mdi_pychecker" moduleNames=win32ui.GetProfileVal('Python','Startup Modules',default) self.DoLoadModules(moduleNames) --- NEW FILE: mdi_pychecker.py --- ###################################################################### ## ## The Pychecker MDI Plug-In UserModule for Pythonwin ## ## contributed by Robert Kiendl ## ## Style is similar to (and inherited) from the SGrepMDI UserModule ## ## Usage: ## ## Start Pychecker on current file: Menu/File/New../Pychecker. ## Use it: Jump to Pychecker warning source lines by double-click. ## Auto-add "#$pycheck_no" / "#$pycheck_no=specific-re-pattern" tags ## to source lines by context/right-mouse-click on warning lines. ## ## It requires pychecker installed and the pychecker.bat to be on ## the PATH. Example pychecker.bat: ## ## REM pychecker.bat ## C:\bin\python.exe C:\PYTHON23\Lib\site-packages\pychecker\checker.py %1 %2 %3 %4 %5 %6 %7 %8 %9 ## ## Adding it as default module in PythonWin: ## ## +++ ./intpyapp.py 2006-10-02 17:59:32.974161600 +0200 ## @@ -272,7 +282,7 @@ ## def LoadUserModules(self, moduleNames = None): ## # Load the users modules. ## if moduleNames is None: ## - default = "sgrepmdi" ## + default = "sgrepmdi,mdi_pychecker" ## moduleNames=win32ui.GetProfileVal('Python','Startup Modules',default) ## self.DoLoadModules(moduleNames) ## ###################################################################### import win32ui import win32api from pywin.mfc import docview, dialog, window import win32con import sys, string, re, glob, os, stat, time import scriptutils def getsubdirs(d): dlist = [] flist = glob.glob(d+'\\*') for f in flist: if os.path.isdir(f): dlist.append(f) dlist = dlist + getsubdirs(f) return dlist class dirpath: def __init__(self, str, recurse=0): dp = string.split(str, ';') dirs = {} for d in dp: if os.path.isdir(d): d = string.lower(d) if not dirs.has_key(d): dirs[d] = None if recurse: subdirs = getsubdirs(d) for sd in subdirs: sd = string.lower(sd) if not dirs.has_key(sd): dirs[sd] = None elif os.path.isfile(d): pass else: x = None if os.environ.has_key(d): x = dirpath(os.environ[d]) elif d[:5] == 'HKEY_': keystr = string.split(d,'\\') try: root = eval('win32con.'+keystr[0]) except: win32ui.MessageBox("Can't interpret registry key name '%s'" % keystr[0]) try: subkey = string.join(keystr[1:], '\\') val = win32api.RegQueryValue(root, subkey) if val: x = dirpath(val) else: win32ui.MessageBox("Registry path '%s' did not return a path entry" % d) except: win32ui.MessageBox("Can't interpret registry key value: %s" % keystr[1:]) else: win32ui.MessageBox("Directory '%s' not found" % d) if x: for xd in x: if not dirs.has_key(xd): dirs[xd] = None if recurse: subdirs = getsubdirs(xd) for sd in subdirs: sd = string.lower(sd) if not dirs.has_key(sd): dirs[sd] = None self.dirs = [] for d in dirs.keys(): self.dirs.append(d) def __getitem__(self, key): return self.dirs[key] def __len__(self): return len(self.dirs) def __setitem__(self, key, value): self.dirs[key] = value def __delitem__(self, key): del self.dirs[key] def __getslice__(self, lo, hi): return self.dirs[lo:hi] def __setslice__(self, lo, hi, seq): self.dirs[lo:hi] = seq def __delslice__(self, lo, hi): del self.dirs[lo:hi] def __add__(self, other): if type(other) == type(self) or type(other) == type([]): return self.dirs + other.dirs def __radd__(self, other): if type(other) == type(self) or type(other) == type([]): return other.dirs + self.dirs # Group(1) is the filename, group(2) is the lineno. #regexGrepResult=regex.compile("^\\([a-zA-Z]:.*\\)(\\([0-9]+\\))") #regexGrep=re.compile(r"^([a-zA-Z]:[^(]*)\((\d+)\)") regexGrep=re.compile(r"^(..[^\(:]+)?[\(:](\d+)[\):]:?\s*(.*)") #these are the atom numbers defined by Windows for basic dialog controls BUTTON = 0x80 EDIT = 0x81 STATIC = 0x82 LISTBOX = 0x83 SCROLLBAR = 0x84 COMBOBOX = 0x85 class TheTemplate(docview.RichEditDocTemplate): def __init__(self): docview.RichEditDocTemplate.__init__(self, win32ui.IDR_TEXTTYPE, TheDocument, TheFrame, TheView) self.SetDocStrings("\nPychecker\nPychecker\nPychecker params (*.pychecker)\n.pychecker\n\n\n") win32ui.GetApp().AddDocTemplate(self) self.docparams = None def MatchDocType(self, fileName, fileType): doc = self.FindOpenDocument(fileName) if doc: return doc ext = string.lower(os.path.splitext(fileName)[1]) if ext =='.pychecker': return win32ui.CDocTemplate_Confidence_yesAttemptNative return win32ui.CDocTemplate_Confidence_noAttempt def setParams(self, params): self.docparams = params def readParams(self): tmp = self.docparams self.docparams = None return tmp class TheFrame(window.MDIChildWnd): # The template and doc params will one day be removed. def __init__(self, wnd = None): window.MDIChildWnd.__init__(self, wnd) class TheDocument(docview.RichEditDoc): def __init__(self, template): docview.RichEditDoc.__init__(self, template) self.dirpattern = '' self.filpattern = '' self.greppattern = '' self.casesensitive = 1 self.recurse = 1 self.verbose = 0 def OnOpenDocument(self, fnm): #this bizarre stuff with params is so right clicking in a result window #and starting a new grep can communicate the default parameters to the #new grep. try: params = open(fnm,'r').read() except: params = None self.setInitParams(params) return self.OnNewDocument() def OnCloseDocument(self): try: win32ui.GetApp().DeleteIdleHandler(self.idleHandler) except: pass return self._obj_.OnCloseDocument() def saveInitParams(self): # Only save the flags, not the text boxes. paramstr = "\t\t\t%d\t%d" % (self.casesensitive, self.recurse) win32ui.WriteProfileVal("Pychecker", "Params", paramstr) def setInitParams(self, paramstr): if paramstr is None: paramstr = win32ui.GetProfileVal("Pychecker", "Params", '\t\t\t1\t0\t0') params = string.split(paramstr, '\t') if len(params) < 3: params = params + ['']*(3-len(params)) if len(params) < 6: params = params + [0]*(6-len(params)) self.dirpattern = params[0] self.filpattern = params[1] self.greppattern = params[2] or '-#1000' self.casesensitive = int(params[3]) self.recurse = int(params[4]) self.verbose = int(params[5]) # setup some reasonable defaults. if not self.dirpattern: try: editor=win32ui.GetMainFrame().MDIGetActive()[0].GetEditorView() self.dirpattern=os.path.abspath(os.path.dirname(editor.GetDocument().GetPathName())) except (AttributeError,win32ui.error): self.dirpattern = os.getcwd() if not self.filpattern: try: editor=win32ui.GetMainFrame().MDIGetActive()[0].GetEditorView() self.filpattern=editor.GetDocument().GetPathName() except AttributeError: self.filpattern = "*.py" def OnNewDocument(self): if self.dirpattern == '': self.setInitParams(greptemplate.readParams()) d = TheDialog(self.dirpattern, self.filpattern, self.greppattern, self.casesensitive, self.recurse, self.verbose) if d.DoModal() == win32con.IDOK: self.dirpattern = d['dirpattern'] self.filpattern = d['filpattern'] self.greppattern = d['greppattern'] #self.casesensitive = d['casesensitive'] #self.recurse = d['recursive'] #self.verbose = d['verbose'] self.doSearch() self.saveInitParams() return 1 return 0 # cancelled - return zero to stop frame creation. def doSearch(self): self.dp = dirpath(self.dirpattern, self.recurse) self.SetTitle("Pychecker Run '%s' (options: %s)" % (self.filpattern, self.greppattern)) #self.text = [] self.GetFirstView().Append('#Pychecker Run in '+self.dirpattern+' %s\n'%time.asctime()) if self.verbose: self.GetFirstView().Append('# ='+`self.dp.dirs`+'\n') self.GetFirstView().Append('# Files '+self.filpattern+'\n') self.GetFirstView().Append('# Options '+self.greppattern+'\n') self.fplist = string.split(self.filpattern,';') self.GetFirstView().Append('# Running... ( double click on result lines in order to jump to the source code ) \n') win32ui.SetStatusText("Pychecker running. Please wait...", 0) self.dpndx = self.fpndx = 0 self.fndx = -1 if not self.dp: self.GetFirstView().Append("# ERROR: '%s' does not resolve to any search locations" % self.dirpattern) self.SetModifiedFlag(0) else: ##self.flist = glob.glob(self.dp[0]+'\\'+self.fplist[0]) import operator self.flist = reduce(operator.add, map(glob.glob,self.fplist) ) #import pywin.debugger;pywin.debugger.set_trace() self.startPycheckerRun() def idleHandler(self,handler,count): import time time.sleep(0.001) if self.result!=None: win32ui.GetApp().DeleteIdleHandler(self.idleHandler) return 0 return 1 #more def startPycheckerRun(self): self.result=None old=win32api.SetCursor(win32api.LoadCursor(0, win32con.IDC_APPSTARTING)) win32ui.GetApp().AddIdleHandler(self.idleHandler) import thread thread.start_new(self.threadPycheckerRun,()) ##win32api.SetCursor(old) def threadPycheckerRun(self): result='' rc=-1 try: options = self.greppattern files= ' '.join(self.flist) # Recently MarkH has failed to run pychecker without it having # been explicitly installed - so we assume it is and locate it # from its default location. # Step1 - get python.exe py = os.path.join(sys.prefix, 'python.exe') if not os.path.isfile(py): py = os.path.join(sys.prefix, 'PCBuild', 'python.exe') try: py = win32api.GetShortPathName(py) except win32api.error: py = "" # Find checker.py from distutils.sysconfig import get_python_lib pychecker = os.path.join(get_python_lib(), 'pychecker', 'checker.py') if not os.path.isfile(py): result = "Can't find python.exe!\n" elif not os.path.isfile(pychecker): result = "Can't find checker.py - please install pychecker " \ "(or run 'setup.py install' if you have the source version)\n" else: cmd='%s "%s" %s %s 2>&1' % (py, pychecker, options,files) ##fin,fout,ferr=os.popen3(cmd) ##result=ferr.read()+fout.read() result=os.popen(cmd).read() ##rc=f.close() self.GetFirstView().Append(result) finally: self.result=result print '== Pychecker run finished ==' self.GetFirstView().Append('\n'+'== Pychecker run finished ==') self.SetModifiedFlag(0) def _inactive_idleHandler(self, handler, count): self.fndx = self.fndx + 1 if self.fndx < len(self.flist): f = self.flist[self.fndx] if self.verbose: self.GetFirstView().Append('# ..'+f+'\n') win32ui.SetStatusText("Searching "+f, 0) lines = open(f, 'r').readlines() for i in range(len(lines)): line = lines[i] if self.pat.search(line) != None: self.GetFirstView().Append(f+'('+`i+1` + ') '+line) else: self.fndx = -1 self.fpndx = self.fpndx + 1 if self.fpndx < len(self.fplist): self.flist = glob.glob(self.dp[self.dpndx] + '\\' + self.fplist[self.fpndx]) else: self.fpndx = 0 self.dpndx = self.dpndx + 1 if self.dpndx < len(self.dp): self.flist = glob.glob(self.dp[self.dpndx] + '\\' + self.fplist[self.fpndx]) else: win32ui.SetStatusText("Search complete.", 0) self.SetModifiedFlag(0) # default to not modified. try: win32ui.GetApp().DeleteIdleHandler(self.idleHandler) except: pass return 0 return 1 def GetParams(self): return self.dirpattern+'\t'+self.filpattern+'\t'+self.greppattern+'\t'+`self.casesensitive`+'\t'+`self.recurse`+'\t'+`self.verbose` def OnSaveDocument(self, filename): # print 'OnSaveDocument() filename=',filename savefile = open(filename,"wb") txt = self.GetParams()+'\n' # print 'writing',txt savefile.write(txt) savefile.close() self.SetModifiedFlag(0) return 1 ID_OPEN_FILE = 0xe500 ID_PYCHECKER = 0xe501 ID_SAVERESULTS = 0x502 ID_TRYAGAIN = 0x503 ID_ADDCOMMENT = 0x504 ID_ADDPYCHECKNO2 = 0x505 class TheView(docview.RichEditView): def __init__(self, doc): docview.RichEditView.__init__(self, doc) self.SetWordWrap(win32ui.CRichEditView_WrapNone) self.HookHandlers() def OnInitialUpdate(self): rc = self._obj_.OnInitialUpdate() format = (-402653169, 0, 200, 0, 0, 0, 49, 'Courier New') self.SetDefaultCharFormat(format) return rc def HookHandlers(self): self.HookMessage(self.OnRClick, win32con.WM_RBUTTONDOWN) self.HookCommand(self.OnCmdOpenFile, ID_OPEN_FILE) self.HookCommand(self.OnCmdThe, ID_PYCHECKER) self.HookCommand(self.OnCmdSave, ID_SAVERESULTS) self.HookCommand(self.OnTryAgain, ID_TRYAGAIN) self.HookCommand(self.OnAddComment, ID_ADDCOMMENT) self.HookCommand(self.OnAddComment, ID_ADDPYCHECKNO2) self.HookMessage(self.OnLDblClick,win32con.WM_LBUTTONDBLCLK) def OnLDblClick(self,params): line = self.GetLine() regexGrepResult = regexGrep.match(line) if regexGrepResult: fname = regexGrepResult.group(1) line = string.atoi(regexGrepResult.group(2)) scriptutils.JumpToDocument(fname, line) return 0 # dont pass on return 1 # pass it on by default. def OnRClick(self, params): menu = win32ui.CreatePopupMenu() flags=win32con.MF_STRING|win32con.MF_ENABLED lineno = self._obj_.LineFromChar(-1) #selection or current line line = self._obj_.GetLine(lineno) regexGrepResult = regexGrep.match(line) charstart, charend = self._obj_.GetSel() if regexGrepResult: self.fnm = regexGrepResult.group(1) self.lnnum = string.atoi(regexGrepResult.group(2)) menu.AppendMenu(flags, ID_OPEN_FILE, "&Open "+self.fnm) menu.AppendMenu(flags, ID_ADDCOMMENT, "&Add to source: Comment Tag/#$pycheck_no ..") menu.AppendMenu(flags, ID_ADDPYCHECKNO2, "&Add to source: Specific #$pycheck_no=%(errtext)s ..") menu.AppendMenu(win32con.MF_SEPARATOR) menu.AppendMenu(flags, ID_TRYAGAIN, "&Try Again") menu.AppendMenu(flags, win32ui.ID_EDIT_CUT, 'Cu&t') menu.AppendMenu(flags, win32ui.ID_EDIT_COPY, '&Copy') menu.AppendMenu(flags, win32ui.ID_EDIT_PASTE, '&Paste') menu.AppendMenu(flags, win32con.MF_SEPARATOR); menu.AppendMenu(flags, win32ui.ID_EDIT_SELECT_ALL, '&Select all') menu.AppendMenu(flags, win32con.MF_SEPARATOR); menu.AppendMenu(flags, ID_SAVERESULTS, 'Sa&ve results') menu.TrackPopupMenu(params[5]) return 0 def OnAddComment(self, cmd, code): addspecific= cmd==ID_ADDPYCHECKNO2 _=list(self.GetSel()) _.sort() start,end=_ line_start, line_end = self.LineFromChar(start), self.LineFromChar(end) first=1 for i in range(line_start,line_end+1): line = self.GetLine(i) m = regexGrep.match(line) if m: if first: first=0 cmnt=dialog.GetSimpleInput( "Add to %s lines" % (line_end-line_start+1), addspecific and " #$pycheck_no=%(errtext)s" or " #$pycheck_no" ) if not cmnt: return 0 ##import pywin.debugger;pywin.debugger.set_trace() fname = m.group(1) line = string.atoi(m.group(2)) view = scriptutils.JumpToDocument(fname,line) pos=view.LineIndex(line)-1 if view.GetTextRange(pos-1,pos) in ('\r','\n'): pos -= 1 view.SetSel(pos, pos) errtext=m.group(3) if start!=end and line_start==line_end: errtext=self.GetSelText() errtext=repr(re.escape(errtext).replace('\ ',' ')) view.ReplaceSel( addspecific and cmnt % locals() or cmnt ) return 0 def OnCmdOpenFile(self, cmd, code): doc = win32ui.GetApp().OpenDocumentFile(self.fnm) if doc: vw = doc.GetFirstView() #hope you have an editor that implements GotoLine()! try: vw.GotoLine(string.atoi(self.lnnum)) except: pass return 0 def OnCmdThe(self, cmd, code): curparamsstr = self.GetDocument().GetParams() params = string.split(curparamsstr,'\t') params[2] = self.sel greptemplate.setParams(string.join(params,'\t')) greptemplate.OpenDocumentFile() return 0 def OnTryAgain(self, cmd, code): greptemplate.setParams(self.GetDocument().GetParams()) greptemplate.OpenDocumentFile() return 0 def OnCmdSave(self, cmd, code): flags = win32con.OFN_OVERWRITEPROMPT dlg = win32ui.CreateFileDialog(0, None, None, flags, "Text Files (*.txt)|*.txt||", self) dlg.SetOFNTitle("Save Results As") if dlg.DoModal() == win32con.IDOK: pn = dlg.GetPathName() self._obj_.SaveFile(pn) return 0 def Append(self, strng): numlines = self.GetLineCount() endpos = self.LineIndex(numlines-1) + len(self.GetLine(numlines-1)) self.SetSel(endpos, endpos) self.ReplaceSel(strng) class TheDialog(dialog.Dialog): def __init__(self, dp, fp, gp, cs, r, v): style = win32con.DS_MODALFRAME | win32con.WS_POPUP | win32con.WS_VISIBLE | win32con.WS_CAPTION | win32con.WS_SYSMENU | win32con.DS_SETFONT CS = win32con.WS_CHILD | win32con.WS_VISIBLE tmp = [ ["Pychecker Run", (0, 0, 210, 90), style, None, (8, "MS Sans Serif")], ] tmp.append([STATIC, "Files:", -1, (7, 7, 50, 9), CS ]) tmp.append([EDIT, gp, 103, (52, 7, 144, 11), CS | win32con.WS_TABSTOP | win32con.ES_AUTOHSCROLL | win32con.WS_BORDER]) tmp.append([STATIC, "Directories:", -1, (7, 20, 50, 9), CS ]) tmp.append([EDIT, dp, 102, (52, 20, 128, 11), CS | win32con.WS_TABSTOP | win32con.ES_AUTOHSCROLL | win32con.WS_BORDER]) tmp.append([BUTTON, '...', 110, (182,20, 16, 11), CS | win32con.BS_PUSHBUTTON | win32con.WS_TABSTOP]) tmp.append([STATIC, "Options:", -1, (7, 33, 50, 9), CS ]) tmp.append([EDIT, fp, 101, (52, 33, 128, 11), CS | win32con.WS_TABSTOP | win32con.ES_AUTOHSCROLL | win32con.WS_BORDER ]) tmp.append([BUTTON, '...', 111, (182,33, 16, 11), CS | win32con.BS_PUSHBUTTON | win32con.WS_TABSTOP]) #tmp.append([BUTTON,'Case sensitive', 104, (7, 45, 72, 9), CS | win32con.BS_AUTOCHECKBOX | win32con.BS_LEFTTEXT| win32con.WS_TABSTOP]) #tmp.append([BUTTON,'Subdirectories', 105, (7, 56, 72, 9), CS | win32con.BS_AUTOCHECKBOX | win32con.BS_LEFTTEXT| win32con.WS_TABSTOP]) #tmp.append([BUTTON,'Verbose', 106, (7, 67, 72, 9), CS | win32con.BS_AUTOCHECKBOX | win32con.BS_LEFTTEXT| win32con.WS_TABSTOP]) tmp.append([BUTTON,'OK', win32con.IDOK, (166,53, 32, 12), CS | win32con.BS_DEFPUSHBUTTON| win32con.WS_TABSTOP]) tmp.append([BUTTON,'Cancel', win32con.IDCANCEL, (166,67, 32, 12), CS | win32con.BS_PUSHBUTTON| win32con.WS_TABSTOP]) dialog.Dialog.__init__(self, tmp) self.AddDDX(101,'greppattern') self.AddDDX(102,'dirpattern') self.AddDDX(103,'filpattern') #self.AddDDX(104,'casesensitive') #self.AddDDX(105,'recursive') #self.AddDDX(106,'verbose') self._obj_.data['greppattern'] = gp self._obj_.data['dirpattern'] = dp self._obj_.data['filpattern'] = fp #self._obj_.data['casesensitive'] = cs #self._obj_.data['recursive'] = r #self._obj_.data['verbose'] = v self.HookCommand(self.OnMoreDirectories, 110) self.HookCommand(self.OnMoreFiles, 111) def OnMoreDirectories(self, cmd, code): self.getMore('Pychecker\\Directories', 'dirpattern') def OnMoreFiles(self, cmd, code): self.getMore('Pychecker\\File Types', 'filpattern') def getMore(self, section, key): self.UpdateData(1) #get the items out of the ini file ini = win32ui.GetProfileFileName() secitems = win32api.GetProfileSection(section, ini) items = [] for secitem in secitems: items.append(string.split(secitem,'=')[1]) dlg = TheParamsDialog(items) if dlg.DoModal() == win32con.IDOK: itemstr = string.join(dlg.getItems(),';') self._obj_.data[key] = itemstr #update the ini file with dlg.getNew() i = 0 newitems = dlg.getNew() if newitems: items = items + newitems for item in items: win32api.WriteProfileVal(section, `i`, item, ini) i = i + 1 self.UpdateData(0) def OnOK(self): self.UpdateData(1) for id, name in [(101,'greppattern'), (102,'dirpattern'), (103,'filpattern')]: if not self[name]: self.GetDlgItem(id).SetFocus() win32api.MessageBeep() win32ui.SetStatusText("Please enter a value") return self._obj_.OnOK() class TheParamsDialog(dialog.Dialog): def __init__(self, items): self.items = items self.newitems = [] style = win32con.DS_MODALFRAME | win32con.WS_POPUP | win32con.WS_VISIBLE | win32con.WS_CAPTION | win32con.WS_SYSMENU | win32con.DS_SETFONT CS = win32con.WS_CHILD | win32con.WS_VISIBLE tmp = [ ["Pychecker Parameters", (0, 0, 205, 100), style, None, (8, "MS Sans Serif")], ] tmp.append([LISTBOX, '', 107, (7, 7, 150, 72), CS | win32con.LBS_MULTIPLESEL| win32con.LBS_STANDARD | win32con.LBS_HASSTRINGS | win32con.WS_TABSTOP | win32con.LBS_NOTIFY]) tmp.append([BUTTON,'OK', win32con.IDOK, (167, 7, 32, 12), CS | win32con.BS_DEFPUSHBUTTON| win32con.WS_TABSTOP]) tmp.append([BUTTON,'Cancel', win32con.IDCANCEL, (167,23, 32, 12), CS | win32con.BS_PUSHBUTTON| win32con.WS_TABSTOP]) tmp.append([STATIC,'New:', -1, (2, 83, 15, 12), CS]) tmp.append([EDIT, '', 108, (18, 83, 139, 12), CS | win32con.WS_TABSTOP | win32con.ES_AUTOHSCROLL | win32con.WS_BORDER]) tmp.append([BUTTON,'Add', 109, (167,83, 32, 12), CS | win32con.BS_PUSHBUTTON| win32con.WS_TABSTOP]) dialog.Dialog.__init__(self, tmp) self.HookCommand(self.OnAddItem, 109) self.HookCommand(self.OnListDoubleClick, 107) def OnInitDialog(self): lb = self.GetDlgItem(107) for item in self.items: lb.AddString(item) return self._obj_.OnInitDialog() def OnAddItem(self, cmd, code): eb = self.GetDlgItem(108) item = eb.GetLine(0) self.newitems.append(item) lb = self.GetDlgItem(107) i = lb.AddString(item) lb.SetSel(i, 1) return 1 def OnListDoubleClick(self, cmd, code): if code == win32con.LBN_DBLCLK: self.OnOK() return 1 def OnOK(self): lb = self.GetDlgItem(107) self.selections = lb.GetSelTextItems() self._obj_.OnOK() def getItems(self): return self.selections def getNew(self): return self.newitems try: win32ui.GetApp().RemoveDocTemplate(greptemplate) except NameError: pass greptemplate = TheTemplate() Index: sgrepmdi.py =================================================================== RCS file: /cvsroot/pywin32/pywin32/Pythonwin/pywin/framework/sgrepmdi.py,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** sgrepmdi.py 8 Jun 2004 23:25:59 -0000 1.4 --- sgrepmdi.py 24 May 2007 13:48:37 -0000 1.5 *************** *** 204,208 **** # setup some reasonable defaults. if not self.dirpattern: ! self.dirpattern = os.getcwd() if not self.filpattern: self.filpattern = "*.py" --- 204,212 ---- # setup some reasonable defaults. if not self.dirpattern: ! try: ! editor=win32ui.GetMainFrame().MDIGetActive()[0].GetEditorView() ! self.dirpattern=os.path.abspath(os.path.dirname(editor.GetDocument().GetPathName())) ! except (AttributeError, win32ui.error): ! self.dirpattern = os.getcwd() if not self.filpattern: self.filpattern = "*.py" |
From: Mark H. <mha...@us...> - 2007-05-24 13:01:50
|
Update of /cvsroot/pywin32/pywin32/com/win32com/client In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16261 Modified Files: genpy.py Log Message: ack - last checkin should have bumped the makepy version number. Index: genpy.py =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/win32com/client/genpy.py,v retrieving revision 1.52 retrieving revision 1.53 diff -C2 -d -r1.52 -r1.53 *** genpy.py 24 May 2007 13:00:03 -0000 1.52 --- genpy.py 24 May 2007 13:01:48 -0000 1.53 *************** *** 24,28 **** error = "makepy.error" ! makepy_version = "0.4.95" # Written to generated file. GEN_FULL="full" --- 24,28 ---- error = "makepy.error" ! makepy_version = "0.4.96" # Written to generated file. GEN_FULL="full" |