pywin32-checkins Mailing List for Python for Windows Extensions (Page 38)
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: Mark H. <mha...@us...> - 2008-12-11 03:37:52
|
Update of /cvsroot/pywin32/pywin32 In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv23273 Modified Files: Tag: py3k setup.py Log Message: Handle errors building propsys, where we create a propsys.lib but also look for an MS supplied propsys.lib. Index: setup.py =================================================================== RCS file: /cvsroot/pywin32/pywin32/setup.py,v retrieving revision 1.81.2.8 retrieving revision 1.81.2.9 diff -C2 -d -r1.81.2.8 -r1.81.2.9 *** setup.py 6 Dec 2008 01:48:26 -0000 1.81.2.8 --- setup.py 11 Dec 2008 03:37:46 -0000 1.81.2.9 *************** *** 256,259 **** --- 256,260 ---- platforms=None, # none means 'all platforms' unicode_mode=None, # 'none'==default or specifically true/false. + implib_name=None, ): assert dsp_file or sources, "Either dsp_file or sources must be specified" *************** *** 282,285 **** --- 283,287 ---- self.base_address = base_address self.platforms = platforms + self.implib_name = implib_name Extension.__init__ (self, name, sources, include_dirs, *************** *** 389,392 **** --- 391,398 ---- self.extra_compile_args.append("/EHsc") + # If someone needs a specially named implib created, handle that + if self.implib_name: + implib = os.path.join(build_ext.build_temp, self.implib_name) + self.extra_link_args.append("/IMPLIB:%s" % implib) # Try and find the MFC source code, so we can reach inside for # some of the ActiveX support we need. We need to do this late, so *************** *** 1066,1069 **** --- 1072,1077 ---- build_ext.build_extension(self, ext) # XXX This has to be changed for mingw32 + # Get the .lib files we need. This is limited to pywintypes, + # pythoncom and win32ui - but the first 2 have special names extra = self.debug and "_d.lib" or ".lib" if ext.name in ("pywintypes", "pythoncom"): *************** *** 1072,1094 **** name1 = "%s%d%d%s" % (ext.name, sys.version_info[0], sys.version_info[1], extra) name2 = "%s%s" % (ext.name, extra) ! else: name1 = name2 = ext.name + extra - # The compiler always creates 'pywintypes22.lib', whereas we - # actually want 'pywintypes.lib' - copy it over. - # Worse: 2.3+ MSVCCompiler constructs the .lib file in the same - # directory as the first source file's object file: - # os.path.dirname(objects[0]) - # rather than in the self.build_temp directory - if sys.version_info > (2,3): - # 2.3+ - Wrong dir, numbered name - src = os.path.join(old_build_temp, - os.path.dirname(ext.sources[0]), - name1) else: ! # 2.2 it is in the right dir, just with the 'numbered' named. ! src = os.path.join(self.build_temp, name1) ! dst = os.path.join(old_build_temp, name2) ! if os.path.abspath(src) != os.path.abspath(dst): ! self.copy_file(src, dst)#, update=1) finally: self.build_temp = old_build_temp --- 1080,1105 ---- name1 = "%s%d%d%s" % (ext.name, sys.version_info[0], sys.version_info[1], extra) name2 = "%s%s" % (ext.name, extra) ! elif ext.name in ("win32ui",): name1 = name2 = ext.name + extra else: ! name1 = name2 = None ! if name1 is not None: ! # The compiler always creates 'pywintypes22.lib', whereas we ! # actually want 'pywintypes.lib' - copy it over. ! # Worse: 2.3+ MSVCCompiler constructs the .lib file in the same ! # directory as the first source file's object file: ! # os.path.dirname(objects[0]) ! # rather than in the self.build_temp directory ! if sys.version_info > (2,3): ! # 2.3+ - Wrong dir, numbered name ! src = os.path.join(old_build_temp, ! os.path.dirname(ext.sources[0]), ! name1) ! else: ! # 2.2 it is in the right dir, just with the 'numbered' named. ! src = os.path.join(self.build_temp, name1) ! dst = os.path.join(old_build_temp, name2) ! if os.path.abspath(src) != os.path.abspath(dst): ! self.copy_file(src, dst)#, update=1) finally: self.build_temp = old_build_temp *************** *** 1676,1680 **** sources=(""" %(propsys)s/propsys.cpp ! """ % dirs).split()), --- 1687,1693 ---- sources=(""" %(propsys)s/propsys.cpp ! """ % dirs).split(), ! implib_name="pypropsys.lib", ! ), |
From: Mark H. <mha...@us...> - 2008-12-11 00:46:37
|
Update of /cvsroot/pywin32/pywin32/win32/src In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv14098 Modified Files: PyLARGE_INTEGER.cpp Log Message: Correct large-int handling from last checking: * Allow ints and longs in py2x * reinstate support for 2 ints, but raise a PendingDeprecationWarning Index: PyLARGE_INTEGER.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/src/PyLARGE_INTEGER.cpp,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** PyLARGE_INTEGER.cpp 11 Dec 2008 00:25:40 -0000 1.13 --- PyLARGE_INTEGER.cpp 11 Dec 2008 00:46:31 -0000 1.14 *************** *** 22,33 **** BOOL PyWinObject_AsLARGE_INTEGER(PyObject *ob, LARGE_INTEGER *pResult) { ! pResult->QuadPart=PyLong_AsLongLong(ob); ! return !(pResult->QuadPart == -1 && PyErr_Occurred()); } BOOL PyWinObject_AsULARGE_INTEGER(PyObject *ob, ULARGE_INTEGER *pResult) { ! pResult->QuadPart=PyLong_AsUnsignedLongLong(ob); ! return !(pResult->QuadPart == (ULONGLONG) -1 && PyErr_Occurred()); } --- 22,74 ---- BOOL PyWinObject_AsLARGE_INTEGER(PyObject *ob, LARGE_INTEGER *pResult) { ! if (PyInt_Check(ob)) { ! // 32 bit integer value. ! int x = PyInt_AS_LONG(ob); ! if (x==(int)-1 && PyErr_Occurred()) ! return FALSE; ! LISet32(*pResult, x); ! return TRUE; ! } else if (PyLong_Check(ob)) { ! pResult->QuadPart=PyLong_AsLongLong(ob); ! return !(pResult->QuadPart == -1 && PyErr_Occurred()); ! } else { ! PyErr_Warn(PyExc_PendingDeprecationWarning, "Support for passing 2 integers to create a 64bit value is deprecated - pass a long instead"); ! long hiVal, loVal; ! if (!PyArg_ParseTuple(ob, "ll", &hiVal, &loVal)) { ! PyErr_SetString(PyExc_TypeError, "LARGE_INTEGER must be 'int', or '(int, int)'"); ! return FALSE; ! } ! // ### what to do about a "negative" loVal?! ! pResult->QuadPart = (((__int64)hiVal) << 32) | loVal; ! return TRUE; ! } ! assert(0); // not reached. } BOOL PyWinObject_AsULARGE_INTEGER(PyObject *ob, ULARGE_INTEGER *pResult) { ! if (PyInt_Check(ob)) { ! // 32 bit integer value. ! int x = PyInt_AS_LONG(ob); ! if (x==(int)-1 && PyErr_Occurred()) ! return FALSE; ! // ### what to do with "negative" integers? Nothing - they ! // get treated as unsigned! ! ULISet32(*pResult, x); ! return TRUE; ! } else if (PyLong_Check(ob)) { ! pResult->QuadPart=PyLong_AsUnsignedLongLong(ob); ! return !(pResult->QuadPart == (ULONGLONG) -1 && PyErr_Occurred()); ! } else { ! PyErr_Warn(PyExc_PendingDeprecationWarning, "Support for passing 2 integers to create a 64bit value is deprecated - pass a long instead"); ! long hiVal, loVal; ! if (!PyArg_ParseTuple(ob, "ll", &hiVal, &loVal)) { ! PyErr_SetString(PyExc_TypeError, "ULARGE_INTEGER must be 'int', or '(int, int)'"); ! return FALSE; ! } ! pResult->QuadPart = (((__int64)hiVal) << 32) | loVal; ! return TRUE; ! } ! assert(0); // not reached. } |
Update of /cvsroot/pywin32/pywin32/win32/src In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv11688/src Modified Files: PyACL.cpp PyHANDLE.cpp PyIID.cpp PyLARGE_INTEGER.cpp PyOVERLAPPED.cpp PySECURITY_ATTRIBUTES.cpp PySECURITY_DESCRIPTOR.cpp PySID.cpp PySecurityObjects.h PyTime.cpp PyWinObjects.h PyWinTypes.h mmapfilemodule.cpp win2krasmodule.cpp win32api_display.h win32apimodule.cpp win32evtlog.i win32file.i win32file_comm.cpp win32gui.i win32helpmodule.cpp win32process.i win32rasmodule.cpp win32security.i win32service.i Added Files: win32file_comm.h Log Message: Merge many tp_getattro/setattro, "2 ints" and buffer changes from Roger via the py3k branch. Index: win32process.i =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/src/win32process.i,v retrieving revision 1.36 retrieving revision 1.37 diff -C2 -d -r1.36 -r1.37 *** win32process.i 3 Dec 2008 22:34:21 -0000 1.36 --- win32process.i 11 Dec 2008 00:25:40 -0000 1.37 *************** *** 85,93 **** static void deallocFunc(PyObject *ob); ! static PyObject *getattr(PyObject *self, char *name); ! static int setattr(PyObject *self, char *name, PyObject *v); ! #pragma warning( disable : 4251 ) ! static struct memberlist memberlist[]; ! #pragma warning( default : 4251 ) protected: --- 85,91 ---- static void deallocFunc(PyObject *ob); ! static PyObject *getattro(PyObject *self, PyObject *obname); ! static int setattro(PyObject *self, PyObject *obname, PyObject *v); ! static struct PyMemberDef members[]; protected: *************** *** 109,114 **** PySTARTUPINFO::deallocFunc, /* tp_dealloc */ 0, /* tp_print */ ! PySTARTUPINFO::getattr, /* tp_getattr */ ! PySTARTUPINFO::setattr, /* tp_setattr */ 0, /* tp_compare */ 0, /* tp_repr */ --- 107,112 ---- PySTARTUPINFO::deallocFunc, /* tp_dealloc */ 0, /* tp_print */ ! 0, /* tp_getattr */ ! 0, /* tp_setattr */ 0, /* tp_compare */ 0, /* tp_repr */ *************** *** 119,127 **** 0, /* tp_call */ 0, /* tp_str */ }; #define OFF(e) offsetof(PySTARTUPINFO, e) ! /*static*/ struct memberlist PySTARTUPINFO::memberlist[] = { {"dwX", T_INT, OFF(m_startupinfo.dwX)}, // @prop integer|dwX|Specifies the x offset, in pixels, of the upper left corner of a window if a new window is created. The offset is from the upper left corner of the screen. {"dwY", T_INT, OFF(m_startupinfo.dwY)}, // @prop integer|dwY|Specifies the y offset, in pixels, of the upper left corner of a window if a new window is created. The offset is from the upper left corner of the screen. --- 117,147 ---- 0, /* tp_call */ 0, /* tp_str */ + PySTARTUPINFO::getattro, /* tp_getattr */ + PySTARTUPINFO::setattro, /* tp_setattr */ + 0, /*tp_as_buffer*/ + Py_TPFLAGS_DEFAULT, /* tp_flags */ + "A Python object, representing a STARTUPINFO structure", /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + 0, /* tp_methods */ + PySTARTUPINFO::members, /* tp_members */ + 0, /* tp_getset */ + 0, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + 0, /* tp_init */ + 0, /* tp_alloc */ + 0, /* tp_new */ }; #define OFF(e) offsetof(PySTARTUPINFO, e) ! /*static*/ struct PyMemberDef PySTARTUPINFO::members[] = { {"dwX", T_INT, OFF(m_startupinfo.dwX)}, // @prop integer|dwX|Specifies the x offset, in pixels, of the upper left corner of a window if a new window is created. The offset is from the upper left corner of the screen. {"dwY", T_INT, OFF(m_startupinfo.dwY)}, // @prop integer|dwY|Specifies the y offset, in pixels, of the upper left corner of a window if a new window is created. The offset is from the upper left corner of the screen. *************** *** 177,183 **** } ! PyObject *PySTARTUPINFO::getattr(PyObject *self, char *name) { PySTARTUPINFO *pO = (PySTARTUPINFO *)self; // @prop integer/<o PyHANDLE>|hStdInput| // @prop integer/<o PyHANDLE>|hStdOutput| --- 197,206 ---- } ! PyObject *PySTARTUPINFO::getattro(PyObject *self, PyObject *obname) { PySTARTUPINFO *pO = (PySTARTUPINFO *)self; + char *name=PYWIN_ATTR_CONVERT(obname); + if (name == NULL) + return NULL; // @prop integer/<o PyHANDLE>|hStdInput| // @prop integer/<o PyHANDLE>|hStdOutput| *************** *** 195,199 **** if (strcmp("lpTitle", name)==0) return PyWinObject_FromTCHAR(pO->m_startupinfo.lpTitle); ! return PyMember_Get((char *)self, memberlist, name); } --- 218,222 ---- if (strcmp("lpTitle", name)==0) return PyWinObject_FromTCHAR(pO->m_startupinfo.lpTitle); ! return PyObject_GenericGetAttr(self, obname); } *************** *** 214,218 **** } ! int PySTARTUPINFO::setattr(PyObject *self, char *name, PyObject *v) { if (v == NULL) { --- 237,241 ---- } ! int PySTARTUPINFO::setattro(PyObject *self, PyObject *obname, PyObject *v) { if (v == NULL) { *************** *** 221,224 **** --- 244,250 ---- } PySTARTUPINFO *pO = (PySTARTUPINFO *)self; + char *name=PYWIN_ATTR_CONVERT(obname); + if (name == NULL) + return -1; if (strcmp("hStdInput", name)==0) return sethandle( &pO->m_obStdIn, &pO->m_startupinfo.hStdInput, v); *************** *** 247,251 **** return 0; } ! return PyMember_Set((char *)self, memberlist, name, v); } --- 273,277 ---- return 0; } ! return PyObject_GenericSetAttr(self, obname, v); } *************** *** 1526,1529 **** --- 1552,1561 ---- %init %{ + + #if (PY_VERSION_HEX >= 0x03000000) + if (PyType_Ready(&PySTARTUPINFOType) == -1) + return NULL; + #endif + FARPROC fp=NULL; HMODULE hmodule=NULL; *************** *** 1532,1540 **** hmodule=LoadLibrary(_T("Psapi.dll")); if (hmodule!=NULL){ ! pfnEnumProcesses = (EnumProcessesfunc)GetProcAddress(hmodule, _T("EnumProcesses")); ! pfnEnumProcessModules = (EnumProcessModulesfunc)GetProcAddress(hmodule, _T("EnumProcessModules")); ! pfnGetModuleFileNameEx = (GetModuleFileNameExfunc)GetProcAddress(hmodule, _T("GetModuleFileNameExW")); #ifndef MS_WINCE ! pfnGetProcessMemoryInfo = (GetProcessMemoryInfofunc)GetProcAddress(hmodule, _T("GetProcessMemoryInfo")); #endif } --- 1564,1572 ---- hmodule=LoadLibrary(_T("Psapi.dll")); if (hmodule!=NULL){ ! pfnEnumProcesses = (EnumProcessesfunc)GetProcAddress(hmodule, "EnumProcesses"); ! pfnEnumProcessModules = (EnumProcessModulesfunc)GetProcAddress(hmodule, "EnumProcessModules"); ! pfnGetModuleFileNameEx = (GetModuleFileNameExfunc)GetProcAddress(hmodule, "GetModuleFileNameExW"); #ifndef MS_WINCE ! pfnGetProcessMemoryInfo = (GetProcessMemoryInfofunc)GetProcAddress(hmodule, "GetProcessMemoryInfo"); #endif } Index: PyWinObjects.h =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/src/PyWinObjects.h,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** PyWinObjects.h 13 Nov 2008 11:11:58 -0000 1.15 --- PyWinObjects.h 11 Dec 2008 00:25:40 -0000 1.16 *************** *** 19,22 **** --- 19,23 ---- /* Python support */ int compare(PyObject *ob); + PyObject *richcompare(PyObject *other, int op); long hash(void); PyObject *str(void); *************** *** 26,29 **** --- 27,31 ---- static int printFunc(PyObject *ob, FILE *fp, int flags); static int compareFunc(PyObject *ob1, PyObject *ob2); + static PyObject *richcompareFunc(PyObject *self, PyObject *other, int op); static long hashFunc(PyObject *ob); static PyObject * strFunc(PyObject *ob); *************** *** 53,58 **** PyObject *repr(); int compare(PyObject *ob); int print(FILE *fp, int flags); - PyObject *getattr(char *name); long hash(void); //PyObject *str(void); --- 55,61 ---- PyObject *repr(); int compare(PyObject *ob); + PyObject *PyTime::richcompare(PyObject *other, int op); + int print(FILE *fp, int flags); long hash(void); //PyObject *str(void); *************** *** 64,69 **** static void deallocFunc(PyObject *ob); static int printFunc(PyObject *ob, FILE *fp, int flags); ! static PyObject *getattrFunc(PyObject *ob, char *attr); static int compareFunc(PyObject *ob1, PyObject *ob2); static long hashFunc(PyObject *ob); //static PyObject * strFunc(PyObject *ob); --- 67,73 ---- static void deallocFunc(PyObject *ob); static int printFunc(PyObject *ob, FILE *fp, int flags); ! static PyObject *getattro(PyObject *self, PyObject *obname); static int compareFunc(PyObject *ob1, PyObject *ob2); + static PyObject *richcompareFunc(PyObject *self, PyObject *other, int op); static long hashFunc(PyObject *ob); //static PyObject * strFunc(PyObject *ob); *************** *** 73,76 **** --- 77,81 ---- static PyObject * strFunc(PyObject *ob); static PyObject * reprFunc(PyObject *ob); + static struct PyMethodDef methods[]; // Methods static PyObject *Format(PyObject *self, PyObject *args); *************** *** 105,120 **** static int compareFunc(PyObject *ob1, PyObject *ob2); ! static PyObject *getattr(PyObject *self, char *name); ! static int setattr(PyObject *self, char *name, PyObject *v); static long hashFunc(PyObject *self); ! #ifdef _MSC_VER ! #pragma warning( disable : 4251 ) ! #endif // _MSC_VER ! static struct memberlist memberlist[]; ! #ifdef _MSC_VER ! #pragma warning( default : 4251 ) ! #endif // _MSC_VER sMyOverlapped m_overlapped; ! PyObject *m_obHandle; }; --- 110,128 ---- static int compareFunc(PyObject *ob1, PyObject *ob2); ! static PyObject *getattro(PyObject *self, PyObject *obname); ! static int setattro(PyObject *self, PyObject *obname, PyObject *v); static long hashFunc(PyObject *self); ! static struct PYWINTYPES_EXPORT PyMemberDef members[]; ! ! static PyObject *get_hEvent(PyObject *self, void *unused); ! static int set_hEvent(PyObject *self, PyObject *v, void *unused); ! static PyObject *get_Internal(PyObject *self, void *unused); ! static int set_Internal(PyObject *self, PyObject *v, void *unused); ! static PyObject *get_InternalHigh(PyObject *self, void *unused); ! static int set_InternalHigh(PyObject *self, PyObject *v, void *unused); ! static PyGetSetDef getset[]; ! sMyOverlapped m_overlapped; ! PyObject *m_obhEvent; }; *************** *** 149,164 **** static PyObject * ternaryFailureFunc(PyObject *ob1, PyObject *ob2, PyObject *ob3); static PyObject *Close(PyObject *self, PyObject *args); static PyObject *Detach(PyObject *self, PyObject *args); ! ! static PyObject *getattr(PyObject *self, char *name); ! static int setattr(PyObject *self, char *name, PyObject *v); ! #ifdef _MSC_VER ! #pragma warning( disable : 4251 ) ! #endif // _MSC_VER ! static struct memberlist memberlist[]; ! #ifdef _MSC_VER ! #pragma warning( default : 4251 ) ! #endif // _MSC_VER protected: --- 157,166 ---- static PyObject * ternaryFailureFunc(PyObject *ob1, PyObject *ob2, PyObject *ob3); + static PyObject *get_handle(PyObject *self, void *unused); + static PyGetSetDef getset[]; + static PyObject *Close(PyObject *self, PyObject *args); static PyObject *Detach(PyObject *self, PyObject *args); ! static struct PyMethodDef methods[]; protected: --- NEW FILE: win32file_comm.h --- // The communications related functions. // The COMM port enhancements were added by Mark Hammond, and are // (c) 2000-2001, ActiveState Tools Corp. // The comms port helpers. extern PyObject *PyWinObject_FromCOMSTAT(const COMSTAT *pCOMSTAT); extern BOOL PyWinObject_AsCOMSTAT(PyObject *ob, COMSTAT **ppCOMSTAT, BOOL bNoneOK = TRUE); extern BOOL PyWinObject_AsDCB(PyObject *ob, DCB **ppDCB, BOOL bNoneOK = TRUE); extern PyObject *PyWinObject_FromDCB(const DCB *pDCB); extern PyObject *PyWinMethod_NewDCB(PyObject *self, PyObject *args); extern PyObject *PyWinObject_FromCOMMTIMEOUTS( COMMTIMEOUTS *p); extern BOOL PyWinObject_AsCOMMTIMEOUTS( PyObject *ob, COMMTIMEOUTS *p); class PyDCB : public PyObject { public: DCB *GetDCB() {return &m_DCB;} PyDCB(void); PyDCB(const DCB &); ~PyDCB(); /* Python support */ int compare(PyObject *ob); static void deallocFunc(PyObject *ob); static int compareFunc(PyObject *ob1, PyObject *ob2); static PyObject *getattro(PyObject *self, PyObject *obname); static int setattro(PyObject *self, PyObject *obname, PyObject *v); static struct PyMemberDef members[]; static PyTypeObject type; protected: DCB m_DCB; }; #define PyDCB_Check(x) ((x)->ob_type==&PyDCB::type) //////////////////////////////////////////////////////////////// // // COMSTAT object. // //////////////////////////////////////////////////////////////// class PyCOMSTAT : public PyObject { public: COMSTAT *GetCOMSTAT() {return &m_COMSTAT;} PyCOMSTAT(void); PyCOMSTAT(const COMSTAT &); ~PyCOMSTAT(); /* Python support */ int compare(PyObject *ob); static void deallocFunc(PyObject *ob); static int compareFunc(PyObject *ob1, PyObject *ob2); static PyObject *getattro(PyObject *self, PyObject *obname); static int setattro(PyObject *self, PyObject *obname, PyObject *v); static struct PyMemberDef members[]; static PyTypeObject type; protected: COMSTAT m_COMSTAT; }; #define PyCOMSTAT_Check(x) ((x)->ob_type==&PyCOMSTAT::type) Index: PySECURITY_DESCRIPTOR.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/src/PySECURITY_DESCRIPTOR.cpp,v retrieving revision 1.21 retrieving revision 1.22 diff -C2 -d -r1.21 -r1.22 *** PySECURITY_DESCRIPTOR.cpp 3 Dec 2008 22:34:21 -0000 1.21 --- PySECURITY_DESCRIPTOR.cpp 11 Dec 2008 00:25:40 -0000 1.22 *************** *** 678,682 **** // @object PySECURITY_DESCRIPTOR|A Python object, representing a SECURITY_DESCRIPTOR structure ! static struct PyMethodDef PySECURITY_DESCRIPTOR_methods[] = { {"Initialize", PySECURITY_DESCRIPTOR::Initialize, 1}, // @pymeth Initialize|Initializes the object. {"GetSecurityDescriptorOwner", PySECURITY_DESCRIPTOR::GetSecurityDescriptorOwner, 1}, // @pymeth GetSecurityDescriptorOwner|Return the owner of the security descriptor. SID is returned. --- 678,682 ---- // @object PySECURITY_DESCRIPTOR|A Python object, representing a SECURITY_DESCRIPTOR structure ! struct PyMethodDef PySECURITY_DESCRIPTOR::methods[] = { {"Initialize", PySECURITY_DESCRIPTOR::Initialize, 1}, // @pymeth Initialize|Initializes the object. {"GetSecurityDescriptorOwner", PySECURITY_DESCRIPTOR::GetSecurityDescriptorOwner, 1}, // @pymeth GetSecurityDescriptorOwner|Return the owner of the security descriptor. SID is returned. *************** *** 697,700 **** --- 697,721 ---- }; + // Buffer interface in Python 3.0 has changed + #if (PY_VERSION_HEX < 0x03000000) + /*static*/ Py_ssize_t PySECURITY_DESCRIPTOR::getreadbuf(PyObject *self, Py_ssize_t index, void **ptr) + { + if ( index != 0 ) { + PyErr_SetString(PyExc_SystemError, + "accessing non-existent SID segment"); + return -1; + } + PySECURITY_DESCRIPTOR *pysd = (PySECURITY_DESCRIPTOR *)self; + *ptr = pysd->m_psd; + return GetSecurityDescriptorLength(pysd->m_psd); + } + + /*static*/ Py_ssize_t PySECURITY_DESCRIPTOR::getsegcount(PyObject *self, Py_ssize_t *lenp) + { + if ( lenp ) + *lenp = GetSecurityDescriptorLength(((PySECURITY_DESCRIPTOR *)self)->m_psd); + return 1; + } + static PyBufferProcs PySECURITY_DESCRIPTOR_as_buffer = { PySECURITY_DESCRIPTOR::getreadbuf, *************** *** 704,707 **** --- 725,742 ---- }; + #else // New buffer interface for Python 3.0 + /*static*/ int PySECURITY_DESCRIPTOR::getbufferinfo(PyObject *self, Py_buffer *view, int flags) + { + PySECURITY_DESCRIPTOR *pysd = (PySECURITY_DESCRIPTOR *)self; + return PyBuffer_FillInfo(view, self, pysd->m_psd, + GetSecurityDescriptorLength(pysd->m_psd), 1, flags); + } + + static PyBufferProcs PySECURITY_DESCRIPTOR_as_buffer = { + PySECURITY_DESCRIPTOR::getbufferinfo, + NULL // Don't need to release any memory from Py_buffer struct + }; + #endif // PY_VERSION_HEX < 0x03000000 + PYWINTYPES_EXPORT PyTypeObject PySECURITY_DESCRIPTORType = { *************** *** 712,717 **** PySECURITY_DESCRIPTOR::deallocFunc, /* tp_dealloc */ 0, /* tp_print */ ! PySECURITY_DESCRIPTOR::getattr, /* tp_getattr */ ! PySECURITY_DESCRIPTOR::setattr, /* tp_setattr */ 0, /* tp_compare */ 0, /* tp_repr */ --- 747,752 ---- PySECURITY_DESCRIPTOR::deallocFunc, /* tp_dealloc */ 0, /* tp_print */ ! 0, /* tp_getattr */ ! 0, /* tp_setattr */ 0, /* tp_compare */ 0, /* tp_repr */ *************** *** 722,736 **** 0, /* tp_call */ 0, /* tp_str */ ! 0, /*tp_getattro*/ ! 0, /*tp_setattro*/ // @comm Note the PySECURITY_DESCRIPTOR object supports the buffer interface. Thus buffer(sd) can be used to obtain the raw bytes. &PySECURITY_DESCRIPTOR_as_buffer, /*tp_as_buffer*/ }; - #define OFF(e) offsetof(PySECURITY_DESCRIPTOR, e) - - /*static*/ struct memberlist PySECURITY_DESCRIPTOR::memberlist[] = { - {NULL} /* Sentinel */ - }; PySECURITY_DESCRIPTOR::PySECURITY_DESCRIPTOR(Py_ssize_t cb /*= 0*/) --- 757,785 ---- 0, /* tp_call */ 0, /* tp_str */ ! PyObject_GenericGetAttr, /* tp_getattro */ ! PyObject_GenericSetAttr, /* tp_setattro */ // @comm Note the PySECURITY_DESCRIPTOR object supports the buffer interface. Thus buffer(sd) can be used to obtain the raw bytes. &PySECURITY_DESCRIPTOR_as_buffer, /*tp_as_buffer*/ + Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */ + 0, /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + PySECURITY_DESCRIPTOR::methods, /* tp_methods */ + 0, /* tp_members */ + 0, /* tp_getset */ + 0, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + 0, /* tp_init */ + 0, /* tp_alloc */ + 0, /* tp_new */ }; PySECURITY_DESCRIPTOR::PySECURITY_DESCRIPTOR(Py_ssize_t cb /*= 0*/) *************** *** 759,806 **** } - PyObject *PySECURITY_DESCRIPTOR::getattr(PyObject *self, char *name) - { - PyObject *res; - - res = Py_FindMethod(PySECURITY_DESCRIPTOR_methods, self, name); - if (res != NULL) - return res; - PyErr_Clear(); - return PyMember_Get((char *)self, memberlist, name); - } - - int PySECURITY_DESCRIPTOR::setattr(PyObject *self, char *name, PyObject *v) - { - if (v == NULL) { - PyErr_SetString(PyExc_AttributeError, "can't delete SECURITY_DESCRIPTOR attributes"); - return -1; - } - return PyMember_Set((char *)self, memberlist, name, v); - } - /*static*/ void PySECURITY_DESCRIPTOR::deallocFunc(PyObject *ob) { delete (PySECURITY_DESCRIPTOR *)ob; } - - /*static*/ Py_ssize_t PySECURITY_DESCRIPTOR::getreadbuf(PyObject *self, Py_ssize_t index, void **ptr) - { - if ( index != 0 ) { - PyErr_SetString(PyExc_SystemError, - "accessing non-existent SID segment"); - return -1; - } - PySECURITY_DESCRIPTOR *pysd = (PySECURITY_DESCRIPTOR *)self; - *ptr = pysd->m_psd; - return GetSecurityDescriptorLength(pysd->m_psd); - } - - /*static*/ Py_ssize_t PySECURITY_DESCRIPTOR::getsegcount(PyObject *self, Py_ssize_t *lenp) - { - if ( lenp ) - *lenp = GetSecurityDescriptorLength(((PySECURITY_DESCRIPTOR *)self)->m_psd); - return 1; - } - #else /* NO_PYWINTYPES_SECURITY */ --- 808,815 ---- Index: win32apimodule.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/src/win32apimodule.cpp,v retrieving revision 1.92 retrieving revision 1.93 diff -C2 -d -r1.92 -r1.93 *** win32apimodule.cpp 8 Dec 2008 13:16:37 -0000 1.92 --- win32apimodule.cpp 11 Dec 2008 00:25:40 -0000 1.93 *************** *** 3793,3797 **** DWORD nSubKeys, nValues; FILETIME ft; - PyObject *l; // @pyparm <o PyHKEY>/int|key||An already open key, or or any one of the following win32con --- 3793,3796 ---- *************** *** 3809,3816 **** )!=ERROR_SUCCESS) return ReturnAPIError("RegQueryInfoKey", rc); ! if (!(l=PyLong_FromTwoInts(ft.dwHighDateTime, ft.dwLowDateTime))) ! return NULL; ! PyObject *ret = Py_BuildValue("iiO",nSubKeys,nValues,l); ! Py_DECREF(l); return ret; } --- 3808,3816 ---- )!=ERROR_SUCCESS) return ReturnAPIError("RegQueryInfoKey", rc); ! ULARGE_INTEGER l; ! l.LowPart = ft.dwLowDateTime; ! l.HighPart = ft.dwHighDateTime; ! PyObject *ret = Py_BuildValue("iiN",nSubKeys,nValues, ! PyWinObject_FromULARGE_INTEGER(l)); return ret; } Index: win32api_display.h =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/src/win32api_display.h,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** win32api_display.h 4 Dec 2008 00:17:13 -0000 1.4 --- win32api_display.h 11 Dec 2008 00:25:40 -0000 1.5 *************** *** 45,49 **** static struct PyMemberDef members[]; static struct PyMethodDef methods[]; - static void deallocFunc(PyObject *ob); PyDISPLAY_DEVICE(PDISPLAY_DEVICE); --- 45,48 ---- Index: win32security.i =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/src/win32security.i,v retrieving revision 1.49 retrieving revision 1.50 diff -C2 -d -r1.49 -r1.50 *** win32security.i 7 Dec 2008 18:00:40 -0000 1.49 --- win32security.i 11 Dec 2008 00:25:40 -0000 1.50 *************** *** 830,834 **** pfnDsFreeNameResult=(DsFreeNameResultfunc)loadapifunc("DsFreeNameResultW", ntdsapi_dll); pfnDsGetDcName=(DsGetDcNamefunc)loadapifunc("DsGetDcNameW", netapi32_dll); ! // old names, these should not be used PyDict_SetItemString(d, "SecBufferType", (PyObject *)&PySecBufferType); --- 830,846 ---- pfnDsFreeNameResult=(DsFreeNameResultfunc)loadapifunc("DsFreeNameResultW", ntdsapi_dll); pfnDsGetDcName=(DsGetDcNamefunc)loadapifunc("DsGetDcNameW", netapi32_dll); ! ! // Py3k requires that *all* types have to be initialized ! #if (PY_VERSION_HEX >= 0x03000000) ! if (PyType_Ready(&PySecBufferType) == -1) ! return NULL; ! if (PyType_Ready(&PySecBufferDescType) == -1) ! return NULL; ! if (PyType_Ready(&PyCtxtHandleType) == -1) ! return NULL; ! if (PyType_Ready(&PyCredHandleType) == -1) ! return NULL; ! #endif ! // old names, these should not be used PyDict_SetItemString(d, "SecBufferType", (PyObject *)&PySecBufferType); Index: PySID.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/src/PySID.cpp,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** PySID.cpp 3 Dec 2008 22:34:21 -0000 1.14 --- PySID.cpp 11 Dec 2008 00:25:40 -0000 1.15 *************** *** 179,183 **** // @object PySID|A Python object, representing a SID structure ! static struct PyMethodDef PySID_methods[] = { {"Initialize", PySID::Initialize, 1}, // @pymeth Initialize|Initialize the SID. {"IsValid", PySID::IsValid, 1}, // @pymeth IsValid|Determines if the SID is valid. --- 179,183 ---- // @object PySID|A Python object, representing a SID structure ! struct PyMethodDef PySID::methods[] = { {"Initialize", PySID::Initialize, 1}, // @pymeth Initialize|Initialize the SID. {"IsValid", PySID::IsValid, 1}, // @pymeth IsValid|Determines if the SID is valid. *************** *** 190,193 **** --- 190,215 ---- }; + + + #if (PY_VERSION_HEX < 0x03000000) + /*static*/ Py_ssize_t PySID::getreadbuf(PyObject *self, Py_ssize_t index, void **ptr) + { + if ( index != 0 ) { + PyErr_SetString(PyExc_SystemError, + "accessing non-existent SID segment"); + return -1; + } + PySID *pysid = (PySID *)self; + *ptr = pysid->m_psid; + return GetLengthSid(pysid->m_psid); + } + + /*static*/ Py_ssize_t PySID::getsegcount(PyObject *self, Py_ssize_t *lenp) + { + if ( lenp ) + *lenp = GetLengthSid(((PySID *)self)->m_psid); + return 1; + } + static PyBufferProcs PySID_as_buffer = { PySID::getreadbuf, *************** *** 197,200 **** --- 219,236 ---- }; + #else // New buffer interface in Py3k + + /*static*/ int PySID::getbufferinfo(PyObject *self, Py_buffer *view, int flags) + { + PySID *pysid = (PySID *)self; + return PyBuffer_FillInfo(view, self, pysid->m_psid, GetLengthSid(pysid->m_psid), 1, flags); + } + + static PyBufferProcs PySID_as_buffer = { + PySID::getbufferinfo, + NULL, // Does not have any allocated mem in Py_buffer struct + }; + + #endif // PY_VERSION_HEX < 0x03000000 PYWINTYPES_EXPORT PyTypeObject PySIDType = *************** *** 206,210 **** PySID::deallocFunc, /* tp_dealloc */ 0, /* tp_print */ ! PySID::getattr, /* tp_getattr */ 0, /* tp_setattr */ // @pymeth __cmp__|Used when objects are compared. --- 242,246 ---- PySID::deallocFunc, /* tp_dealloc */ 0, /* tp_print */ ! 0, /* tp_getattr */ 0, /* tp_setattr */ // @pymeth __cmp__|Used when objects are compared. *************** *** 217,224 **** 0, /* tp_call */ PySID::strFunc, /* tp_str */ ! 0, /*tp_getattro*/ ! 0, /*tp_setattro*/ // @comm Note the PySID object supports the buffer interface. Thus buffer(sid) can be used to obtain the raw bytes. &PySID_as_buffer, /*tp_as_buffer*/ }; --- 253,279 ---- 0, /* tp_call */ PySID::strFunc, /* tp_str */ ! PyObject_GenericGetAttr, /*tp_getattro*/ ! 0, /*tp_setattro*/ // @comm Note the PySID object supports the buffer interface. Thus buffer(sid) can be used to obtain the raw bytes. &PySID_as_buffer, /*tp_as_buffer*/ + Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */ + 0, /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + PySID::methods, /* tp_methods */ + 0, /* tp_members */ + 0, /* tp_getset */ + 0, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + 0, /* tp_init */ + 0, /* tp_alloc */ + 0, /* tp_new */ }; *************** *** 251,265 **** } - PyObject *PySID::getattr(PyObject *self, char *name) - { - return Py_FindMethod(PySID_methods, self, name); - } - int PySID::compare(PyObject *ob) { ! PSID p1 = NULL, p2 = NULL; ! PyWinObject_AsSID(this, &p1); ! PyWinObject_AsSID(ob, &p2); ! return EqualSid(p1, p2)==FALSE; } --- 306,315 ---- } int PySID::compare(PyObject *ob) { ! PSID p2; ! if (!PyWinObject_AsSID(ob, &p2, FALSE)) ! return -2; ! return EqualSid(this->GetSID(), p2)==FALSE; } *************** *** 277,300 **** } - /*static*/ Py_ssize_t PySID::getreadbuf(PyObject *self, Py_ssize_t index, void **ptr) - { - if ( index != 0 ) { - PyErr_SetString(PyExc_SystemError, - "accessing non-existent SID segment"); - return -1; - } - PySID *pysid = (PySID *)self; - *ptr = pysid->m_psid; - return GetLengthSid(pysid->m_psid); - } - - /*static*/ Py_ssize_t PySID::getsegcount(PyObject *self, Py_ssize_t *lenp) - { - if ( lenp ) - *lenp = GetLengthSid(((PySID *)self)->m_psid); - return 1; - } - - // NOTE: This function taken from KB Q131320. BOOL GetTextualSid( --- 327,330 ---- Index: PyOVERLAPPED.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/src/PyOVERLAPPED.cpp,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** PyOVERLAPPED.cpp 3 Dec 2008 22:34:21 -0000 1.15 --- PyOVERLAPPED.cpp 11 Dec 2008 00:25:40 -0000 1.16 *************** *** 70,75 **** PyOVERLAPPED::deallocFunc, /* tp_dealloc */ 0, /* tp_print */ ! PyOVERLAPPED::getattr, /* tp_getattr */ ! PyOVERLAPPED::setattr, /* tp_setattr */ // @pymeth __cmp__|Used when OVERLAPPED objects are compared. PyOVERLAPPED::compareFunc, /* tp_compare */ --- 70,75 ---- PyOVERLAPPED::deallocFunc, /* tp_dealloc */ 0, /* tp_print */ ! 0, /* tp_getattr */ ! 0, /* tp_setattr */ // @pymeth __cmp__|Used when OVERLAPPED objects are compared. PyOVERLAPPED::compareFunc, /* tp_compare */ *************** *** 81,89 **** 0, /* tp_call */ 0, /* tp_str */ }; #define OFF(e) offsetof(PyOVERLAPPED, e) ! /*static*/ struct memberlist PyOVERLAPPED::memberlist[] = { {"Offset", T_ULONG, OFF(m_overlapped.Offset)}, // @prop integer|Offset|Specifies a file position at which to start the transfer. The file position is a byte offset from the start of the file. The calling process sets this member before calling the ReadFile or WriteFile function. This member is ignored when reading from or writing to named pipes and communications devices. {"OffsetHigh", T_ULONG, OFF(m_overlapped.OffsetHigh)}, // @prop integer|OffsetHigh|Specifies the high word of the byte offset at which to start the transfer. --- 81,111 ---- 0, /* tp_call */ 0, /* tp_str */ + PyOVERLAPPED::getattro, /* tp_getattro */ + PyOVERLAPPED::setattro, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT, /* tp_flags */ + 0, /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + 0, /* tp_methods */ + PyOVERLAPPED::members, /* tp_members and tp_getset are apparently mutually exclusive, but this isn't documented anywhere */ + 0, //PyOVERLAPPED::getset, /* tp_getset */ + 0, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + 0, /* tp_init */ + 0, /* tp_alloc */ + 0, /* tp_new */ }; #define OFF(e) offsetof(PyOVERLAPPED, e) ! /*static*/ struct PYWINTYPES_EXPORT PyMemberDef PyOVERLAPPED::members[] = { {"Offset", T_ULONG, OFF(m_overlapped.Offset)}, // @prop integer|Offset|Specifies a file position at which to start the transfer. The file position is a byte offset from the start of the file. The calling process sets this member before calling the ReadFile or WriteFile function. This member is ignored when reading from or writing to named pipes and communications devices. {"OffsetHigh", T_ULONG, OFF(m_overlapped.OffsetHigh)}, // @prop integer|OffsetHigh|Specifies the high word of the byte offset at which to start the transfer. *************** *** 91,95 **** {"dword", T_ULONG, OFF(m_overlapped.dwValue)}, // @prop int|dword|An integer buffer that may be used by overlapped functions (eg, <om win32file.WaitCommEvent>) ! // These are handled by PyOVERLAPPED::getattr, included here so they show up as attributes {"hEvent", T_OBJECT, OFF(obDummy)}, // @prop <o PyHANDLE>|hEvent|Identifies an event set to the signaled state when the transfer has been completed. The calling process sets this member before calling the <om win32file.ReadFile>, <om win32file.WriteFile>, <om win32pipe.ConnectNamedPipe>, or <om win32pipe.TransactNamedPipe> function. {"Internal", T_OBJECT, OFF(obDummy)}, // @prop integer|Internal|Reserved for operating system use. (pointer-sized value) --- 113,117 ---- {"dword", T_ULONG, OFF(m_overlapped.dwValue)}, // @prop int|dword|An integer buffer that may be used by overlapped functions (eg, <om win32file.WaitCommEvent>) ! // These are handled by PyOVERLAPPED::getattro, included here so they show up as attributes {"hEvent", T_OBJECT, OFF(obDummy)}, // @prop <o PyHANDLE>|hEvent|Identifies an event set to the signaled state when the transfer has been completed. The calling process sets this member before calling the <om win32file.ReadFile>, <om win32file.WriteFile>, <om win32pipe.ConnectNamedPipe>, or <om win32pipe.TransactNamedPipe> function. {"Internal", T_OBJECT, OFF(obDummy)}, // @prop integer|Internal|Reserved for operating system use. (pointer-sized value) *************** *** 103,108 **** _Py_NewReference(this); memset(&m_overlapped, 0, sizeof(m_overlapped)); - m_obHandle = NULL; obDummy = NULL; } --- 125,130 ---- _Py_NewReference(this); memset(&m_overlapped, 0, sizeof(m_overlapped)); obDummy = NULL; + m_obhEvent = NULL; } *************** *** 113,122 **** m_overlapped = *pO; Py_XINCREF(m_overlapped.obState); ! m_obHandle = NULL; } PyOVERLAPPED::~PyOVERLAPPED(void) { ! Py_XDECREF(m_obHandle); Py_XDECREF(m_overlapped.obState); // set our memory to zero, so our clunky check for an invalid --- 135,144 ---- m_overlapped = *pO; Py_XINCREF(m_overlapped.obState); ! m_obhEvent = NULL; } PyOVERLAPPED::~PyOVERLAPPED(void) { ! Py_XDECREF(m_obhEvent); Py_XDECREF(m_overlapped.obState); // set our memory to zero, so our clunky check for an invalid *************** *** 136,146 **** } ! PyObject *PyOVERLAPPED::getattr(PyObject *self, char *name) { if (strcmp("hEvent", name)==0) { PyOVERLAPPED *pO = (PyOVERLAPPED *)self; ! if (pO->m_obHandle) { ! Py_INCREF(pO->m_obHandle); ! return pO->m_obHandle; } return PyWinLong_FromHANDLE(pO->m_overlapped.hEvent); --- 158,171 ---- } ! PyObject *PyOVERLAPPED::getattro(PyObject *self, PyObject *obname) { + char *name=PYWIN_ATTR_CONVERT(obname); + if (name==NULL) + return NULL; if (strcmp("hEvent", name)==0) { PyOVERLAPPED *pO = (PyOVERLAPPED *)self; ! if (pO->m_obhEvent) { ! Py_INCREF(pO->m_obhEvent); ! return pO->m_obhEvent; } return PyWinLong_FromHANDLE(pO->m_overlapped.hEvent); *************** *** 154,161 **** return PyWinObject_FromULONG_PTR(pO->m_overlapped.InternalHigh); } ! return PyMember_Get((char *)self, memberlist, name); } ! int PyOVERLAPPED::setattr(PyObject *self, char *name, PyObject *v) { if (v == NULL) { --- 179,186 ---- return PyWinObject_FromULONG_PTR(pO->m_overlapped.InternalHigh); } ! return PyObject_GenericGetAttr(self, obname); } ! int PyOVERLAPPED::setattro(PyObject *self, PyObject *obname, PyObject *v) { if (v == NULL) { *************** *** 163,166 **** --- 188,194 ---- return -1; } + char *name=PYWIN_ATTR_CONVERT(obname); + if (name==NULL) + return NULL; if (strcmp("hEvent", name)==0) { PyOVERLAPPED *pO = (PyOVERLAPPED *)self; *************** *** 170,180 **** return -1; pO->m_overlapped.hEvent=htmp; ! Py_XDECREF(pO->m_obHandle); if (PyHANDLE_Check(v)) { ! pO->m_obHandle = v; Py_INCREF(v); } else ! pO->m_obHandle = NULL; return 0; } --- 198,208 ---- return -1; pO->m_overlapped.hEvent=htmp; ! Py_XDECREF(pO->m_obhEvent); if (PyHANDLE_Check(v)) { ! pO->m_obhEvent = v; Py_INCREF(v); } else ! pO->m_obhEvent = NULL; return 0; } *************** *** 195,199 **** return 0; } ! return PyMember_Set((char *)self, memberlist, name, v); } --- 223,227 ---- return 0; } ! return PyObject_GenericSetAttr(self, obname, v); } Index: PySECURITY_ATTRIBUTES.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/src/PySECURITY_ATTRIBUTES.cpp,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** PySECURITY_ATTRIBUTES.cpp 3 Dec 2008 22:34:21 -0000 1.8 --- PySECURITY_ATTRIBUTES.cpp 11 Dec 2008 00:25:40 -0000 1.9 *************** *** 59,63 **** // @object PySECURITY_ATTRIBUTES|A Python object, representing a SECURITY_ATTRIBUTES structure ! static struct PyMethodDef PySECURITY_ATTRIBUTES_methods[] = { {NULL} }; --- 59,63 ---- // @object PySECURITY_ATTRIBUTES|A Python object, representing a SECURITY_ATTRIBUTES structure ! struct PyMethodDef PySECURITY_ATTRIBUTES::methods[] = { {NULL} }; *************** *** 72,77 **** PySECURITY_ATTRIBUTES::deallocFunc, /* tp_dealloc */ 0, /* tp_print */ ! PySECURITY_ATTRIBUTES::getattr, /* tp_getattr */ ! PySECURITY_ATTRIBUTES::setattr, /* tp_setattr */ 0, /* tp_compare */ 0, /* tp_repr */ --- 72,77 ---- PySECURITY_ATTRIBUTES::deallocFunc, /* tp_dealloc */ 0, /* tp_print */ ! 0, /* tp_getattr */ ! 0, /* tp_setattr */ 0, /* tp_compare */ 0, /* tp_repr */ *************** *** 82,91 **** 0, /* tp_call */ 0, /* tp_str */ }; #define OFF(e) offsetof(PySECURITY_ATTRIBUTES, e) ! /*static*/ struct memberlist PySECURITY_ATTRIBUTES::memberlist[] = { ! {"bInheritHandle", T_INT, OFF(m_sa.bInheritHandle)}, // @prop integer|bInheritHandle|Specifies whether the returned handle is inherited when a new process is created. If this member is TRUE, the new process inherits the handle. {"SECURITY_DESCRIPTOR", T_OBJECT, OFF(m_obSD)}, // @prop <o PySECURITY_DESCRIPTOR>|SECURITY_DESCRIPTOR|A PySECURITY_DESCRIPTOR, or None {NULL} --- 82,113 ---- 0, /* tp_call */ 0, /* tp_str */ + PySECURITY_ATTRIBUTES::getattro, /* tp_getattro */ + PySECURITY_ATTRIBUTES::setattro, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT, /* tp_flags */ + "A Python object, representing a SECURITY_ATTRIBUTES structure", /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + PySECURITY_ATTRIBUTES::methods, /* tp_methods */ + PySECURITY_ATTRIBUTES::members, /* tp_members */ + 0, /* tp_getset */ + 0, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + 0, /* tp_init */ + 0, /* tp_alloc */ + 0, /* tp_new */ }; #define OFF(e) offsetof(PySECURITY_ATTRIBUTES, e) ! /*static*/ struct PYWINTYPES_EXPORT PyMemberDef PySECURITY_ATTRIBUTES::members[] = { ! {"bInheritHandle", T_INT, OFF(m_sa.bInheritHandle)}, // @prop boolean|bInheritHandle|Specifies whether the returned handle is inherited when a new process is created. If this member is TRUE, the new process inherits the handle. {"SECURITY_DESCRIPTOR", T_OBJECT, OFF(m_obSD)}, // @prop <o PySECURITY_DESCRIPTOR>|SECURITY_DESCRIPTOR|A PySECURITY_DESCRIPTOR, or None {NULL} *************** *** 142,167 **** } ! PyObject *PySECURITY_ATTRIBUTES::getattr(PyObject *self, char *name) { ! PyObject *res; ! ! res = Py_FindMethod(PySECURITY_ATTRIBUTES_methods, self, name); if (res != NULL) return res; - PyErr_Clear(); - res = PyMember_Get((char *)self, memberlist, name); - if (res != NULL) - return res; // let it inherit methods from PySECURITY_DESCRIPTOR for backward compatibility PySECURITY_ATTRIBUTES *This = (PySECURITY_ATTRIBUTES *)self; if (This->m_obSD!=Py_None){ PyErr_Clear(); ! res=((PySECURITY_DESCRIPTOR *)(This->m_obSD))->getattr(This->m_obSD, name); } return res; } ! int PySECURITY_ATTRIBUTES::setattr(PyObject *self, char *name, PyObject *v) { if (v == NULL) { --- 164,183 ---- } ! PyObject *PySECURITY_ATTRIBUTES::getattro(PyObject *self, PyObject *obname) { ! PyObject *res = PyObject_GenericGetAttr(self, obname); if (res != NULL) return res; // let it inherit methods from PySECURITY_DESCRIPTOR for backward compatibility PySECURITY_ATTRIBUTES *This = (PySECURITY_ATTRIBUTES *)self; if (This->m_obSD!=Py_None){ PyErr_Clear(); ! res=PyObject_GenericGetAttr(This->m_obSD, obname); } return res; } ! int PySECURITY_ATTRIBUTES::setattro(PyObject *self, PyObject *obname, PyObject *v) { if (v == NULL) { *************** *** 169,184 **** return -1; } if (strcmp(name, "SECURITY_DESCRIPTOR")==0){ PySECURITY_ATTRIBUTES *This=(PySECURITY_ATTRIBUTES *)self; ! if (v==Py_None) ! This->m_sa.lpSecurityDescriptor=NULL; ! else if (PySECURITY_DESCRIPTOR_Check(v)) ! This->m_sa.lpSecurityDescriptor=((PySECURITY_DESCRIPTOR *)This->m_obSD)->GetSD(); ! else{ ! PyErr_SetString(PyExc_TypeError, "SECURITY_DESCRIPTOR must be a PySECURITY_DESCRIPTOR, or None"); return -1; ! } } ! return PyMember_Set((char *)self, memberlist, name, v); } --- 185,203 ---- return -1; } + char *name=PYWIN_ATTR_CONVERT(obname); + if (name==NULL) + return -1; if (strcmp(name, "SECURITY_DESCRIPTOR")==0){ PySECURITY_ATTRIBUTES *This=(PySECURITY_ATTRIBUTES *)self; ! PSECURITY_DESCRIPTOR psd; ! if (!PyWinObject_AsSECURITY_DESCRIPTOR(v, &psd, TRUE)) return -1; ! Py_XDECREF(This->m_obSD); ! Py_INCREF(v); ! This->m_obSD = v; ! This->m_sa.lpSecurityDescriptor = psd; ! return 0; } ! return PyObject_GenericSetAttr(self, obname, v); } Index: PyWinTypes.h =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/src/PyWinTypes.h,v retrieving revision 1.57 retrieving revision 1.58 diff -C2 -d -r1.57 -r1.58 *** PyWinTypes.h 8 Dec 2008 13:16:37 -0000 1.57 --- PyWinTypes.h 11 Dec 2008 00:25:40 -0000 1.58 *************** *** 140,143 **** --- 140,150 ---- #endif // FREEZE_PYWINTYPES + #if (PY_VERSION_HEX >= 0x03000000) + // Py3k uses memoryview object in place of buffer + extern PYWINTYPES_EXPORT PyObject *PyBuffer_New(Py_ssize_t size); + extern PYWINTYPES_EXPORT PyObject *PyBuffer_FromReadWriteMemory(void *buf, Py_ssize_t size); + extern PYWINTYPES_EXPORT PyObject *PyBuffer_FromMemory(void *buf, Py_ssize_t size); + #endif + // Formats a python traceback into a character string - result must be free()ed PYWINTYPES_EXPORT char *GetPythonTraceback(PyObject *exc_type, PyObject *exc_value, PyObject *exc_tb); *************** *** 347,358 **** ** LARGE_INTEGER objects */ - // These need to be renamed. For now, the old names still appear in the DLL. - PYWINTYPES_EXPORT BOOL PyLong_AsTwoInts(PyObject *ob, int *hiint, unsigned *loint); - PYWINTYPES_EXPORT PyObject *PyLong_FromTwoInts(int hidword, unsigned lodword); - - // These seem (to MH anyway :) to be better names than using "int". - inline BOOL PyLong_AsTwoI32(PyObject *ob, int *hiint, unsigned *loint) {return PyLong_AsTwoInts(ob, hiint, loint);} - inline PyObject *PyLong_FromTwoI32(int hidword, unsigned lodword) {return PyLong_FromTwoInts(hidword, lodword);} - //AsLARGE_INTEGER takes either int or long PYWINTYPES_EXPORT BOOL PyWinObject_AsLARGE_INTEGER(PyObject *ob, LARGE_INTEGER *pResult); --- 354,357 ---- *************** *** 369,375 **** #define PyWinObject_FromUPY_LONG_LONG(val) PyWinObject_FromULARGE_INTEGER((ULARGE_INTEGER)val) - PyObject *PyLong_FromI64(__int64 ival); - BOOL PyLong_AsI64(PyObject *val, __int64 *lval); - // A DWORD_PTR and ULONG_PTR appear to mean "integer long enough to hold a pointer" // It is *not* actually a pointer (but is the same size as a pointer) --- 368,371 ---- Index: win32file.i =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/src/win32file.i,v retrieving revision 1.95 retrieving revision 1.96 diff -C2 -d -r1.95 -r1.96 *** win32file.i 6 Dec 2008 00:43:45 -0000 1.95 --- win32file.i 11 Dec 2008 00:25:40 -0000 1.96 *************** *** 38,41 **** --- 38,42 ---- #define NEED_PYWINOBJECTS_H + #include "win32file_comm.h" %} *************** *** 523,528 **** PyTypeObject FindFileIterator_Type = { ! PyObject_HEAD_INIT(&PyType_Type) ! 0, /* ob_size */ "FindFileIterator", /* tp_name */ sizeof(FindFileIterator), /* tp_basicsize */ --- 524,528 ---- PyTypeObject FindFileIterator_Type = { ! PYWIN_OBJECT_HEAD "FindFileIterator", /* tp_name */ sizeof(FindFileIterator), /* tp_basicsize */ *************** *** 649,654 **** WCHAR *fileName); // @pyparm <o PyUnicode>|fileName||Name of the file to retrieve attributes for. ! // @pyswig int|GetFileTime|Determine a file access/modification times. ! DWORD GetFileTime( HANDLE handle, // @pyparm <o PyHANDLE>|handle||Handle to the file. FILETIME *OUTPUT, // @pyparm <o PyTime>|creationTime|| --- 649,655 ---- WCHAR *fileName); // @pyparm <o PyUnicode>|fileName||Name of the file to retrieve attributes for. ! // @pyswig (<o PyTime>, <o PyTime>, <o PyTime>)|GetFileTime|Returns a file's creation, last access, and modification times. ! // @comm Times are returned in UTC time. ! BOOLAPI GetFileTime( HANDLE handle, // @pyparm <o PyHANDLE>|handle||Handle to the file. FILETIME *OUTPUT, // @pyparm <o PyTime>|creationTime|| *************** *** 765,780 **** if (!PyWinObject_AsTCHAR(obName, &fname, FALSE)) return NULL; ! DWORD dwSizeLow, dwSizeHigh; Py_BEGIN_ALLOW_THREADS ! dwSizeLow = GetCompressedFileSize(fname, &dwSizeHigh); Py_END_ALLOW_THREADS // If we failed ... ! if (dwSizeLow == 0xFFFFFFFF && GetLastError() != NO_ERROR ) return PyWin_SetAPIError("GetCompressedFileSize"); ! return PyLong_FromTwoInts(dwSizeHigh, dwSizeLow); } %} ! // @pyswig <o PyLARGE_INTEGER>|GetCompressedFileSize|Determines the compressed size of a file. %native(GetCompressedFileSize) MyGetCompressedFileSize; --- 766,783 ---- if (!PyWinObject_AsTCHAR(obName, &fname, FALSE)) return NULL; ! ULARGE_INTEGER ulsize; Py_BEGIN_ALLOW_THREADS ! ulsize.LowPart = GetCompressedFileSize(fname, &ulsize.HighPart); Py_END_ALLOW_THREADS + + PyWinObject_FreeTCHAR(fname); // If we failed ... ! if (ulsize.LowPart == 0xFFFFFFFF && GetLastError() != NO_ERROR ) return PyWin_SetAPIError("GetCompressedFileSize"); ! return PyWinObject_FromULARGE_INTEGER(ulsize); } %} ! // @pyswig long|GetCompressedFileSize|Determines the compressed size of a file. %native(GetCompressedFileSize) MyGetCompressedFileSize; *************** *** 789,805 **** if (!PyWinObject_AsHANDLE(obHandle, &hFile)) return NULL; ! DWORD dwSizeLow=0, dwSizeHigh=0; Py_BEGIN_ALLOW_THREADS ! dwSizeLow = GetFileSize (hFile, &dwSizeHigh); Py_END_ALLOW_THREADS // If we failed ... ! if (dwSizeLow == 0xFFFFFFFF && GetLastError() != NO_ERROR ) return PyWin_SetAPIError("GetFileSize"); ! return PyLong_FromTwoInts(dwSizeHigh, dwSizeLow); } %} ! // @pyswig <o PyLARGE_INTEGER>|GetFileSize|Determines the size of a file. %native(GetFileSize) MyGetFileSize; --- 792,808 ---- if (!PyWinObject_AsHANDLE(obHandle, &hFile)) return NULL; ! ULARGE_INTEGER ulsize; Py_BEGIN_ALLOW_THREADS ! ulsize.LowPart = GetFileSize (hFile, &ulsize.HighPart); Py_END_ALLOW_THREADS // If we failed ... ! if (ulsize.LowPart == 0xFFFFFFFF && GetLastError() != NO_ERROR ) return PyWin_SetAPIError("GetFileSize"); ! return PyWinObject_FromULARGE_INTEGER(ulsize); } %} ! // @pyswig long|GetFileSize|Determines the size of a file. %native(GetFileSize) MyGetFileSize; *************** *** 868,872 **** void *buf = NULL; - PyBufferProcs *pb = NULL; bufSize = PyInt_AsLong(obBuf); --- 871,874 ---- *************** *** 876,881 **** if (obRet==NULL) return NULL; ! pb = obRet->ob_type->tp_as_buffer; ! (*pb->bf_getreadbuffer)(obRet, 0, &buf); } else{ --- 878,886 ---- if (obRet==NULL) return NULL; ! // This should never fail ! if (!PyWinObject_AsWriteBuffer(obRet, &buf, &bufSize)){ ! Py_DECREF(obRet); ! return NULL; ! } } else{ *************** *** 1533,1548 **** if (!PyWinObject_AsHANDLE(obHandle, &handle)) return NULL; ! long offHigh; ! unsigned offLow; ! if (!PyLong_AsTwoInts(obOffset, (int *)&offHigh, &offLow)) return NULL; Py_BEGIN_ALLOW_THREADS ! offLow = SetFilePointer(handle, offLow, &offHigh, iMethod); Py_END_ALLOW_THREADS // If we failed ... ! if (offLow == 0xFFFFFFFF && GetLastError() != NO_ERROR ) return PyWin_SetAPIError("SetFilePointer"); ! return PyLong_FromTwoInts(offHigh, offLow); } %} --- 1538,1554 ---- if (!PyWinObject_AsHANDLE(obHandle, &handle)) return NULL; ! ! LARGE_INTEGER offset; ! if (!PyWinObject_AsLARGE_INTEGER(obOffset, &offset)) return NULL; + Py_BEGIN_ALLOW_THREADS ! offset.LowPart = SetFilePointer(handle, offset.LowPart, &offset.HighPart, iMethod); Py_END_ALLOW_THREADS // If we failed ... ! if (offset.LowPart == 0xFFFFFFFF && GetLastError() != NO_ERROR ) return PyWin_SetAPIError("SetFilePointer"); ! return PyWinObject_FromLARGE_INTEGER(offset); } %} *************** *** 1643,1651 **** PyObject *obOverlapped = NULL; DWORD dwBufSize = 0; - PyObject *rv = NULL; PyObject *obListening = NULL; PyObject *obAccepting = NULL; PyObject *obBuf = NULL; - PyObject *pORB = NULL; void *buf = NULL; DWORD cBytesRecvd = 0; --- 1649,1655 ---- *************** *** 1706,1731 **** } ! if (obBuf->ob_type->tp_as_buffer && obBuf->ob_type->tp_as_buffer->bf_getwritebuffer) ! { ! pORB = obBuf; ! Py_INCREF(pORB); ! pb = pORB->ob_type->tp_as_buffer; ! dwBufSize = (*pb->bf_getwritebuffer)(pORB, 0, &buf); ! if (dwBufSize==(DWORD)-1 && PyErr_Occurred()) ! goto Error; ! if (dwBufSize < (DWORD)iMinBufferSize ) { ! PyErr_Format( ! PyExc_ValueError, ! "Second param must be at least %ld bytes long", ! iMinBufferSize); ! goto Error; ! } ! } ! else ! { ! PyErr_SetString(PyExc_TypeError, "Second param must be a buffer object"); return NULL; ! } // Phew... finally, all the arguments are converted... --- 1710,1723 ---- } ! if (!PyWinObject_AsWriteBuffer(obBuf, &buf, &dwBufSize)) ! return NULL; ! if (dwBufSize < (DWORD)iMinBufferSize ) { ! PyErr_Format( ! PyExc_ValueError, ! "Second param must be at least %ld bytes long", ! iMinBufferSize); return NULL; ! } // Phew... finally, all the arguments are converted... *************** *** 1745,1761 **** rc = WSAGetLastError(); if (rc != ERROR_IO_PENDING) ! { ! PyWin_SetAPIError("AcceptEx", WSAGetLastError()); ! goto Error; ! } } ! Py_DECREF(pORB); ! rv = PyInt_FromLong(rc); ! Cleanup: ! return rv; ! Error: ! Py_DECREF(pORB); ! rv = NULL; ! goto Cleanup; } --- 1737,1743 ---- rc = WSAGetLastError(); if (rc != ERROR_IO_PENDING) ! return PyWin_SetAPIError("AcceptEx", WSAGetLastError()); } ! return PyInt_FromLong(rc); } *************** *** 1864,1889 **** } iMinBufferSize = (wsProtInfo.iMaxSockAddr + 16) * 2; ! if (obBuf->ob_type->tp_as_buffer && obBuf->ob_type->tp_as_buffer->bf_getreadbuffer) ! { ! pORB = obBuf; ! Py_INCREF(pORB); ! pb = pORB->ob_type->tp_as_buffer; ! dwBufSize = (*pb->bf_getreadbuffer)(pORB, 0, &buf); ! if (dwBufSize==(DWORD)-1 && PyErr_Occurred()) ! goto Error; ! if (dwBufSize < (DWORD)iMinBufferSize ) ! { ! PyErr_Format( ! PyExc_ValueError, ! "Second param must be at least %ld bytes long", ! iMinBufferSize); ! goto Error; ! } ! } ! else { ! PyErr_SetString(PyExc_TypeError, "Second param must be a buffer object"); ! return NULL; } --- 1846,1859 ---- } iMinBufferSize = (wsProtInfo.iMaxSockAddr + 16) * 2; + if (!PyWinObject_AsReadBuffer(obBuf, &buf, &dwBufSize)) + return NULL; ! if (dwBufSize < (DWORD)iMinBufferSize ) { ! PyErr_Format( ! PyExc_ValueError, ! "Second param must be at least %ld bytes long", ! iMinBufferSize); ! goto Error; } *************** *** 2059,2080 **** } ! if (PyString_Check(obBuf)) ! { ! wsBuf.buf = PyString_AS_STRING(obBuf); ! wsBuf.len = PyString_GET_SIZE(obBuf); ! } ! else if (obBuf->ob_type->tp_as_buffer && obBuf->ob_type->tp_as_buffer->bf_getreadbuffer) ! { ! Py_INCREF(obBuf); ! pb = obBuf->ob_type->tp_as_buffer; ! wsBuf.len = (*pb->bf_getreadbuffer)(obBuf, 0, (void **)&wsBuf.buf); ! if (wsBuf.len==(u_long)-1 && PyErr_Occurred()) ! return NULL; ! } ! else ! { ! PyErr_SetString(PyExc_TypeError, "Second param must be a buffer object or a string."); return NULL; - } Py_BEGIN_ALLOW_THREADS; --- 2029,2034 ---- } ! if (!PyWinObject_AsReadBuffer(obBuf, (void **)&wsBuf.buf, &wsBuf.len, FALSE)) return NULL; Py_BEGIN_ALLOW_THREADS; *************** *** 2171,2187 **** } ! if (obBuf->ob_type->tp_as_buffer && obBuf->ob_type->tp_as_buffer->bf_getwritebuffer) ! { ! Py_INCREF(obBuf); ! pb = obBuf->ob_type->tp_as_buffer; ! wsBuf.len = (*pb->bf_getwritebuffer)(obBuf, 0, (void **)&wsBuf.buf); ! if (wsBuf.len==(u_long)-1 && PyErr_Occurred()) ! return NULL; ! } ! else ! { ! PyErr_SetString(PyExc_TypeError, "Second param must be a PyOVERLAPPEDReadBuffer object"); return NULL; - } Py_BEGIN_ALLOW_THREADS; --- 2125,2130 ---- } ! if (!PyWinObject_AsWriteBuffer(obBuf, (void **)&wsBuf.buf, &wsBuf.len, FALSE)) return NULL; Py_BEGIN_ALLOW_THREADS; *************** *** 2241,2244 **** --- 2184,2188 ---- #define SO_UPDATE_ACCEPT_CONTEXT SO_UPDATE_ACCEPT_CONTEXT + #define SO_UPDATE_CONNECT_CONTEXT SO_UPDATE_CONNECT_CONTEXT #define SO_CONNECT_TIME SO_CONNECT_TIME *************** *** 2273,2292 **** #endif // MS_WINCE - // The communications related functions. - // The COMM port enhancements were added by Mark Hammond, and are - // (c) 2000-2001, ActiveState Tools Corp. - - %{ - // The comms port helpers. - extern PyObject *PyWinObject_FromCOMSTAT(const COMSTAT *pCOMSTAT); - extern BOOL PyWinObject_AsCOMSTAT(PyObject *ob, COMSTAT **ppCOMSTAT, BOOL bNoneOK = TRUE); - extern BOOL PyWinObject_AsDCB(PyObject *ob, DCB **ppDCB, BOOL bNoneOK = TRUE); - extern PyObject *PyWinObject_FromDCB(const DCB *pDCB); - extern PyObject *PyWinMethod_NewDCB(PyObject *self, PyObject *args); - extern PyObject *PyWinObject_FromCOMMTIMEOUTS( COMMTIMEOUTS *p); - extern BOOL PyWinObject_AsCOMMTIMEOUTS( PyObject *ob, COMMTIMEOUTS *p); - - %} - %native (DCB) PyWinMethod_NewDCB; --- 2217,2220 ---- *************** *** 2672,2675 **** --- 2600,2608 ---- static GetFullPathNameTransactedAfunc pfnGetFullPathNameTransactedA = NULL; + typedef BOOL (WINAPI *Wow64DisableWow64FsRedirectionfunc)(PVOID*); + static Wow64DisableWow64FsRedirectionfunc pfnWow64DisableWow64FsRedirection = NULL; + typedef BOOL (WINAPI *Wow64RevertWow64FsRedirectionfunc)(PVOID); + static Wow64RevertWow64FsRedirectionfunc pfnWow64RevertWow64FsRedirection = NULL; + /* FILE_INFO_BY_HANDLE_CLASS and various structs used by this function are in fileextd.h, can be downloaded here: http://www.microsoft.com/downloads/details.aspx?familyid=1decc547-ab00-4963-a360-e4130ec079b8&displaylang=en *************** *** 3526,3530 **** return NULL; if (obbuf==Py_None){ ! obbufout=PyBuffer_New(bytes_requested); // ??? any way to create a writable buffer from Python level ??? if (obbufout==NULL) return NULL; --- 3459,3463 ---- return NULL; if (obbuf==Py_None){ ! obbufout=PyBuffer_New(bytes_requested); if (obbufout==NULL) return NULL; *************** *** 4222,4225 **** --- 4155,4161 ---- case GetFileExInfoStandard: { WIN32_FILE_ATTRIBUTE_DATA *pa = (WIN32_FILE_ATTRIBUTE_DATA *)p; + ULARGE_INTEGER fsize; + fsize.LowPart=pa->nFileSizeLow; + fsize.HighPart=pa->nFileSizeHigh; return Py_BuildValue("iNNNN", pa->dwFileAttributes, *************** *** 4227,4231 **** PyWinObject_FromFILETIME(pa->ftLastAccessTime), PyWinObject_FromFILETIME(pa->ftLastWriteTime), ! PyLong_FromTwoInts(pa->nFileSizeHigh, pa->nFileSizeLow)); break; } --- 4163,4167 ---- PyWinObject_FromFILETIME(pa->ftLastAccessTime), PyWinObject_FromFILETIME(pa->ftLastWriteTime), ! PyWinObject_FromULARGE_INTEGER(fsize)); break; } *************** *** 5093,5098 **** %init %{ ! PyDict_SetItemString(d, "error", PyWinExc_ApiError); ! PyDict_SetItemString(d, "INVALID_HANDLE_VALUE", PyWinLong_FromHANDLE(INVALID_HANDLE_VALUE)); for (PyMethodDef *pmd = win32fileMethods;pmd->ml_name;pmd++) --- 5029,5042 ---- %init %{ ! ! if (PyType_Ready(&FindFileIterator_Type) == -1 ! ||PyType_Ready(&PyDCB::type) == -1 ! ||PyType_Ready(&PyCOMSTAT::type) == -1) ! PYWIN_MODULE_INIT_RETURN_ERROR; ! ! if (PyDict_SetItemString(d, "error", PyWinExc_ApiError) == -1) ! PYWIN_MODULE_INIT_RETURN_ERROR; ! if (PyDict_SetItemString(d, "INVALID_HANDLE_VALUE", PyWinLong_FromHANDLE(INVALID_HANDLE_VALUE)) == -1) ! PYWIN_MODULE_INIT_RETURN_ERROR; for (PyMethodDef *pmd = win32fileMethods;pmd->ml_name;pmd++) *************** *** 5191,5194 **** --- 5135,5140 ---- pfnGetFullPathNameTransactedA=(GetFullPathNameTransactedAfunc)GetProcAddress(hmodule, "GetFullPathNameTransactedA"); // pfnGetFileInformationByHandleEx=(GetFileInformationByHandleExfunc)GetProcAddress(hmodule, "GetFileInformationByHandleEx"); + pfnWow64DisableWow64FsRedirection=(Wow64DisableWow64FsRedirectionfunc)GetProcAddress(hmodule, "Wow64DisableWow64FsRedirection"); + pfnWow64RevertWow64FsRedirection=(Wow64RevertWow64FsRedirectionfunc)GetProcAddress(hmodule, "Wow64RevertWow64FsRedirection"); } *************** *** 5265,5268 **** --- 5211,5221 ---- #define FILE_READ_ONLY FILE_READ_ONLY + #define TF_DISCONNECT TF_DISCONNECT + #define TF_REUSE_SOCKET TF_REUSE_SOCKET + #define TF_WRITE_BEHIND TF_WRITE_BEHIND + #define TF_USE_DEFAULT_WORKER TF_USE_DEFAULT_WORKER + #define TF_USE_SYSTEM_THREAD TF_USE_SYSTEM_THREAD + #define TF_USE_KERNEL_APC TF_USE_KERNEL_APC + // flags used with CopyFileEx #define COPY_FILE_ALLOW_DECRYPTED_DESTINATION COPY_FILE_ALLOW_DECRYPTED_DESTINATION Index: win32rasmodule.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/src/win32rasmodule.cpp,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** win32rasmodule.cpp 8 Dec 2008 13:16:38 -0000 1.14 --- win32rasmodule.cpp 11 Dec 2008 00:25:40 -0000 1.15 *************** *** 124,129 **** static void deallocFunc(PyObject *ob); ! static PyObject *getattr(PyObject *self, char *name); ! static int setattr(PyObject *self, char *name, PyObject *v); static PyTypeObject type; RASDIALEXTENSIONS m_ext; --- 124,129 ---- static void deallocFunc(PyObject *ob); ! static PyObject *getattro(PyObject *self, PyObject *obname); ! static int setattro(PyObject *self, PyObject *obname, PyObject *v); static PyTypeObject type; RASDIALEXTENSIONS m_ext; *************** *** 162,167 **** PyRASDIALEXTENSIONS::deallocFunc, /* tp_dealloc */ 0, /* tp_print */ ! PyRASDIALEXTENSIONS::getattr, /* tp_getattr */ ! PyRASDIALEXTENSIONS::setattr, /* tp_setattr */ 0, /* tp_compare */ 0, /* tp_repr */ --- 162,167 ---- PyRASDIALEXTENSIONS::deallocFunc, /* tp_dealloc */ 0, /* tp_print */ ! 0, /* tp_getattr */ ! 0, /* tp_setattr */ 0, /* tp_compare */ 0, /* tp_repr */ *************** *** 172,178 **** 0, /* tp_call */ 0, /* tp_str */ ! 0, /*tp_getattro*/ ! 0, /*tp_setattro*/ 0, /*tp_as_buffer*/ }; --- 172,197 ---- 0, /* tp_call */ 0, /* tp_str */ ! PyRASDIALEXTENSIONS::getattro, /* tp_getattro */ ! PyRASDIALEXTENSIONS::setattro, /* tp_setattro */ 0, /*tp_as_buffer*/ + Py_TPFLAGS_DEFAULT, // tp_flags; + "An object that describes a Win32 RASDIALEXTENSIONS structure", // tp_doc + 0, // tp_traverse; + 0, // tp_clear + 0, // tp_richcompare; + 0, // tp_weaklistoffset; + 0, // tp_iter + 0, // iternextfunc tp_iternext + 0, // tp_methods + 0, // tp_members + 0, // tp_getset; + 0, // tp_base; + 0, // tp_dict; + 0, // tp_descr_get; + 0, // tp_descr_set; + 0, // tp_dictoffset; + 0, // tp_init; + 0, // tp_alloc; + 0, // newfunc tp_new; }; *************** *** 192,197 **** } ! PyObject *PyRASDIALEXTENSIONS::getattr(PyObject *self, char *name) { PyRASDIALEXTENSIONS *py = (PyRASDIALEXTENSIONS *)self; // @prop integer|dwfOptions|(fOptions may also be used) --- 211,219 ---- } ! PyObject *PyRASDIALEXTENSIONS::getattro(PyObject *self, PyObject *obname) { + char *name=PYWIN_ATTR_CONVERT(obname); + if (na... [truncated message content] |
From: Mark H. <mha...@us...> - 2008-12-11 00:25:46
|
Update of /cvsroot/pywin32/pywin32/win32/src/PerfMon In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv11688/src/PerfMon Modified Files: MappingManager.cpp PerfCounterDefn.cpp PerfObjectType.cpp pyperfmon.h Log Message: Merge many tp_getattro/setattro, "2 ints" and buffer changes from Roger via the py3k branch. Index: PerfCounterDefn.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/src/PerfMon/PerfCounterDefn.cpp,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** PerfCounterDefn.cpp 3 Dec 2008 22:34:21 -0000 1.2 --- PerfCounterDefn.cpp 11 Dec 2008 00:25:40 -0000 1.3 *************** *** 97,101 **** // excessive tests for lack of performance monitor functionality. // However, the method <om PyPERF_COUNTER_DEFINITION.Get> will raise a ValueError exception in this case. ! static struct PyMethodDef PyPERF_COUNTER_DEFINITION_methods[] = { {"Increment", PyPERF_COUNTER_DEFINITION::Increment, 1}, // @pymeth Increment|Increments the value of the performance counter {"Decrement", PyPERF_COUNTER_DEFINITION::Decrement, 1}, // @pymeth Decrement|Decrements the value of the performance counter --- 97,101 ---- // excessive tests for lack of performance monitor functionality. // However, the method <om PyPERF_COUNTER_DEFINITION.Get> will raise a ValueError exception in this case. ! struct PyMethodDef PyPERF_COUNTER_DEFINITION::methods[] = { {"Increment", PyPERF_COUNTER_DEFINITION::Increment, 1}, // @pymeth Increment|Increments the value of the performance counter {"Decrement", PyPERF_COUNTER_DEFINITION::Decrement, 1}, // @pymeth Decrement|Decrements the value of the performance counter *************** *** 114,119 **** PyPERF_COUNTER_DEFINITION::deallocFunc, /* tp_dealloc */ 0, /* tp_print */ ! PyPERF_COUNTER_DEFINITION::getattr, /* tp_getattr */ ! PyPERF_COUNTER_DEFINITION::setattr, /* tp_setattr */ 0, /* tp_compare */ 0, /* tp_repr */ --- 114,119 ---- PyPERF_COUNTER_DEFINITION::deallocFunc, /* tp_dealloc */ 0, /* tp_print */ ! 0, /* tp_getattr */ ! 0, /* tp_setattr */ 0, /* tp_compare */ 0, /* tp_repr */ *************** *** 124,127 **** --- 124,149 ---- 0, /* tp_call */ 0, /* tp_str */ + PyObject_GenericGetAttr, /* tp_getattro */ + PyObject_GenericSetAttr, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT, /* tp_flags */ + 0, /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + PyPERF_COUNTER_DEFINITION::methods, /* tp_methods */ + PyPERF_COUNTER_DEFINITION::members, /* tp_members */ + 0, /* tp_getset */ + 0, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + 0, /* tp_init */ + 0, /* tp_alloc */ + 0, /* tp_new */ }; *************** *** 129,133 **** ! /*static*/ struct memberlist PyPERF_COUNTER_DEFINITION::memberlist[] = { {"DefaultScale", T_LONG, OFF(m_DefaultScale)}, // @prop integer|DefaultScale|The default scale of the counter. {"DetailLevel", T_LONG, OFF(m_DetailLevel)}, // @prop integer|DetailLevel|The detail level of the counter. --- 151,155 ---- ! /*static*/ struct PyMemberDef PyPERF_COUNTER_DEFINITION::members[] = { {"DefaultScale", T_LONG, OFF(m_DefaultScale)}, // @prop integer|DefaultScale|The default scale of the counter. {"DetailLevel", T_LONG, OFF(m_DetailLevel)}, // @prop integer|DetailLevel|The detail level of the counter. *************** *** 189,212 **** } - PyObject *PyPERF_COUNTER_DEFINITION::getattr(PyObject *self, char *name) - { - PyObject *res; - - res = Py_FindMethod(PyPERF_COUNTER_DEFINITION_methods, self, name); - if (res != NULL) - return res; - PyErr_Clear(); - return PyMember_Get((char *)self, memberlist, name); - } - - int PyPERF_COUNTER_DEFINITION::setattr(PyObject *self, char *name, PyObject *v) - { - if (v == NULL) { - PyErr_SetString(PyExc_AttributeError, "can't delete PERF_COUNTER_DEFINITION attributes"); - return -1; - } - return PyMember_Set((char *)self, memberlist, name, v); - } - /*static*/ void PyPERF_COUNTER_DEFINITION::deallocFunc(PyObject *ob) { --- 211,214 ---- Index: MappingManager.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/src/PerfMon/MappingManager.cpp,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** MappingManager.cpp 3 Dec 2008 22:34:21 -0000 1.5 --- MappingManager.cpp 11 Dec 2008 00:25:40 -0000 1.6 *************** *** 179,183 **** // @object PyPerfMonManager|A Python object ! static struct PyMethodDef PyPerfMonManager_methods[] = { {"Close", PyPerfMonManager::Close, 1}, // @pymeth Close|Closes all counters. {NULL} --- 179,183 ---- // @object PyPerfMonManager|A Python object ! struct PyMethodDef PyPerfMonManager::methods[] = { {"Close", PyPerfMonManager::Close, 1}, // @pymeth Close|Closes all counters. {NULL} *************** *** 192,197 **** PyPerfMonManager::deallocFunc, /* tp_dealloc */ 0, /* tp_print */ ! PyPerfMonManager::getattr, /* tp_getattr */ ! PyPerfMonManager::setattr, /* tp_setattr */ 0, /* tp_compare */ 0, /* tp_repr */ --- 192,197 ---- PyPerfMonManager::deallocFunc, /* tp_dealloc */ 0, /* tp_print */ ! 0, /* tp_getattr */ ! 0, /* tp_setattr */ 0, /* tp_compare */ 0, /* tp_repr */ *************** *** 202,205 **** --- 202,227 ---- 0, /* tp_call */ 0, /* tp_str */ + PyObject_GenericGetAttr, /* tp_getattro */ + PyObject_GenericSetAttr, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT, /* tp_flags */ + 0, /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + PyPerfMonManager::methods, /* tp_methods */ + PyPerfMonManager::members, /* tp_members */ + 0, /* tp_getset */ + 0, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + 0, /* tp_init */ + 0, /* tp_alloc */ + 0, /* tp_new */ }; *************** *** 207,211 **** ! /*static*/ struct memberlist PyPerfMonManager::memberlist[] = { {NULL} /* Sentinel */ }; --- 229,233 ---- ! /*static*/ struct PyMemberDef PyPerfMonManager::members[] = { {NULL} /* Sentinel */ }; *************** *** 268,291 **** } - PyObject *PyPerfMonManager::getattr(PyObject *self, char *name) - { - PyObject *res; - - res = Py_FindMethod(PyPerfMonManager_methods, self, name); - if (res != NULL) - return res; - PyErr_Clear(); - return PyMember_Get((char *)self, memberlist, name); - } - - int PyPerfMonManager::setattr(PyObject *self, char *name, PyObject *v) - { - if (v == NULL) { - PyErr_SetString(PyExc_AttributeError, "can't delete PERF_OBJECT_TYPE attributes"); - return -1; - } - return PyMember_Set((char *)self, memberlist, name, v); - } - /*static*/ void PyPerfMonManager::deallocFunc(PyObject *ob) { --- 290,293 ---- Index: pyperfmon.h =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/src/PerfMon/pyperfmon.h,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** pyperfmon.h 4 Dec 2008 00:17:13 -0000 1.2 --- pyperfmon.h 11 Dec 2008 00:25:40 -0000 1.3 *************** *** 40,46 **** static void deallocFunc(PyObject *ob); ! static PyObject *getattr(PyObject *self, char *name); ! static int setattr(PyObject *self, char *name, PyObject *v); ! static struct memberlist memberlist[]; static PyTypeObject type; protected: --- 40,45 ---- static void deallocFunc(PyObject *ob); ! static struct PyMemberDef members[]; ! static struct PyMethodDef methods[]; static PyTypeObject type; protected: *************** *** 69,74 **** static void deallocFunc(PyObject *ob); ! static PyObject *getattr(PyObject *self, char *name); ! static int setattr(PyObject *self, char *name, PyObject *v); static PyObject *Increment(PyObject *self, PyObject *args); --- 68,73 ---- static void deallocFunc(PyObject *ob); ! static PyObject *getattro(PyObject *self, PyObject *obname); ! static int setattro(PyObject *self, PyObject *obname, PyObject *v); static PyObject *Increment(PyObject *self, PyObject *args); *************** *** 77,84 **** static PyObject *Get(PyObject *self, PyObject *args); ! // #pragma warning( disable : 4251 ) ! static struct memberlist memberlist[]; static PyTypeObject type; - #pragma warning( default : 4251 ) protected: --- 76,82 ---- static PyObject *Get(PyObject *self, PyObject *args); ! static struct PyMemberDef members[]; ! static struct PyMethodDef methods[]; static PyTypeObject type; protected: *************** *** 115,125 **** /* Python support */ static void deallocFunc(PyObject *ob); - - static PyObject *getattr(PyObject *self, char *name); - static int setattr(PyObject *self, char *name, PyObject *v); - static PyObject *Close(PyObject *self, PyObject *args); ! ! static struct memberlist memberlist[]; static PyTypeObject type; --- 113,119 ---- /* Python support */ static void deallocFunc(PyObject *ob); static PyObject *Close(PyObject *self, PyObject *args); ! static struct PyMemberDef members[]; ! static struct PyMethodDef methods[]; static PyTypeObject type; Index: PerfObjectType.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/src/PerfMon/PerfObjectType.cpp,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** PerfObjectType.cpp 3 Dec 2008 22:34:21 -0000 1.2 --- PerfObjectType.cpp 11 Dec 2008 00:25:40 -0000 1.3 *************** *** 57,61 **** // @object PyPERF_OBJECT_TYPE|A Python object, representing a PERF_OBJECT_TYPE structure ! static struct PyMethodDef PyPERF_OBJECT_TYPE_methods[] = { {"Close", PyPERF_OBJECT_TYPE::Close, 1}, // @pymeth Close|Closes all counters. {NULL} --- 57,61 ---- // @object PyPERF_OBJECT_TYPE|A Python object, representing a PERF_OBJECT_TYPE structure ! struct PyMethodDef PyPERF_OBJECT_TYPE::methods[] = { {"Close", PyPERF_OBJECT_TYPE::Close, 1}, // @pymeth Close|Closes all counters. {NULL} *************** *** 71,76 **** PyPERF_OBJECT_TYPE::deallocFunc, /* tp_dealloc */ 0, /* tp_print */ ! PyPERF_OBJECT_TYPE::getattr, /* tp_getattr */ ! PyPERF_OBJECT_TYPE::setattr, /* tp_setattr */ 0, /* tp_compare */ 0, /* tp_repr */ --- 71,76 ---- PyPERF_OBJECT_TYPE::deallocFunc, /* tp_dealloc */ 0, /* tp_print */ ! 0, /* tp_getattr */ ! 0, /* tp_setattr */ 0, /* tp_compare */ 0, /* tp_repr */ *************** *** 81,84 **** --- 81,106 ---- 0, /* tp_call */ 0, /* tp_str */ + PyObject_GenericGetAttr, /* tp_getattro */ + PyObject_GenericSetAttr, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT, /* tp_flags */ + 0, /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + PyPERF_OBJECT_TYPE::methods, /* tp_methods */ + PyPERF_OBJECT_TYPE::members, /* tp_members */ + 0, /* tp_getset */ + 0, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + 0, /* tp_init */ + 0, /* tp_alloc */ + 0, /* tp_new */ }; *************** *** 86,90 **** ! /*static*/ struct memberlist PyPERF_OBJECT_TYPE::memberlist[] = { {"ObjectNameTitleIndex", T_LONG, OFF(m_ObjectNameTitleIndex)}, // @prop integer|ObjectNameTitleIndex| {"ObjectHelpTitleIndex", T_LONG, OFF(m_ObjectHelpTitleIndex)}, // @prop integer|ObjectHelpTitleIndex| --- 108,112 ---- ! /*static*/ struct PyMemberDef PyPERF_OBJECT_TYPE::members[] = { {"ObjectNameTitleIndex", T_LONG, OFF(m_ObjectNameTitleIndex)}, // @prop integer|ObjectNameTitleIndex| {"ObjectHelpTitleIndex", T_LONG, OFF(m_ObjectHelpTitleIndex)}, // @prop integer|ObjectHelpTitleIndex| *************** *** 240,263 **** } - PyObject *PyPERF_OBJECT_TYPE::getattr(PyObject *self, char *name) - { - PyObject *res; - - res = Py_FindMethod(PyPERF_OBJECT_TYPE_methods, self, name); - if (res != NULL) - return res; - PyErr_Clear(); - return PyMember_Get((char *)self, memberlist, name); - } - - int PyPERF_OBJECT_TYPE::setattr(PyObject *self, char *name, PyObject *v) - { - if (v == NULL) { - PyErr_SetString(PyExc_AttributeError, "can't delete PERF_OBJECT_TYPE attributes"); - return -1; - } - return PyMember_Set((char *)self, memberlist, name, v); - } - /*static*/ void PyPERF_OBJECT_TYPE::deallocFunc(PyObject *ob) { --- 262,265 ---- |
From: Mark H. <mha...@us...> - 2008-12-11 00:25:45
|
Update of /cvsroot/pywin32/pywin32/win32/test In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv11688/test Added Files: test_win32gui.py Log Message: Merge many tp_getattro/setattro, "2 ints" and buffer changes from Roger via the py3k branch. --- NEW FILE: test_win32gui.py --- # tests for win32gui import unittest import win32gui class TestMisc(unittest.TestCase): def test_get_string(self): # test invalid addresses cause a ValueError rather than crash! self.assertRaises(ValueError, win32gui.PyGetString, 0) self.assertRaises(ValueError, win32gui.PyGetString, 1) self.assertRaises(ValueError, win32gui.PyGetString, 1,1) if __name__=='__main__': unittest.main() |
From: Mark H. <mha...@us...> - 2008-12-11 00:24:59
|
Update of /cvsroot/pywin32/pywin32/win32/test In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv11587/test Modified Files: test_security.py test_pywintypes.py Log Message: Add simple comparison tests for PyTime and PySID objects. Index: test_security.py =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/test/test_security.py,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** test_security.py 31 May 2005 02:07:35 -0000 1.4 --- test_security.py 11 Dec 2008 00:24:53 -0000 1.5 *************** *** 13,16 **** --- 13,26 ---- pass + def testEqual(self): + self.failUnlessEqual(win32security.LookupAccountName('','Administrator')[0], + win32security.LookupAccountName('','Administrator')[0]) + + def testBuffer(self): + # hrm - what about py3k - intent is to check the buffer slots return + # something sane. + self.failUnlessEqual(buffer(win32security.LookupAccountName('','Administrator')[0]), + buffer(win32security.LookupAccountName('','Administrator')[0])) + def testMemory(self): pwr_sid = self.pwr_sid Index: test_pywintypes.py =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/test/test_pywintypes.py,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** test_pywintypes.py 26 May 2004 08:29:20 -0000 1.3 --- test_pywintypes.py 11 Dec 2008 00:24:53 -0000 1.4 *************** *** 22,25 **** --- 22,38 ---- return + def testPyTimeCompare(self): + t1 = pywintypes.Time(100) + t1_2 = pywintypes.Time(100) + t2 = pywintypes.Time(101) + + self.failUnlessEqual(t1, t1_2) + self.failUnless(t1 <= t1_2) + self.failUnless(t1_2 >= t1) + + self.failIfEqual(t1, t2) + self.failUnless(t1 < t2) + self.failUnless(t2 > t1 ) + def testGUID(self): s = "{00020400-0000-0000-C000-000000000046}" |
From: Mark H. <mha...@us...> - 2008-12-11 00:23:53
|
Update of /cvsroot/pywin32/pywin32/win32/test In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv11370/test Modified Files: test_win32file.py Log Message: Avoid socket.create_connection as it doesn't exist in early python's. Index: test_win32file.py =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/test/test_win32file.py,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -d -r1.17 -r1.18 *** test_win32file.py 6 Dec 2008 00:47:23 -0000 1.17 --- test_win32file.py 11 Dec 2008 00:23:48 -0000 1.18 *************** *** 297,301 **** if not running.isSet(): self.fail("AcceptEx Worker thread failed to start") ! s = socket.create_connection(('127.0.0.1', port), 10) win32file.WSASend(s, "hello", None) overlapped = pywintypes.OVERLAPPED() --- 297,302 ---- if not running.isSet(): self.fail("AcceptEx Worker thread failed to start") ! s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) ! s.connect(('127.0.0.1', port)) win32file.WSASend(s, "hello", None) overlapped = pywintypes.OVERLAPPED() |
From: Mark H. <mha...@us...> - 2008-12-11 00:21:48
|
Update of /cvsroot/pywin32/pywin32/win32/test In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv11009 Modified Files: test_win32api.py Log Message: Use %temp% instead of the cwd so there is more hope of \\\\?\\ semantics. Index: test_win32api.py =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/test/test_win32api.py,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** test_win32api.py 3 Oct 2008 01:03:56 -0000 1.14 --- test_win32api.py 11 Dec 2008 00:21:42 -0000 1.15 *************** *** 5,8 **** --- 5,9 ---- import win32api, win32con, win32event, winerror import sys, os + import tempfile class CurrentUserTestCase(unittest.TestCase): *************** *** 138,145 **** def testLongLongPathNames(self): # We need filename where the FQN is > 256 - simplest way is to create a ! # 250 character directory in the cwd. import win32file basename = "a" * 250 ! fname = "\\\\?\\" + os.path.join(os.getcwd(), basename) try: win32file.CreateDirectoryW(fname, None) --- 139,150 ---- def testLongLongPathNames(self): # We need filename where the FQN is > 256 - simplest way is to create a ! # 250 character directory in the cwd (except - cwd may be on a drive ! # not supporting \\\\?\\ (eg, network share) - so use temp. import win32file basename = "a" * 250 ! # but we need to ensure we use the 'long' version of the ! # temp dir for later comparison. ! long_temp_dir = win32api.GetLongPathNameW(tempfile.gettempdir()) ! fname = "\\\\?\\" + os.path.join(long_temp_dir, basename) try: win32file.CreateDirectoryW(fname, None) |
From: Mark H. <mha...@us...> - 2008-12-10 23:48:54
|
Update of /cvsroot/pywin32/pywin32/win32/src/win32wnet In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv6256 Modified Files: PyNCB.cpp PyNetresource.cpp Log Message: Move away from 'unsigned' types as Python always gives us a long (even for unsigned byte!) Index: PyNetresource.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/src/win32wnet/PyNetresource.cpp,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** PyNetresource.cpp 10 Dec 2008 11:13:51 -0000 1.5 --- PyNetresource.cpp 10 Dec 2008 23:48:49 -0000 1.6 *************** *** 126,133 **** struct PyMemberDef PyNETRESOURCE::members[] = { ! {"dwScope", T_ULONG, OFF(m_nr.dwScope), 0}, // @prop integer|dwScope| ! {"dwType", T_ULONG, OFF(m_nr.dwType), 0}, // @prop integer|dwType| ! {"dwDisplayType", T_ULONG,OFF(m_nr.dwDisplayType), 0}, // @prop integer|dwDisplayType| ! {"dwUsage", T_ULONG, OFF(m_nr.dwUsage), 0}, // @prop integer|dwUsage| // These are handled by getattro/setattro --- 126,135 ---- struct PyMemberDef PyNETRESOURCE::members[] = { ! // Note we avoid the use of 'U'nsigned types as they always force ! // a long to be returned. ! {"dwScope", T_INT, OFF(m_nr.dwScope), 0}, // @prop integer|dwScope| ! {"dwType", T_INT, OFF(m_nr.dwType), 0}, // @prop integer|dwType| ! {"dwDisplayType", T_INT, OFF(m_nr.dwDisplayType), 0}, // @prop integer|dwDisplayType| ! {"dwUsage", T_INT, OFF(m_nr.dwUsage), 0}, // @prop integer|dwUsage| // These are handled by getattro/setattro Index: PyNCB.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/src/win32wnet/PyNCB.cpp,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** PyNCB.cpp 10 Dec 2008 11:13:51 -0000 1.6 --- PyNCB.cpp 10 Dec 2008 23:48:49 -0000 1.7 *************** *** 110,124 **** struct PyMemberDef PyNCB::members[] = { ! {"Command", T_UBYTE, OFF(m_ncb.ncb_command), 0}, // @prop int|Command| ! {"Retcode", T_UBYTE, OFF(m_ncb.ncb_retcode), 0}, // @prop int|Retcode| ! {"Lsn", T_UBYTE, OFF(m_ncb.ncb_lsn), 0}, // @prop int|Lsn| ! {"Num", T_UBYTE, OFF(m_ncb.ncb_num), 0}, // @prop int|Num| ! {"Bufflen", T_USHORT, OFF(m_ncb.ncb_length), 1}, // @prop int|Bufflen|read-only {"Callname",T_STRING, OFF(m_ncb.ncb_callname),0}, // @prop string|Callname| - The strings need to be space padded to 16 chars exactly {"Name", T_STRING, OFF(m_ncb.ncb_name), 0}, // @prop string|Name| - The strings need to be space padded to 16 chars exactly ! {"Rto", T_UBYTE, OFF(m_ncb.ncb_rto), 0},// @prop string|Rto| - The strings need to be space padded to 16 chars exactly ! {"Sto", T_UBYTE, OFF(m_ncb.ncb_sto), 0},// @prop string|Sto| - The strings need to be space padded to 16 chars exactly ! {"Lana_num",T_UBYTE, OFF(m_ncb.ncb_lana_num),0},// @prop int|Lana_num| ! {"Cmd_cplt",T_UBYTE, OFF(m_ncb.ncb_cmd_cplt),0},// @prop int|Cmd_cplt| {"Event", T_LONG, OFF(m_ncb.ncb_event), 0},// @prop int|Event| {"Post", T_LONG, OFF(m_ncb.ncb_post), 0},// @prop int|Post| --- 110,126 ---- struct PyMemberDef PyNCB::members[] = { ! // Note we avoid the use of 'U'nsigned types as they always force ! // a long to be returned. ! {"Command", T_BYTE, OFF(m_ncb.ncb_command), 0}, // @prop int|Command| ! {"Retcode", T_BYTE, OFF(m_ncb.ncb_retcode), 0}, // @prop int|Retcode| ! {"Lsn", T_BYTE, OFF(m_ncb.ncb_lsn), 0}, // @prop int|Lsn| ! {"Num", T_BYTE, OFF(m_ncb.ncb_num), 0}, // @prop int|Num| ! {"Bufflen", T_SHORT, OFF(m_ncb.ncb_length), 1}, // @prop int|Bufflen|read-only {"Callname",T_STRING, OFF(m_ncb.ncb_callname),0}, // @prop string|Callname| - The strings need to be space padded to 16 chars exactly {"Name", T_STRING, OFF(m_ncb.ncb_name), 0}, // @prop string|Name| - The strings need to be space padded to 16 chars exactly ! {"Rto", T_BYTE, OFF(m_ncb.ncb_rto), 0},// @prop string|Rto| - The strings need to be space padded to 16 chars exactly ! {"Sto", T_BYTE, OFF(m_ncb.ncb_sto), 0},// @prop string|Sto| - The strings need to be space padded to 16 chars exactly ! {"Lana_num",T_BYTE, OFF(m_ncb.ncb_lana_num),0},// @prop int|Lana_num| ! {"Cmd_cplt",T_BYTE, OFF(m_ncb.ncb_cmd_cplt),0},// @prop int|Cmd_cplt| {"Event", T_LONG, OFF(m_ncb.ncb_event), 0},// @prop int|Event| {"Post", T_LONG, OFF(m_ncb.ncb_post), 0},// @prop int|Post| |
From: Mark H. <mha...@us...> - 2008-12-10 11:13:57
|
Update of /cvsroot/pywin32/pywin32/win32/test In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv9900/win32/test Modified Files: test_win32wnet.py Log Message: Modernization of win32wnet, via the py3k branch: * Move to getattro/setattro * Add support for WNetAddConnection2 taking a NETRESOURCE as the first param. * Add tp_new slots for the type, so the type can be used in-place of global functions. * Replace NCB and NETRESOURCE methods with the actual types. * Treat CallName and Name attributes as true strings. * Many more tests. Index: test_win32wnet.py =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/test/test_win32wnet.py,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** test_win32wnet.py 2 Jul 2003 04:07:37 -0000 1.1 --- test_win32wnet.py 10 Dec 2008 11:13:51 -0000 1.2 *************** *** 1,4 **** import unittest ! import win32wnet, win32api class TestCase(unittest.TestCase): --- 1,51 ---- import unittest ! import win32wnet ! import win32api ! import netbios ! ! RESOURCE_CONNECTED = 0x00000001 ! RESOURCE_GLOBALNET = 0x00000002 ! RESOURCE_REMEMBERED = 0x00000003 ! RESOURCE_RECENT = 0x00000004 ! RESOURCE_CONTEXT = 0x00000005 ! RESOURCETYPE_ANY = 0x00000000 ! RESOURCETYPE_DISK = 0x00000001 ! RESOURCETYPE_PRINT = 0x00000002 ! RESOURCETYPE_RESERVED = 0x00000008 ! RESOURCETYPE_UNKNOWN = 0xFFFFFFFF ! RESOURCEUSAGE_CONNECTABLE = 0x00000001 ! RESOURCEUSAGE_CONTAINER = 0x00000002 ! RESOURCEDISPLAYTYPE_GENERIC = 0x00000000 ! RESOURCEDISPLAYTYPE_DOMAIN = 0x00000001 ! RESOURCEDISPLAYTYPE_SERVER = 0x00000002 ! RESOURCEDISPLAYTYPE_SHARE = 0x00000003 ! ! ! NETRESOURCE_attributes = [ ! ("dwScope", int), ! ("dwType", int), ! ("dwDisplayType", int), ! ("dwUsage", int), ! ("lpLocalName", str), ! ("lpRemoteName", str), ! ("lpComment", str), ! ("lpProvider", str), ! ] ! ! NCB_attributes = [ ! ("Command", int), ! ("Retcode", int), ! ("Lsn", int), ! ("Num", int), ! # ("Bufflen", int), - read-only ! ("Callname", str), ! ("Name", str), ! ("Rto", int), ! ("Sto", int), ! ("Lana_num", int), ! ("Cmd_cplt", int), ! ("Event", int), ! ("Post", int), ! ] class TestCase(unittest.TestCase): *************** *** 6,9 **** --- 53,169 ---- self.assertEquals(win32api.GetUserName(), win32wnet.WNetGetUser()) + def _checkItemAttributes(self, item, attrs): + for attr, typ in attrs: + val = getattr(item, attr) + if typ is int: + self.failUnless(type(val) in (int, int), + "Attr %r has value %r" % (attr, val)) + new_val = val + 1 + elif typ is str: + if val is not None: + # on py2k, must be string or unicode. py3k must be string or bytes. + self.failUnless(type(val) in (str, str), + "Attr %r has value %r" % (attr, val)) + new_val = val + " new value" + else: + new_val = "new value" + else: + self.fail("Don't know what %s is" % (typ,)) + # set the attribute just to make sure we can. + setattr(item, attr, new_val) + + def testNETRESOURCE(self): + nr = win32wnet.NETRESOURCE() + self._checkItemAttributes(nr, NETRESOURCE_attributes) + + def testWNetEnumResource(self): + handle = win32wnet.WNetOpenEnum(RESOURCE_GLOBALNET, RESOURCETYPE_ANY, + 0, None) + try: + while 1: + items = win32wnet.WNetEnumResource(handle, 0) + if len(items)==0: + break + for item in items: + self._checkItemAttributes(item, NETRESOURCE_attributes) + finally: + handle.Close() + + def testNCB(self): + ncb = win32wnet.NCB() + self._checkItemAttributes(ncb, NCB_attributes) + + def testNetbios(self): + # taken from the demo code in netbios.py + ncb = win32wnet.NCB() + ncb.Command = netbios.NCBENUM + la_enum = netbios.LANA_ENUM() + ncb.Buffer = la_enum + rc = win32wnet.Netbios(ncb) + self.failUnlessEqual(rc, 0) + for i in range(la_enum.length): + ncb.Reset() + ncb.Command = netbios.NCBRESET + ncb.Lana_num = netbios.byte_to_int(la_enum.lana[i]) + rc = Netbios(ncb) + self.failUnlessEqual(rc, 0) + ncb.Reset() + ncb.Command = netbios.NCBASTAT + ncb.Lana_num = byte_to_int(la_enum.lana[i]) + ncb.Callname = "* ".encode("ascii") # ensure bytes on py2x and 3k + adapter = netbios.ADAPTER_STATUS() + ncb.Buffer = adapter + Netbios(ncb) + # expect 6 bytes in the mac address. + self.failUnless(len(adapter.adapter_address), 6) + + def iterConnectableShares(self): + nr = win32wnet.NETRESOURCE() + nr.dwScope = RESOURCE_GLOBALNET + nr.dwUsage = RESOURCEUSAGE_CONTAINER + nr.lpRemoteName = "\\\\" + win32api.GetComputerName() + + handle = win32wnet.WNetOpenEnum(RESOURCE_GLOBALNET, RESOURCETYPE_ANY, + 0, nr) + while 1: + items = win32wnet.WNetEnumResource(handle, 0) + if len(items)==0: + break + for item in items: + if item.dwDisplayType == RESOURCEDISPLAYTYPE_SHARE: + yield item + + def findUnusedDriveLetter(self): + existing = [x[0].lower() for x in win32api.GetLogicalDriveStrings().split('\0') if x] + handle = win32wnet.WNetOpenEnum(RESOURCE_REMEMBERED,RESOURCETYPE_DISK,0,None) + try: + while 1: + items = win32wnet.WNetEnumResource(handle, 0) + if len(items)==0: + break + xtra = [i.lpLocalName[0].lower() for i in items if i.lpLocalName] + existing.extend(xtra) + finally: + handle.Close() + for maybe in 'defghijklmnopqrstuvwxyz': + if maybe not in existing: + return maybe + self.fail("All drive mappings are taken?") + + def testAddConnection(self): + localName = self.findUnusedDriveLetter() + ':' + for share in self.iterConnectableShares(): + share.lpLocalName = localName + win32wnet.WNetAddConnection2(share) + win32wnet.WNetCancelConnection2(localName, 0, 0) + break + + def testAddConnectionOld(self): + localName = self.findUnusedDriveLetter() + ':' + for share in self.iterConnectableShares(): + win32wnet.WNetAddConnection2(share.dwType, localName, share.lpRemoteName) + win32wnet.WNetCancelConnection2(localName, 0, 0) + break + if __name__ == '__main__': |
From: Mark H. <mha...@us...> - 2008-12-10 11:13:57
|
Update of /cvsroot/pywin32/pywin32/win32/Demos/win32wnet In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv9900/win32/Demos/win32wnet Modified Files: testwnet.py Log Message: Modernization of win32wnet, via the py3k branch: * Move to getattro/setattro * Add support for WNetAddConnection2 taking a NETRESOURCE as the first param. * Add tp_new slots for the type, so the type can be used in-place of global functions. * Replace NCB and NETRESOURCE methods with the actual types. * Treat CallName and Name attributes as true strings. * Many more tests. Index: testwnet.py =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/Demos/win32wnet/testwnet.py,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** testwnet.py 27 Nov 2008 03:53:25 -0000 1.5 --- testwnet.py 10 Dec 2008 11:13:51 -0000 1.6 *************** *** 1,2 **** --- 1,3 ---- + import win32api import win32wnet import sys *************** *** 39,47 **** print "Finished dumping all resources." def TestConnection(): if len(possible_shares)==0: print "Couldn't find any potential shares to connect to" return ! localName = "Z:" # need better way! for share in possible_shares: print "Attempting connection of", localName, "to", share.lpRemoteName --- 40,65 ---- print "Finished dumping all resources." + def findUnusedDriveLetter(): + existing = [x[0].lower() for x in win32api.GetLogicalDriveStrings().split('\0') if x] + handle = win32wnet.WNetOpenEnum(RESOURCE_REMEMBERED,RESOURCETYPE_DISK,0,None) + try: + while 1: + items = win32wnet.WNetEnumResource(handle, 0) + if len(items)==0: + break + xtra = [i.lpLocalName[0].lower() for i in items if i.lpLocalName] + existing.extend(xtra) + finally: + handle.Close() + for maybe in 'defghijklmnopqrstuvwxyz': + if maybe not in existing: + return maybe + raise RuntimeError("All drive mappings are taken?") + def TestConnection(): if len(possible_shares)==0: print "Couldn't find any potential shares to connect to" return ! localName = findUnusedDriveLetter() + ':' for share in possible_shares: print "Attempting connection of", localName, "to", share.lpRemoteName *************** *** 61,66 **** finally: win32wnet.WNetCancelConnection2(localName, 0, 0) ! # Only do the first share that succeeds. ! break def TestGetUser(): --- 79,93 ---- finally: win32wnet.WNetCancelConnection2(localName, 0, 0) ! # and do it again, but this time by using the more modern ! # NETRESOURCE way. ! nr = win32wnet.NETRESOURCE() ! nr.dwType = share.dwType ! nr.lpLocalName = localName ! nr.lpRemoteName = share.lpRemoteName ! win32wnet.WNetAddConnection2(nr) ! win32wnet.WNetCancelConnection2(localName, 0, 0) ! ! # Only do the first share that succeeds. ! break def TestGetUser(): |
From: Mark H. <mha...@us...> - 2008-12-10 11:13:57
|
Update of /cvsroot/pywin32/pywin32 In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv9900 Modified Files: CHANGES.txt Log Message: Modernization of win32wnet, via the py3k branch: * Move to getattro/setattro * Add support for WNetAddConnection2 taking a NETRESOURCE as the first param. * Add tp_new slots for the type, so the type can be used in-place of global functions. * Replace NCB and NETRESOURCE methods with the actual types. * Treat CallName and Name attributes as true strings. * Many more tests. Index: CHANGES.txt =================================================================== RCS file: /cvsroot/pywin32/pywin32/CHANGES.txt,v retrieving revision 1.35 retrieving revision 1.36 diff -C2 -d -r1.35 -r1.36 *** CHANGES.txt 8 Dec 2008 12:37:50 -0000 1.35 --- CHANGES.txt 10 Dec 2008 11:13:51 -0000 1.36 *************** *** 9,12 **** --- 9,21 ---- ---------------- + * "Modernization" changes, instigated by py3k: + + - Many older modules now accept unicode arguments where previously they + only accepted strings - notably, win32ui, win32wnet ... + + - win32wnet: NCB and NETRESOURCE attributes are now types rather than + methods. NETRESOURCE string attributes may return None if the win32 + structure has a NULL pointer (previously an empty string was returned) + * Added win32inet.WinHttpGetDefaultProxyConfiguration() |
From: Mark H. <mha...@us...> - 2008-12-10 11:13:56
|
Update of /cvsroot/pywin32/pywin32/win32/src/win32wnet In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv9900/win32/src/win32wnet Modified Files: Netres.h PyNCB.cpp PyNCB.h PyNetresource.cpp win32wnet.cpp Log Message: Modernization of win32wnet, via the py3k branch: * Move to getattro/setattro * Add support for WNetAddConnection2 taking a NETRESOURCE as the first param. * Add tp_new slots for the type, so the type can be used in-place of global functions. * Replace NCB and NETRESOURCE methods with the actual types. * Treat CallName and Name attributes as true strings. * Many more tests. Index: win32wnet.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/src/win32wnet/win32wnet.cpp,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** win32wnet.cpp 9 Dec 2008 07:21:06 -0000 1.15 --- win32wnet.cpp 10 Dec 2008 11:13:51 -0000 1.16 *************** *** 129,181 **** // @pymethod |win32wnet|WNetAddConnection2|Creates a connection to a network resource. The function can redirect // a local device to the network resource. ! static ! PyObject * ! PyWNetAddConnection2 (PyObject *self, PyObject *args) ! { ! // @todo Eventually should update this to use a NETRESOURCE object (it was written before PyNETRESOURCE) ! DWORD Type; // @pyparm int|type||The resource type. May be either RESOURCETYPE_DISK, RESOURCETYPE_PRINT, or RESOURCETYPE_ANY (from win32netcon) ! LPSTR LocalName; // @pyparm string|localName||holds the name of a local device to map connection to; may be NULL ! LPSTR RemoteName; // @pyparm string|remoteName||holds the passed in remote machine\service name. ! LPSTR ProviderName = NULL; // @pyparm string|ProviderName|None|holds name of network provider to use (if any): NULL lets OS handle it ! LPSTR Username = NULL; // @pyparm string|userName|None|The user name to connect as. ! LPSTR Password = NULL; // @pyparm string|password|None|The password to use. ! ! DWORD ErrorNo; // holds the returned error number, if any ! DWORD flags = 0; // @pyparm int|flags|0|Specifies a DWORD value that describes connection options. The following value is currently defined. ! // @flagh Value|Meaning ! // @flag CONNECT_UPDATE_PROFILE|The network resource connection should be remembered. ! // <nl>If this bit flag is set, the operating system automatically attempts to restore the connection when the user logs on. ! // <nl>The operating system remembers only successful connections that redirect local devices. It does not remember connections that are unsuccessful or deviceless connections. (A deviceless connection occurs when the lpLocalName member is NULL or points to an empty string.) ! // <nl>If this bit flag is clear, the operating system does not automatically restore the connection at logon. ! NETRESOURCE NetResource; ! if (!PyArg_ParseTuple(args,"izs|zzzi",&Type,&LocalName,&RemoteName,&ProviderName,&Username,&Password, &flags)) ! return NULL; ! // Build the NETRESOURCE structure ! Py_BEGIN_ALLOW_THREADS ! memset((void *)&NetResource, '\0', sizeof(NETRESOURCE)); ! NetResource.dwType = Type; ! NetResource.lpLocalName = LocalName; ! NetResource.lpProvider = ProviderName; ! NetResource.lpRemoteName = RemoteName; ! #ifdef _WIN32_WCE_ // Windows CE only has the #3 version...use NULL for HWND to simulate #2 ! ErrorNo = WNetAddConnection3(NULL,&NetResource, Password, Username, flags); ! #else ! ErrorNo = WNetAddConnection2(&NetResource, Password, Username, flags); ! #endif Py_END_ALLOW_THREADS - if (ErrorNo != NO_ERROR) ! { ! return ReturnNetError("WNetAddConnection2", ErrorNo); } ! ! Py_INCREF(Py_None); ! return Py_None; ! }; --- 129,197 ---- // @pymethod |win32wnet|WNetAddConnection2|Creates a connection to a network resource. The function can redirect // a local device to the network resource. ! // @comm This function also accepts backwards-compatible, positional-only ! // arguments of (dwType, lpLocalName, lpRemoteName[, lpProviderName, Username, Password, flags]) ! // @comm Accepts keyword arguments. ! // @pyseeapi WNetAddConnection2 ! static PyObject *PyWNetAddConnection2 (PyObject *self, PyObject *args, PyObject *kwargs) { ! LPTSTR Username = NULL; ! LPTSTR Password = NULL; ! // values used for b/w compat args. ! DWORD Type; ! PyObject *obLocalName, *obRemoteName, *obProviderName = Py_None; ! PyObject *obnr, *obPassword=Py_None, *obUsername=Py_None, *ret=NULL; ! DWORD ErrorNo; // holds the returned error number, if any ! DWORD flags = 0; ! NETRESOURCE *pNetResource; ! NETRESOURCE tempNetResource; ! memset(&tempNetResource, 0, sizeof(tempNetResource)); ! if (PyArg_ParseTuple(args,"iOO|OOOi",&Type,&obLocalName,&obRemoteName,&obProviderName,&obUsername,&obPassword, &flags)) { ! // the b/w compat args have been used - build the NETRESOURCE structure ! memset((void *)&tempNetResource, '\0', sizeof(NETRESOURCE)); ! tempNetResource.dwType = Type; ! if (!PyWinObject_AsTCHAR(obLocalName, &tempNetResource.lpLocalName, TRUE) ! || !PyWinObject_AsTCHAR(obRemoteName, &tempNetResource.lpRemoteName, FALSE) ! || !PyWinObject_AsTCHAR(obProviderName, &tempNetResource.lpProvider, TRUE)) ! goto done; ! pNetResource = &tempNetResource; ! } else { ! PyErr_Clear(); ! static char *keywords[] = {"NetResource","Password","UserName","Flags", NULL}; ! if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O|OOk", keywords, ! &obnr, // @pyparm <o PyNETRESOURCE>|NetResource||Describes the network resource for the connection. ! &obPassword, // @pyparm str|Password|None|The password to use. Use None for default credentials. ! &obUsername, // @pyparm str|UserName|None|The user name to connect as. Use None for default credentials. ! &flags)) // @pyparm int|Flags|0|Combination win32netcon.CONNECT_* flags ! return NULL; ! if (!PyWinObject_AsNETRESOURCE(obnr, &pNetResource, FALSE)) ! return NULL; ! } ! if (!PyWinObject_AsTCHAR(obPassword, &Password, TRUE) ! || !PyWinObject_AsTCHAR(obUsername, &Username, TRUE)) ! goto done; ! Py_BEGIN_ALLOW_THREADS ! #ifdef _WIN32_WCE_ // Windows CE only has the #3 version...use NULL for HWND to simulate #2 ! ErrorNo = WNetAddConnection3(NULL, pNetResource, Password, Username, flags); ! #else ! ErrorNo = WNetAddConnection2(pNetResource, Password, Username, flags); ! #endif Py_END_ALLOW_THREADS if (ErrorNo != NO_ERROR) ! ReturnNetError("WNetAddConnection2", ErrorNo); ! else{ ! Py_INCREF(Py_None); ! ret = Py_None; } ! done: ! PyWinObject_FreeTCHAR(Password); ! PyWinObject_FreeTCHAR(Username); ! PyWinObject_FreeTCHAR(tempNetResource.lpLocalName); ! PyWinObject_FreeTCHAR(tempNetResource.lpRemoteName); ! PyWinObject_FreeTCHAR(tempNetResource.lpProvider); ! return ret; }; *************** *** 610,617 **** // @module win32wnet|A module that exposes the Windows Networking API. static PyMethodDef win32wnet_functions[] = { ! // @pymeth NETRESOURCE|Creates a new <o NETRESOURCE> object ! {"NETRESOURCE", PyWinMethod_NewNETRESOURCE, 1, "NETRESOURCE Structure Object. x=NETRESOURCE() to instantiate"}, ! // @pymeth NCB|Creates a new <o NCB> object ! {"NCB", PyWinMethod_NewNCB, 1, "NCB Netbios command structure Object"}, // @pymeth NCBBuffer|Creates a new buffer {"NCBBuffer", PyWinMethod_NCBBuffer, 1, "Creates a memory buffer"}, --- 626,631 ---- // @module win32wnet|A module that exposes the Windows Networking API. static PyMethodDef win32wnet_functions[] = { ! // @pymeth NETRESOURCE|The <o PyNETRESOURCE> type - can be used to create a new <o PyNETRESOURCE> object. ! // @pymeth NCB|The <o PyNCB> type - can be used to create a new <o PyNCB> object. // @pymeth NCBBuffer|Creates a new buffer {"NCBBuffer", PyWinMethod_NCBBuffer, 1, "Creates a memory buffer"}, *************** *** 646,650 **** "A module that exposes the Windows Networking API."); - PyDict_SetItemString(dict, "error", PyWinExc_ApiError); --- 660,663 ---- *************** *** 653,659 **** --- 666,676 ---- PYWIN_MODULE_INIT_RETURN_ERROR; + // old "deprecated" names, before types could create instances. PyDict_SetItemString(dict, "NETRESOURCEType", (PyObject *)&PyNETRESOURCEType); PyDict_SetItemString(dict, "NCBType", (PyObject *)&PyNCBType); + PyDict_SetItemString(dict, "NETRESOURCE", (PyObject *)&PyNETRESOURCEType); + PyDict_SetItemString(dict, "NCB", (PyObject *)&PyNCBType); + PYWIN_MODULE_INIT_RETURN_SUCCESS; } Index: PyNetresource.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/src/win32wnet/PyNetresource.cpp,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** PyNetresource.cpp 3 Dec 2008 22:34:21 -0000 1.4 --- PyNetresource.cpp 10 Dec 2008 11:13:51 -0000 1.5 *************** *** 36,46 **** ! /* Main PYTHON entry point for creating a new reference. Registered by win32wnet module */ ! ! // @pymethod <o PyNETRESOURCE>|win32wnet|NETRESOURCE|Creates a new <o NETRESOURCE> object. ! ! PyObject *PyWinMethod_NewNETRESOURCE(PyObject *self, PyObject *args) { ! if (!PyArg_ParseTuple(args, ":NETRESOURCE")) // no arguments return NULL; return new PyNETRESOURCE(); // call the C++ constructor --- 36,43 ---- ! static PyObject *NETRESOURCE_new(PyTypeObject *type, PyObject *args, PyObject *kwds) { ! static char *kwlist[] = {0}; ! if (!PyArg_ParseTupleAndKeywords(args, kwds, ":NETRESOURCE", kwlist)) // no arguments return NULL; return new PyNETRESOURCE(); // call the C++ constructor *************** *** 91,96 **** PyNETRESOURCE::deallocFunc, /* tp_dealloc */ 0, /* tp_print */ ! PyNETRESOURCE::getattr, /* tp_getattr */ ! PyNETRESOURCE::setattr, /* tp_setattr */ PyNETRESOURCE::compareFunc, /* tp_compare */ 0, /* tp_repr */ --- 88,93 ---- PyNETRESOURCE::deallocFunc, /* tp_dealloc */ 0, /* tp_print */ ! 0, /* tp_getattr */ ! 0, /* tp_setattr */ PyNETRESOURCE::compareFunc, /* tp_compare */ 0, /* tp_repr */ *************** *** 101,109 **** 0, /* tp_call */ 0, /* tp_str */ }; #define OFF(e) offsetof(PyNETRESOURCE, e) ! struct memberlist PyNETRESOURCE::memberlist[] = { {"dwScope", T_ULONG, OFF(m_nr.dwScope), 0}, // @prop integer|dwScope| --- 98,128 ---- 0, /* tp_call */ 0, /* tp_str */ + PyNETRESOURCE::getattro, /* tp_getattro */ + PyNETRESOURCE::setattro, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT, /* tp_flags */ + 0, /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + 0, /* tp_methods */ + PyNETRESOURCE::members, /* tp_members */ + 0, /* tp_getset */ + 0, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + 0, /* tp_init */ + 0, /* tp_alloc */ + NETRESOURCE_new, /* tp_new */ }; #define OFF(e) offsetof(PyNETRESOURCE, e) ! struct PyMemberDef PyNETRESOURCE::members[] = { {"dwScope", T_ULONG, OFF(m_nr.dwScope), 0}, // @prop integer|dwScope| *************** *** 112,115 **** --- 131,135 ---- {"dwUsage", T_ULONG, OFF(m_nr.dwUsage), 0}, // @prop integer|dwUsage| + // These are handled by getattro/setattro {"lpLocalName", T_STRING, OFF(m_nr.lpLocalName), 0}, // @prop string|localName| {"lpRemoteName",T_STRING, OFF(m_nr.lpRemoteName), 0},// @prop string|remoteName| *************** *** 117,120 **** --- 137,144 ---- {"lpProvider", T_STRING, OFF(m_nr.lpProvider), 0},// @prop string|provider| {NULL} + // @comm Note that in pywin32-212 and earlier, the string attributes + // were always strings, but empty strings when the underlying Windows + // structure had NULL. On later pywin32 builds, these string attributes will + // return None in such cases. }; *************** *** 124,216 **** _Py_NewReference(this); memset(&m_nr, 0, sizeof(m_nr)); - m_nr.lpLocalName = szLName; - m_nr.lpRemoteName = szRName; - m_nr.lpProvider = szProv; - m_nr.lpComment = szComment; - szLName[0] = _T('\0'); - szRName[0] = _T('\0'); - szProv[0] = _T('\0'); - szComment[0] = _T('\0'); } ! PyNETRESOURCE::PyNETRESOURCE(const NETRESOURCE *pO) { ob_type = &PyNETRESOURCEType; _Py_NewReference(this); ! m_nr.dwScope = pO->dwScope; ! m_nr.dwType = pO->dwType; ! m_nr.dwDisplayType = pO->dwDisplayType; ! m_nr.dwUsage = pO->dwUsage; ! m_nr.lpLocalName = szLName; ! m_nr.lpRemoteName = szRName; ! m_nr.lpProvider = szProv; ! m_nr.lpComment = szComment; ! ! if (pO->lpLocalName == NULL) ! szLName[0] = _T('\0'); ! else ! { ! _tcsncpy(szLName, pO->lpLocalName, MAX_NAME); ! szLName[MAX_NAME-1] = _T('\0'); // explicit termination! ! } ! ! ! if (pO->lpRemoteName == NULL) ! szRName[0] = _T('\0'); ! else ! { ! _tcsncpy(szRName, pO->lpRemoteName, MAX_NAME); ! szRName[MAX_NAME-1] = _T('\0'); // explicit termination! ! } ! ! ! if (pO->lpProvider == NULL) ! szProv[0] = _T('\0'); ! else ! { ! _tcsncpy(szProv, pO->lpProvider, MAX_NAME); ! szProv[MAX_NAME-1] = _T('\0'); // explicit termination! ! } ! ! if (pO->lpComment == NULL) ! szComment[0] = _T('\0'); ! else ! { ! _tcsncpy(szComment, pO->lpComment, MAX_COMMENT); ! szComment[MAX_COMMENT-1] = _T('\0'); ! } } PyNETRESOURCE::~PyNETRESOURCE(void) { ! } ! PyObject *PyNETRESOURCE::getattr(PyObject *self, char *name) { ! #ifdef UNICODE PyNETRESOURCE *This = (PyNETRESOURCE *)self; if (strcmp(name, "lpProvider")==0) ! return PyWinObject_FromWCHAR(This->m_nr.lpProvider); ! else if ! (strcmp(name, "lpRemoteName") == 0) ! return PyWinObject_FromWCHAR(This->m_nr.lpRemoteName); ! else if ! (strcmp(name, "lpLocalName") == 0) ! return PyWinObject_FromWCHAR(This->m_nr.lpLocalName); ! else if ! (strcmp(name, "lpComment") == 0) ! return PyWinObject_FromWCHAR(This->m_nr.lpComment); ! else ! #endif ! return PyMember_Get((char *)self, memberlist, name); } ! ! ! int PyNETRESOURCE::setattr(PyObject *self, char *name, PyObject *v) { if (v == NULL) { --- 148,199 ---- _Py_NewReference(this); memset(&m_nr, 0, sizeof(m_nr)); } ! PyNETRESOURCE::PyNETRESOURCE(const NETRESOURCE *p_nr) { ob_type = &PyNETRESOURCEType; _Py_NewReference(this); ! m_nr=*p_nr; + // Copy strings so they can be freed in same way as when set via setattro + // No error checking here, no way to return an error from a constructor anyway + if (p_nr->lpProvider) + m_nr.lpProvider=PyWin_CopyString(p_nr->lpProvider); + if (p_nr->lpRemoteName) + m_nr.lpRemoteName=PyWin_CopyString(p_nr->lpRemoteName); + if (p_nr->lpLocalName) + m_nr.lpLocalName=PyWin_CopyString(p_nr->lpLocalName); + if (p_nr->lpComment) + m_nr.lpComment=PyWin_CopyString(p_nr->lpComment); } PyNETRESOURCE::~PyNETRESOURCE(void) { ! PyWinObject_FreeTCHAR(m_nr.lpProvider); ! PyWinObject_FreeTCHAR(m_nr.lpRemoteName); ! PyWinObject_FreeTCHAR(m_nr.lpLocalName); ! PyWinObject_FreeTCHAR(m_nr.lpComment); } ! PyObject *PyNETRESOURCE::getattro(PyObject *self, PyObject *obname) { ! char *name=PYWIN_ATTR_CONVERT(obname); ! if (name==NULL) ! return NULL; PyNETRESOURCE *This = (PyNETRESOURCE *)self; if (strcmp(name, "lpProvider")==0) ! return PyWinObject_FromTCHAR(This->m_nr.lpProvider); ! if (strcmp(name, "lpRemoteName")==0) ! return PyWinObject_FromTCHAR(This->m_nr.lpRemoteName); ! if (strcmp(name, "lpLocalName")==0) ! return PyWinObject_FromTCHAR(This->m_nr.lpLocalName); ! if (strcmp(name, "lpComment")==0) ! return PyWinObject_FromTCHAR(This->m_nr.lpComment); ! return PyObject_GenericGetAttr(self, obname); } ! int PyNETRESOURCE::setattro(PyObject *self, PyObject *obname, PyObject *v) { if (v == NULL) { *************** *** 218,268 **** return -1; } PyNETRESOURCE *This = (PyNETRESOURCE *)self; ! // the following specific string attributes can be set, all others generate an error. ! ! if (PyString_Check(v)) ! { ! int ret; ! TCHAR *value; ! if (!PyWinObject_AsTCHAR(v, &value, FALSE)) return -1; ! if (strcmp (name, "lpProvider") == 0) ! { ! _tcsncpy(This->szProv, value, MAX_NAME); // no overflow allowed! ! This->szProv[MAX_NAME-1] = _T('\0'); // make sure NULL terminated! ! ret = 0; ! } ! else ! if (strcmp(name, "lpRemoteName") == 0) ! { ! _tcsncpy(This->szRName, value, MAX_NAME); ! This->szRName[MAX_NAME-1] = _T('\0'); ! ret = 0; } ! else ! if (strcmp(name, "lpLocalName") == 0) ! { ! _tcsncpy(This->szLName, value, MAX_NAME); ! This->szLName[MAX_NAME-1] = _T('\0'); ! ret = 0; } ! else ! if (strcmp(name, "lpComment") == 0) ! { ! _tcsncpy(This->szComment, value, MAX_COMMENT); ! This->szComment[MAX_COMMENT-1] = _T('\0'); ! ret = 0; } ! else ! { ! PyErr_SetString(PyExc_AttributeError, "The attribute is not a PyNETRESOURCE string"); ! ret = -1; } ! PyWinObject_FreeTCHAR(value); ! return ret; ! } // PyString_Check ! ! return PyMember_Set((char *)self, memberlist, name, v); } --- 201,239 ---- return -1; } + char *name=PYWIN_ATTR_CONVERT(obname); + if (name==NULL) + return NULL; PyNETRESOURCE *This = (PyNETRESOURCE *)self; ! TCHAR *value; ! if (strcmp(name, "lpProvider")==0){ ! if (!PyWinObject_AsTCHAR(v, &value, TRUE)) return -1; ! PyWinObject_FreeTCHAR(This->m_nr.lpProvider); ! This->m_nr.lpProvider=value; ! return 0; } ! if (strcmp(name, "lpRemoteName")==0){ ! if (!PyWinObject_AsTCHAR(v, &value, TRUE)) ! return -1; ! PyWinObject_FreeTCHAR(This->m_nr.lpRemoteName); ! This->m_nr.lpRemoteName=value; ! return 0; } ! if (strcmp(name, "lpLocalName")==0){ ! if (!PyWinObject_AsTCHAR(v, &value, TRUE)) ! return -1; ! PyWinObject_FreeTCHAR(This->m_nr.lpLocalName); ! This->m_nr.lpLocalName=value; ! return 0; } ! if (strcmp(name, "lpComment")==0){ ! if (!PyWinObject_AsTCHAR(v, &value, TRUE)) ! return -1; ! PyWinObject_FreeTCHAR(This->m_nr.lpComment); ! This->m_nr.lpComment=value; ! return 0; } ! return PyObject_GenericSetAttr(self, obname, v); } *************** *** 278,296 **** if (!PyWinObject_AsNETRESOURCE(ob, &p_nr, FALSE)) // sets error exception ! return NULL; // do integer tests first ! if ((m_nr.dwType != p_nr->dwType) || ! (m_nr.dwScope != p_nr->dwScope) || ! (m_nr.dwUsage != p_nr->dwUsage) || ! (m_nr.dwDisplayType != p_nr->dwDisplayType)) ! return (0); ! ! if ((_tcscmp(szComment, GetComment())) || ! (_tcscmp(szLName, GetLName())) || ! (_tcscmp(szProv, GetProvider())) || ! (_tcscmp(szRName, GetRName()))) ! return 0; ! return 1; }; --- 249,289 ---- if (!PyWinObject_AsNETRESOURCE(ob, &p_nr, FALSE)) // sets error exception ! return -1; // do integer tests first ! if (m_nr.dwType != p_nr->dwType || ! m_nr.dwScope != p_nr->dwScope || ! m_nr.dwUsage != p_nr->dwUsage || ! m_nr.dwDisplayType != p_nr->dwDisplayType) ! return 1; ! if (m_nr.lpComment && p_nr->lpComment){ ! if (_tcscmp(m_nr.lpComment, p_nr->lpComment) != 0) ! return 1; ! } ! else if (m_nr.lpComment || p_nr->lpComment) ! return 1; ! ! if (m_nr.lpLocalName && p_nr->lpLocalName){ ! if (_tcscmp(m_nr.lpLocalName, p_nr->lpLocalName) != 0) ! return 1; ! } ! else if (m_nr.lpLocalName || p_nr->lpLocalName) ! return 1; ! ! if (m_nr.lpProvider && p_nr->lpProvider){ ! if (_tcscmp(m_nr.lpProvider, p_nr->lpProvider) != 0) ! return 1; ! } ! else if (m_nr.lpProvider || p_nr->lpProvider) ! return 1; ! ! if (m_nr.lpRemoteName && p_nr->lpRemoteName){ ! if (_tcscmp(m_nr.lpRemoteName, p_nr->lpRemoteName) != 0) ! return 1; ! } ! else if (m_nr.lpRemoteName || p_nr->lpRemoteName) ! return 1; ! ! return 0; }; Index: PyNCB.h =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/src/win32wnet/PyNCB.h,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** PyNCB.h 28 Mar 2000 11:34:29 -0000 1.2 --- PyNCB.h 10 Dec 2008 11:13:51 -0000 1.3 *************** *** 33,45 **** static void deallocFunc(PyObject *ob); ! static PyObject *getattr(PyObject *self, char *name); ! static int setattr(PyObject *self, char *name, PyObject *v); ! ! ! #pragma warning( disable : 4251 ) ! static struct memberlist memberlist[]; ! #pragma warning( default : 4251 ) - NCB m_ncb; DWORD dwStatus; // status of this object (used during copy construct) --- 33,41 ---- static void deallocFunc(PyObject *ob); ! static PyObject *getattro(PyObject *self, PyObject *obname); ! static int setattro(PyObject *self, PyObject *obname, PyObject *v); ! static struct PyMemberDef members[]; ! static struct PyMethodDef methods[]; NCB m_ncb; DWORD dwStatus; // status of this object (used during copy construct) *************** *** 51,56 **** #define PyNCB_Check(ob) ((ob)->ob_type == &PyNCBType) - __declspec(dllexport) PyObject *PyWinMethod_NewNCB(PyObject *self, PyObject *args); - - #endif // end of _WIN32_WCE exclude --- 47,49 ---- Index: PyNCB.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/src/win32wnet/PyNCB.cpp,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** PyNCB.cpp 3 Dec 2008 22:34:21 -0000 1.5 --- PyNCB.cpp 10 Dec 2008 11:13:51 -0000 1.6 *************** *** 37,40 **** --- 37,51 ---- #include <crtdbg.h> + /*************************************************************************** + ** Create a new NCB Object + ***************************************************************************/ + static PyObject *NCB_new(PyTypeObject *type, PyObject *args, PyObject *kwds) + { + static char *kwlist[] = {0}; + if (!PyArg_ParseTupleAndKeywords(args, kwds, ":NCB", kwlist)) // no arguments + return NULL; + return new PyNCB(); // call the C++ constructor + } + __declspec(dllexport)PyTypeObject PyNCBType = *************** *** 46,52 **** PyNCB::deallocFunc, /* tp_dealloc */ 0, /* tp_print */ ! PyNCB::getattr, /* tp_getattr */ ! PyNCB::setattr, /* tp_setattr */ ! // PyNCB::compareFunc, /* tp_compare */ 0, /* tp_repr */ 0, /* tp_as_number */ --- 57,63 ---- PyNCB::deallocFunc, /* tp_dealloc */ 0, /* tp_print */ ! 0, /* tp_getattr */ ! 0, /* tp_setattr */ ! 0, /* tp_compare */ 0, /* tp_repr */ 0, /* tp_as_number */ *************** *** 56,59 **** --- 67,92 ---- 0, /* tp_call */ 0, /* tp_str */ + PyNCB::getattro, /* tp_getattro */ + PyNCB::setattro, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT, /* tp_flags */ + 0, /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + PyNCB::methods, /* tp_methods */ + PyNCB::members, /* tp_members */ + 0, /* tp_getset */ + 0, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + 0, /* tp_init */ + 0, /* tp_alloc */ + NCB_new, /* tp_new */ }; *************** *** 68,72 **** } ! static struct PyMethodDef PyUnicode_methods[] = { { "Reset", PyNCB_Reset, METH_VARARGS }, { NULL }, --- 101,105 ---- } ! struct PyMethodDef PyNCB::methods[] = { { "Reset", PyNCB_Reset, METH_VARARGS }, { NULL }, *************** *** 75,79 **** // @object NCB|A Python object that encapsulates a Win32 NCB structure. #define OFF(e) offsetof(PyNCB, e) ! struct memberlist PyNCB::memberlist[] = { {"Command", T_UBYTE, OFF(m_ncb.ncb_command), 0}, // @prop int|Command| --- 108,112 ---- // @object NCB|A Python object that encapsulates a Win32 NCB structure. #define OFF(e) offsetof(PyNCB, e) ! struct PyMemberDef PyNCB::members[] = { {"Command", T_UBYTE, OFF(m_ncb.ncb_command), 0}, // @prop int|Command| *************** *** 171,189 **** }; - /*************************************************************************** - ** Create a new NCB Object - ***************************************************************************/ - // @pymethod <o NCB>|win32wnet|NCB|Creates a new <o NCB> object. - PyObject *PyWinMethod_NewNCB(PyObject *self, PyObject *args) - { - if (!PyArg_ParseTuple(args, ":NCB")) // no arguments - return NULL; - return new PyNCB(); // call the C++ constructor - } - /*********************************************************************/ ! PyObject *PyNCB::getattr(PyObject *self, char *name) { PyNCB *This = (PyNCB *)self; if (strcmp(name, "Callname") == 0) // these "strings" are not null terminated so build // a local representation of them and return --- 204,217 ---- }; /*********************************************************************/ ! PyObject *PyNCB::getattro(PyObject *self, PyObject *obname) { PyNCB *This = (PyNCB *)self; + char *name=PYWIN_ATTR_CONVERT(obname); + if (name==NULL) + return NULL; + // Our string attributes still need special handling as the NCB isn't + // unicode aware. + // These 2 string attributes are logically "strings" rather than "bytes" if (strcmp(name, "Callname") == 0) // these "strings" are not null terminated so build // a local representation of them and return *************** *** 192,196 **** char TempString[17]; TempString[16] = '\0'; ! return(PyString_FromString(strncpy((char *)TempString,(char *)This->m_ncb.ncb_callname,NCBNAMSZ))); } else if(strcmp(name, "Name") == 0) --- 220,224 ---- char TempString[17]; TempString[16] = '\0'; ! return(PyWinCoreString_FromString(strncpy((char *)TempString,(char *)This->m_ncb.ncb_callname,NCBNAMSZ))); } else if(strcmp(name, "Name") == 0) *************** *** 198,205 **** char TempString[17]; TempString[16] = '\0'; ! return(PyString_FromString(strncpy((char *)TempString,(char *)This->m_ncb.ncb_name,NCBNAMSZ))); } else if(strcmp(name, "Buffer") == 0) { if (This->m_obuserbuffer != NULL) { Py_INCREF(This->m_obuserbuffer); --- 226,234 ---- char TempString[17]; TempString[16] = '\0'; ! return(PyWinCoreString_FromString(strncpy((char *)TempString,(char *)This->m_ncb.ncb_name,NCBNAMSZ))); } else if(strcmp(name, "Buffer") == 0) { + // This is logically bytes if (This->m_obuserbuffer != NULL) { Py_INCREF(This->m_obuserbuffer); *************** *** 212,227 **** return PyBuffer_FromMemory(This->m_ncb.ncb_buffer, This->m_ncb.ncb_length); } ! else { ! PyObject *ret = PyMember_Get((char *)self, memberlist, name); ! if (ret==NULL) { ! PyErr_Clear(); ! ret = Py_FindMethod(PyUnicode_methods, self, name); ! } ! return ret; ! } }; /********************************************************************/ ! int PyNCB::setattr(PyObject *self, char *name, PyObject *v) { if (v == NULL) { --- 241,249 ---- return PyBuffer_FromMemory(This->m_ncb.ncb_buffer, This->m_ncb.ncb_length); } ! return PyObject_GenericGetAttr(self, obname); }; /********************************************************************/ ! int PyNCB::setattro(PyObject *self, PyObject *obname, PyObject *v) { if (v == NULL) { *************** *** 229,308 **** return -1; } ! // the following specific string attributes can be set ! if (PyString_Check(v)) ! { ! PyNCB *This = (PyNCB *)self; ! ! if (strcmp(name, "Callname") == 0) ! { ! int srclen = lstrlenA(PyString_AsString(v)); ! if (srclen > NCBNAMSZ) // cap string length at NCBNAMSZ(16) ! srclen = NCBNAMSZ; ! memset (This->m_ncb.ncb_callname, ' ', NCBNAMSZ); // make sure that the name is space padded ! strncpy ((char *)This->m_ncb.ncb_callname, PyString_AsString(v), srclen); ! if (srclen == 0) // source was null string ! This->m_ncb.ncb_callname[0] = '\0'; ! return 0; } - else - if (strcmp(name, "Name") == 0) - { - int srclen = lstrlenA(PyString_AsString(v)); - if (srclen > NCBNAMSZ) - srclen = NCBNAMSZ; ! memset (This->m_ncb.ncb_name, ' ', NCBNAMSZ); ! strncpy ((char *)This->m_ncb.ncb_name, PyString_AsString(v), srclen); ! if (srclen == 0) // source was null string ! This->m_ncb.ncb_callname[0] = '\0'; ! return 0; } - } // PyString_Check if (strcmp(name, "Buffer") == 0) { PyNCB *This = (PyNCB *)self; ! PyObject *ob_buf = v; ! if (PyInstance_Check(v)) { ! ob_buf = PyObject_GetAttrString(v, "_buffer_"); ! if (ob_buf==NULL) { ! PyErr_Clear(); ! PyErr_SetString(PyExc_TypeError, "The instance must have a _buffer_ attribute"); ! return -1; } ! } ! PyBufferProcs *pb = ob_buf->ob_type->tp_as_buffer; ! if ( pb == NULL || pb->bf_getwritebuffer == NULL || ! pb->bf_getsegcount == NULL ) { ! PyErr_SetString(PyExc_TypeError, "The object must support the write-buffer interface"); ! return -1; ! } ! if ( (*pb->bf_getsegcount)(ob_buf, NULL) != 1 ) { ! PyErr_SetString(PyExc_TypeError, "The object must be a single-segment write-buffer"); return -1; ! } ! This->m_ncb.ncb_length = pb->bf_getwritebuffer(ob_buf, 0, (void **)&This->m_ncb.ncb_buffer); ! if (This->m_ncb.ncb_length==-1) { ! This->m_ncb.ncb_length = 0; return -1; ! } Py_XDECREF(This->m_obbuffer); Py_XDECREF(This->m_obuserbuffer); - This->m_obbuffer = ob_buf; - Py_INCREF(ob_buf); - This->m_obuserbuffer = v; Py_INCREF(v); ! if (ob_buf != v) ! Py_DECREF(ob_buf); // for the temp refcount from the GetAttrString return 0; } ! ! ! ! return PyMember_Set((char *)self, memberlist, name, v); } --- 251,323 ---- return -1; } + char *name=PYWIN_ATTR_CONVERT(obname); + if (name==NULL) + return NULL; + PyNCB *This = (PyNCB *)self; ! if (strcmp(name, "Callname") == 0){ ! char *value; ! DWORD valuelen; ! if (!PyWinObject_AsString(v, &value, FALSE, &valuelen)) ! return -1; ! if (valuelen > NCBNAMSZ) // cap string length at NCBNAMSZ(16) ! valuelen = NCBNAMSZ; ! memset (This->m_ncb.ncb_callname, ' ', NCBNAMSZ); // make sure that the name is space padded ! strncpy ((char *)This->m_ncb.ncb_callname, value, valuelen); ! if (valuelen == 0) // source was null string ! This->m_ncb.ncb_callname[0] = '\0'; ! PyWinObject_FreeString(value); ! return 0; } ! if (strcmp(name, "Name") == 0){ ! char *value; ! DWORD valuelen; ! if (!PyWinObject_AsString(v, &value, FALSE, &valuelen)) ! return -1; ! if (valuelen > NCBNAMSZ) // cap string length at NCBNAMSZ(16) ! valuelen = NCBNAMSZ; ! memset (This->m_ncb.ncb_name, ' ', NCBNAMSZ); ! strncpy ((char *)This->m_ncb.ncb_name, value, valuelen); ! if (valuelen == 0) // source was null string ! This->m_ncb.ncb_callname[0] = '\0'; ! PyWinObject_FreeString(value); ! return 0; } if (strcmp(name, "Buffer") == 0) { PyNCB *This = (PyNCB *)self; ! PyObject *ob_buf = PyObject_GetAttrString(v, "_buffer_"); ! if (ob_buf==NULL){ ! PyErr_Clear(); ! ob_buf=v; ! Py_INCREF(ob_buf); } ! ! void *buf; ! DWORD buflen; ! if (!PyWinObject_AsWriteBuffer(ob_buf, &buf, &buflen)){ ! Py_DECREF(ob_buf); return -1; ! } ! if (buflen > USHRT_MAX){ ! Py_DECREF(ob_buf); ! PyErr_Format(PyExc_ValueError, "Buffer can be at most %d bytes", USHRT_MAX); return -1; ! } Py_XDECREF(This->m_obbuffer); + This->m_obbuffer=ob_buf; Py_XDECREF(This->m_obuserbuffer); Py_INCREF(v); ! This->m_obuserbuffer=v; ! This->m_ncb.ncb_length = (WORD)buflen; ! This->m_ncb.ncb_buffer = (PUCHAR)buf; return 0; } ! return PyObject_GenericSetAttr(self, obname, v); } Index: Netres.h =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/src/win32wnet/Netres.h,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** Netres.h 19 Apr 2006 03:15:10 -0000 1.2 --- Netres.h 10 Dec 2008 11:13:51 -0000 1.3 *************** *** 30,37 **** public: NETRESOURCE *GetNetresource() {return &m_nr;} - LPTSTR GetComment() {return szComment;} - LPTSTR GetLName() {return szLName;} - LPTSTR GetRName() {return szRName;} - LPTSTR GetProvider() {return szProv;} PyNETRESOURCE(void); --- 30,33 ---- *************** *** 43,66 **** static void deallocFunc(PyObject *ob); ! static PyObject *getattr(PyObject *self, char *name); ! static int setattr(PyObject *self, char *name, PyObject *v); static int compareFunc(PyObject *ob1, PyObject *ob2); ! ! ! #pragma warning( disable : 4251 ) ! static struct memberlist memberlist[]; ! #pragma warning( default : 4251 ) protected: ! /* NETRESOURCE contains pointer to strings (LPTSTR) to four items. we are ! copying the values to strings local to each NETRESOURCE instance, thereby keeping ! each NETRESOURCE object self contained. Note that the NETRESOURCE Object's ! strings are not Python Strings!*/ ! ! NETRESOURCE m_nr; ! TCHAR szLName[MAX_NAME]; // length?? ! TCHAR szRName[MAX_NAME]; // probably overkill ! TCHAR szProv[MAX_NAME]; ! TCHAR szComment[MAX_COMMENT]; }; --- 39,52 ---- static void deallocFunc(PyObject *ob); ! static PyObject *getattro(PyObject *self, PyObject *obname); ! static int setattro(PyObject *self, PyObject *obname, PyObject *v); static int compareFunc(PyObject *ob1, PyObject *ob2); ! static struct PyMemberDef members[]; protected: ! /* NETRESOURCE contains pointer to strings (LPTSTR) to four items. ! These are allocated and released by PyWinObject_AsWCHAR and PyWinObject_FreeWCHAR ! */ ! NETRESOURCE m_nr; }; *************** *** 68,73 **** #define PyNETRESOURCE_Check(ob) ((ob)->ob_type == &PyNETRESOURCEType) - __declspec(dllexport) PyObject *PyWinMethod_NewNETRESOURCE(PyObject *self, PyObject *args); __declspec(dllexport) BOOL PyWinObject_AsNETRESOURCE(PyObject *ob, NETRESOURCE **ppNetresource, BOOL bNoneOK = TRUE); __declspec(dllexport) PyObject *PyWinObject_FromNETRESOURCE(const NETRESOURCE *pNetresource); - --- 54,57 ---- |
From: Mark H. <mha...@us...> - 2008-12-10 11:13:56
|
Update of /cvsroot/pywin32/pywin32/win32/Lib In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv9900/win32/Lib Modified Files: netbios.py Log Message: Modernization of win32wnet, via the py3k branch: * Move to getattro/setattro * Add support for WNetAddConnection2 taking a NETRESOURCE as the first param. * Add tp_new slots for the type, so the type can be used in-place of global functions. * Replace NCB and NETRESOURCE methods with the actual types. * Treat CallName and Name attributes as true strings. * Many more tests. Index: netbios.py =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/Lib/netbios.py,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** netbios.py 27 Nov 2008 06:40:00 -0000 1.6 --- netbios.py 10 Dec 2008 11:13:51 -0000 1.7 *************** *** 1,2 **** --- 1,3 ---- + import sys import win32wnet import struct *************** *** 257,260 **** --- 258,268 ---- return NCBStruct(ACTION_HEADER_ITEMS) + def byte_to_int(b): + """Given an element in a binary buffer, return its integer value""" + if sys.version_info >= (3,0): + # a byte is already an int in py3k + return b + return ord(b) # its a char from a string in py2k. + if __name__=='__main__': # code ported from "HOWTO: Get the MAC Address for an Ethernet Adapter" *************** *** 269,279 **** ncb.Reset() ncb.Command = NCBRESET ! ncb.Lana_num = ord(la_enum.lana[i]) rc = Netbios(ncb) if rc != 0: raise RuntimeError("Unexpected result %d" % (rc,)) ncb.Reset() ncb.Command = NCBASTAT ! ncb.Lana_num = ord(la_enum.lana[i]) ! ncb.Callname = "* " adapter = ADAPTER_STATUS() ncb.Buffer = adapter --- 277,287 ---- ncb.Reset() ncb.Command = NCBRESET ! ncb.Lana_num = byte_to_int(la_enum.lana[i]) rc = Netbios(ncb) if rc != 0: raise RuntimeError("Unexpected result %d" % (rc,)) ncb.Reset() ncb.Command = NCBASTAT ! ncb.Lana_num = byte_to_int(la_enum.lana[i]) ! ncb.Callname = "* ".encode("ascii") # ensure bytes on py2x and 3k adapter = ADAPTER_STATUS() ncb.Buffer = adapter *************** *** 281,284 **** print "Adapter address:", for ch in adapter.adapter_address: ! print "%02x" % (ord(ch),) , print --- 289,292 ---- print "Adapter address:", for ch in adapter.adapter_address: ! print "%02x" % (byte_to_int(ch),) , print |
From: Mark H. <mha...@us...> - 2008-12-10 11:01:28
|
Update of /cvsroot/pywin32/pywin32/win32/test In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv8712/test Modified Files: Tag: py3k test_win32wnet.py Log Message: * re-instate b/w compatible arg list for WNetAddConnection2 * Add tp_new slots for the type, so the type can be used in-place of global functions. * Replace NCB and NETRESOURCE methods with the actual types. * Treat CallName and Name attributes as true strings. * Many more tests. Index: test_win32wnet.py =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/test/test_win32wnet.py,v retrieving revision 1.1 retrieving revision 1.1.4.1 diff -C2 -d -r1.1 -r1.1.4.1 *** test_win32wnet.py 2 Jul 2003 04:07:37 -0000 1.1 --- test_win32wnet.py 10 Dec 2008 11:01:22 -0000 1.1.4.1 *************** *** 1,4 **** import unittest ! import win32wnet, win32api class TestCase(unittest.TestCase): --- 1,51 ---- import unittest ! import win32wnet ! import win32api ! import netbios ! ! RESOURCE_CONNECTED = 0x00000001 ! RESOURCE_GLOBALNET = 0x00000002 ! RESOURCE_REMEMBERED = 0x00000003 ! RESOURCE_RECENT = 0x00000004 ! RESOURCE_CONTEXT = 0x00000005 ! RESOURCETYPE_ANY = 0x00000000 ! RESOURCETYPE_DISK = 0x00000001 ! RESOURCETYPE_PRINT = 0x00000002 ! RESOURCETYPE_RESERVED = 0x00000008 ! RESOURCETYPE_UNKNOWN = 0xFFFFFFFF ! RESOURCEUSAGE_CONNECTABLE = 0x00000001 ! RESOURCEUSAGE_CONTAINER = 0x00000002 ! RESOURCEDISPLAYTYPE_GENERIC = 0x00000000 ! RESOURCEDISPLAYTYPE_DOMAIN = 0x00000001 ! RESOURCEDISPLAYTYPE_SERVER = 0x00000002 ! RESOURCEDISPLAYTYPE_SHARE = 0x00000003 ! ! ! NETRESOURCE_attributes = [ ! ("dwScope", int), ! ("dwType", int), ! ("dwDisplayType", int), ! ("dwUsage", int), ! ("lpLocalName", str), ! ("lpRemoteName", str), ! ("lpComment", str), ! ("lpProvider", str), ! ] ! ! NCB_attributes = [ ! ("Command", int), ! ("Retcode", int), ! ("Lsn", int), ! ("Num", int), ! # ("Bufflen", int), - read-only ! ("Callname", str), ! ("Name", str), ! ("Rto", int), ! ("Sto", int), ! ("Lana_num", int), ! ("Cmd_cplt", int), ! ("Event", int), ! ("Post", int), ! ] class TestCase(unittest.TestCase): *************** *** 6,9 **** --- 53,169 ---- self.assertEquals(win32api.GetUserName(), win32wnet.WNetGetUser()) + def _checkItemAttributes(self, item, attrs): + for attr, typ in attrs: + val = getattr(item, attr) + if typ is int: + self.failUnless(type(val) in (int, int), + "Attr %r has value %r" % (attr, val)) + new_val = val + 1 + elif typ is str: + if val is not None: + # on py2k, must be string or unicode. py3k must be string or bytes. + self.failUnless(type(val) in (str, str), + "Attr %r has value %r" % (attr, val)) + new_val = val + " new value" + else: + new_val = "new value" + else: + self.fail("Don't know what %s is" % (typ,)) + # set the attribute just to make sure we can. + setattr(item, attr, new_val) + + def testNETRESOURCE(self): + nr = win32wnet.NETRESOURCE() + self._checkItemAttributes(nr, NETRESOURCE_attributes) + + def testWNetEnumResource(self): + handle = win32wnet.WNetOpenEnum(RESOURCE_GLOBALNET, RESOURCETYPE_ANY, + 0, None) + try: + while 1: + items = win32wnet.WNetEnumResource(handle, 0) + if len(items)==0: + break + for item in items: + self._checkItemAttributes(item, NETRESOURCE_attributes) + finally: + handle.Close() + + def testNCB(self): + ncb = win32wnet.NCB() + self._checkItemAttributes(ncb, NCB_attributes) + + def testNetbios(self): + # taken from the demo code in netbios.py + ncb = win32wnet.NCB() + ncb.Command = netbios.NCBENUM + la_enum = netbios.LANA_ENUM() + ncb.Buffer = la_enum + rc = win32wnet.Netbios(ncb) + self.failUnlessEqual(rc, 0) + for i in range(la_enum.length): + ncb.Reset() + ncb.Command = netbios.NCBRESET + ncb.Lana_num = netbios.byte_to_int(la_enum.lana[i]) + rc = Netbios(ncb) + self.failUnlessEqual(rc, 0) + ncb.Reset() + ncb.Command = netbios.NCBASTAT + ncb.Lana_num = byte_to_int(la_enum.lana[i]) + ncb.Callname = "* ".encode("ascii") # ensure bytes on py2x and 3k + adapter = netbios.ADAPTER_STATUS() + ncb.Buffer = adapter + Netbios(ncb) + # expect 6 bytes in the mac address. + self.failUnless(len(adapter.adapter_address), 6) + + def iterConnectableShares(self): + nr = win32wnet.NETRESOURCE() + nr.dwScope = RESOURCE_GLOBALNET + nr.dwUsage = RESOURCEUSAGE_CONTAINER + nr.lpRemoteName = "\\\\" + win32api.GetComputerName() + + handle = win32wnet.WNetOpenEnum(RESOURCE_GLOBALNET, RESOURCETYPE_ANY, + 0, nr) + while 1: + items = win32wnet.WNetEnumResource(handle, 0) + if len(items)==0: + break + for item in items: + if item.dwDisplayType == RESOURCEDISPLAYTYPE_SHARE: + yield item + + def findUnusedDriveLetter(self): + existing = [x[0].lower() for x in win32api.GetLogicalDriveStrings().split('\0') if x] + handle = win32wnet.WNetOpenEnum(RESOURCE_REMEMBERED,RESOURCETYPE_DISK,0,None) + try: + while 1: + items = win32wnet.WNetEnumResource(handle, 0) + if len(items)==0: + break + xtra = [i.lpLocalName[0].lower() for i in items if i.lpLocalName] + existing.extend(xtra) + finally: + handle.Close() + for maybe in 'defghijklmnopqrstuvwxyz': + if maybe not in existing: + return maybe + self.fail("All drive mappings are taken?") + + def testAddConnection(self): + localName = self.findUnusedDriveLetter() + ':' + for share in self.iterConnectableShares(): + share.lpLocalName = localName + win32wnet.WNetAddConnection2(share) + win32wnet.WNetCancelConnection2(localName, 0, 0) + break + + def testAddConnectionOld(self): + localName = self.findUnusedDriveLetter() + ':' + for share in self.iterConnectableShares(): + win32wnet.WNetAddConnection2(share.dwType, localName, share.lpRemoteName) + win32wnet.WNetCancelConnection2(localName, 0, 0) + break + if __name__ == '__main__': |
From: Mark H. <mha...@us...> - 2008-12-10 11:01:28
|
Update of /cvsroot/pywin32/pywin32/win32/src/win32wnet In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv8712/src/win32wnet Modified Files: Tag: py3k Netres.h PyNCB.cpp PyNCB.h PyNetresource.cpp win32wnet.cpp Log Message: * re-instate b/w compatible arg list for WNetAddConnection2 * Add tp_new slots for the type, so the type can be used in-place of global functions. * Replace NCB and NETRESOURCE methods with the actual types. * Treat CallName and Name attributes as true strings. * Many more tests. Index: win32wnet.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/src/win32wnet/win32wnet.cpp,v retrieving revision 1.13.2.2 retrieving revision 1.13.2.3 diff -C2 -d -r1.13.2.2 -r1.13.2.3 *** win32wnet.cpp 9 Dec 2008 12:38:52 -0000 1.13.2.2 --- win32wnet.cpp 10 Dec 2008 11:01:22 -0000 1.13.2.3 *************** *** 129,134 **** // @pymethod |win32wnet|WNetAddConnection2|Creates a connection to a network resource. The function can redirect // a local device to the network resource. ! // @comm This function previously accepted separate parameters to construct a <o PyNETRESOURCE>. It has been ! // changed to accept a NETRESOURCE object instead of the individual elements. // @comm Accepts keyword arguments. // @pyseeapi WNetAddConnection2 --- 129,134 ---- // @pymethod |win32wnet|WNetAddConnection2|Creates a connection to a network resource. The function can redirect // a local device to the network resource. ! // @comm This function also accepts backwards-compatible, positional-only ! // arguments of (dwType, lpLocalName, lpRemoteName[, lpProviderName, Username, Password, flags]) // @comm Accepts keyword arguments. // @pyseeapi WNetAddConnection2 *************** *** 136,171 **** { LPTSTR Username = NULL; ! LPTSTR Password = NULL; PyObject *obnr, *obPassword=Py_None, *obUsername=Py_None, *ret=NULL; DWORD ErrorNo; // holds the returned error number, if any DWORD flags = 0; ! NETRESOURCE * pNetResource; ! static char *keywords[] = {"NetResource","Password","UserName","Flags", NULL}; ! if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O|OOk", keywords, ! &obnr, // @pyparm <o PyNETRESOURCE>|NetResource||Describes the network resource for the connection. ! &obPassword, // @pyparm str|Password|None|The password to use. Use None for default credentials. ! &obUsername, // @pyparm str|UserName|None|The user name to connect as. Use None for default credentials. ! &flags)) // @pyparm int|Flags|0|Combination win32netcon.CONNECT_* flags ! return NULL; ! if (PyWinObject_AsNETRESOURCE(obnr, &pNetResource, FALSE) ! && PyWinObject_AsTCHAR(obPassword, &Password, TRUE) ! && PyWinObject_AsTCHAR(obUsername, &Username, TRUE)){ ! Py_BEGIN_ALLOW_THREADS ! #ifdef _WIN32_WCE_ // Windows CE only has the #3 version...use NULL for HWND to simulate #2 ! ErrorNo = WNetAddConnection3(NULL, pNetResource, Password, Username, flags); ! #else ! ErrorNo = WNetAddConnection2(pNetResource, Password, Username, flags); ! #endif ! Py_END_ALLOW_THREADS ! if (ErrorNo != NO_ERROR) ! ReturnNetError("WNetAddConnection2", ErrorNo); ! else{ ! Py_INCREF(Py_None); ! ret = Py_None; ! } ! } PyWinObject_FreeTCHAR(Password); PyWinObject_FreeTCHAR(Username); return ret; }; --- 136,196 ---- { LPTSTR Username = NULL; ! LPTSTR Password = NULL; ! // values used for b/w compat args. ! DWORD Type; ! PyObject *obLocalName, *obRemoteName, *obProviderName = Py_None; ! PyObject *obnr, *obPassword=Py_None, *obUsername=Py_None, *ret=NULL; DWORD ErrorNo; // holds the returned error number, if any DWORD flags = 0; ! NETRESOURCE *pNetResource; ! NETRESOURCE tempNetResource; ! memset(&tempNetResource, 0, sizeof(tempNetResource)); ! if (PyArg_ParseTuple(args,"iOO|OOOi",&Type,&obLocalName,&obRemoteName,&obProviderName,&obUsername,&obPassword, &flags)) { ! // the b/w compat args have been used - build the NETRESOURCE structure ! memset((void *)&tempNetResource, '\0', sizeof(NETRESOURCE)); ! tempNetResource.dwType = Type; ! if (!PyWinObject_AsTCHAR(obLocalName, &tempNetResource.lpLocalName, TRUE) ! || !PyWinObject_AsTCHAR(obRemoteName, &tempNetResource.lpRemoteName, FALSE) ! || !PyWinObject_AsTCHAR(obProviderName, &tempNetResource.lpProvider, TRUE)) ! goto done; ! pNetResource = &tempNetResource; ! } else { ! PyErr_Clear(); ! static char *keywords[] = {"NetResource","Password","UserName","Flags", NULL}; ! if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O|OOk", keywords, ! &obnr, // @pyparm <o PyNETRESOURCE>|NetResource||Describes the network resource for the connection. ! &obPassword, // @pyparm str|Password|None|The password to use. Use None for default credentials. ! &obUsername, // @pyparm str|UserName|None|The user name to connect as. Use None for default credentials. ! &flags)) // @pyparm int|Flags|0|Combination win32netcon.CONNECT_* flags ! return NULL; ! if (!PyWinObject_AsNETRESOURCE(obnr, &pNetResource, FALSE)) ! return NULL; ! } ! ! if (!PyWinObject_AsTCHAR(obPassword, &Password, TRUE) ! || !PyWinObject_AsTCHAR(obUsername, &Username, TRUE)) ! goto done; ! ! Py_BEGIN_ALLOW_THREADS ! #ifdef _WIN32_WCE_ // Windows CE only has the #3 version...use NULL for HWND to simulate #2 ! ErrorNo = WNetAddConnection3(NULL, pNetResource, Password, Username, flags); ! #else ! ErrorNo = WNetAddConnection2(pNetResource, Password, Username, flags); ! #endif ! Py_END_ALLOW_THREADS ! if (ErrorNo != NO_ERROR) ! ReturnNetError("WNetAddConnection2", ErrorNo); ! else{ ! Py_INCREF(Py_None); ! ret = Py_None; ! } ! done: PyWinObject_FreeTCHAR(Password); PyWinObject_FreeTCHAR(Username); + PyWinObject_FreeTCHAR(tempNetResource.lpLocalName); + PyWinObject_FreeTCHAR(tempNetResource.lpRemoteName); + PyWinObject_FreeTCHAR(tempNetResource.lpProvider); return ret; }; *************** *** 601,608 **** // @module win32wnet|A module that exposes the Windows Networking API. static PyMethodDef win32wnet_functions[] = { ! // @pymeth NETRESOURCE|Creates a new <o NETRESOURCE> object ! {"NETRESOURCE", PyWinMethod_NewNETRESOURCE, 1, "NETRESOURCE Structure Object. x=NETRESOURCE() to instantiate"}, ! // @pymeth NCB|Creates a new <o NCB> object ! {"NCB", PyWinMethod_NewNCB, 1, "NCB Netbios command structure Object"}, // @pymeth NCBBuffer|Creates a new buffer {"NCBBuffer", PyWinMethod_NCBBuffer, 1, "Creates a memory buffer"}, --- 626,631 ---- // @module win32wnet|A module that exposes the Windows Networking API. static PyMethodDef win32wnet_functions[] = { ! // @pymeth NETRESOURCE|The <o PyNETRESOURCE> type - can be used to create a new <o PyNETRESOURCE> object. ! // @pymeth NCB|The <o PyNCB> type - can be used to create a new <o PyNCB> object. // @pymeth NCBBuffer|Creates a new buffer {"NCBBuffer", PyWinMethod_NCBBuffer, 1, "Creates a memory buffer"}, *************** *** 637,641 **** "A module that exposes the Windows Networking API."); - PyDict_SetItemString(dict, "error", PyWinExc_ApiError); --- 660,663 ---- *************** *** 644,650 **** --- 666,676 ---- PYWIN_MODULE_INIT_RETURN_ERROR; + // old "deprecated" names, before types could create instances. PyDict_SetItemString(dict, "NETRESOURCEType", (PyObject *)&PyNETRESOURCEType); PyDict_SetItemString(dict, "NCBType", (PyObject *)&PyNCBType); + PyDict_SetItemString(dict, "NETRESOURCE", (PyObject *)&PyNETRESOURCEType); + PyDict_SetItemString(dict, "NCB", (PyObject *)&PyNCBType); + PYWIN_MODULE_INIT_RETURN_SUCCESS; } Index: PyNetresource.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/src/win32wnet/PyNetresource.cpp,v retrieving revision 1.3.4.1 retrieving revision 1.3.4.2 diff -C2 -d -r1.3.4.1 -r1.3.4.2 *** PyNetresource.cpp 29 Aug 2008 05:00:24 -0000 1.3.4.1 --- PyNetresource.cpp 10 Dec 2008 11:01:22 -0000 1.3.4.2 *************** *** 36,46 **** ! /* Main PYTHON entry point for creating a new reference. Registered by win32wnet module */ ! ! // @pymethod <o PyNETRESOURCE>|win32wnet|NETRESOURCE|Creates a new <o NETRESOURCE> object. ! ! PyObject *PyWinMethod_NewNETRESOURCE(PyObject *self, PyObject *args) { ! if (!PyArg_ParseTuple(args, ":NETRESOURCE")) // no arguments return NULL; return new PyNETRESOURCE(); // call the C++ constructor --- 36,43 ---- ! static PyObject *NETRESOURCE_new(PyTypeObject *type, PyObject *args, PyObject *kwds) { ! static char *kwlist[] = {0}; ! if (!PyArg_ParseTupleAndKeywords(args, kwds, ":NETRESOURCE", kwlist)) // no arguments return NULL; return new PyNETRESOURCE(); // call the C++ constructor *************** *** 122,126 **** 0, /* tp_init */ 0, /* tp_alloc */ ! 0, /* tp_new */ }; --- 119,123 ---- 0, /* tp_init */ 0, /* tp_alloc */ ! NETRESOURCE_new, /* tp_new */ }; *************** *** 140,143 **** --- 137,144 ---- {"lpProvider", T_STRING, OFF(m_nr.lpProvider), 0},// @prop string|provider| {NULL} + // @comm Note that in pywin32-212 and earlier, the string attributes + // were always strings, but empty strings when the underlying Windows + // structure had NULL. On later pywin32 builds, these string attributes will + // return None in such cases. }; Index: PyNCB.h =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/src/win32wnet/PyNCB.h,v retrieving revision 1.2.4.1 retrieving revision 1.2.4.2 diff -C2 -d -r1.2.4.1 -r1.2.4.2 *** PyNCB.h 29 Aug 2008 05:00:24 -0000 1.2.4.1 --- PyNCB.h 10 Dec 2008 11:01:22 -0000 1.2.4.2 *************** *** 47,52 **** #define PyNCB_Check(ob) ((ob)->ob_type == &PyNCBType) - __declspec(dllexport) PyObject *PyWinMethod_NewNCB(PyObject *self, PyObject *args); - - #endif // end of _WIN32_WCE exclude --- 47,49 ---- Index: PyNCB.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/src/win32wnet/PyNCB.cpp,v retrieving revision 1.4.4.1 retrieving revision 1.4.4.2 diff -C2 -d -r1.4.4.1 -r1.4.4.2 *** PyNCB.cpp 29 Aug 2008 05:00:24 -0000 1.4.4.1 --- PyNCB.cpp 10 Dec 2008 11:01:22 -0000 1.4.4.2 *************** *** 37,40 **** --- 37,51 ---- #include <crtdbg.h> + /*************************************************************************** + ** Create a new NCB Object + ***************************************************************************/ + static PyObject *NCB_new(PyTypeObject *type, PyObject *args, PyObject *kwds) + { + static char *kwlist[] = {0}; + if (!PyArg_ParseTupleAndKeywords(args, kwds, ":NCB", kwlist)) // no arguments + return NULL; + return new PyNCB(); // call the C++ constructor + } + __declspec(dllexport)PyTypeObject PyNCBType = *************** *** 77,81 **** 0, /* tp_init */ 0, /* tp_alloc */ ! 0, /* tp_new */ }; --- 88,92 ---- 0, /* tp_init */ 0, /* tp_alloc */ ! NCB_new, /* tp_new */ }; *************** *** 193,207 **** }; - /*************************************************************************** - ** Create a new NCB Object - ***************************************************************************/ - // @pymethod <o NCB>|win32wnet|NCB|Creates a new <o NCB> object. - PyObject *PyWinMethod_NewNCB(PyObject *self, PyObject *args) - { - if (!PyArg_ParseTuple(args, ":NCB")) // no arguments - return NULL; - return new PyNCB(); // call the C++ constructor - } - /*********************************************************************/ PyObject *PyNCB::getattro(PyObject *self, PyObject *obname) --- 204,207 ---- *************** *** 211,214 **** --- 211,217 ---- if (name==NULL) return NULL; + // Our string attributes still need special handling as the NCB isn't + // unicode aware. + // These 2 string attributes are logically "strings" rather than "bytes" if (strcmp(name, "Callname") == 0) // these "strings" are not null terminated so build // a local representation of them and return *************** *** 217,221 **** char TempString[17]; TempString[16] = '\0'; ! return(PyString_FromString(strncpy((char *)TempString,(char *)This->m_ncb.ncb_callname,NCBNAMSZ))); } else if(strcmp(name, "Name") == 0) --- 220,224 ---- char TempString[17]; TempString[16] = '\0'; ! return(PyWinCoreString_FromString(strncpy((char *)TempString,(char *)This->m_ncb.ncb_callname,NCBNAMSZ))); } else if(strcmp(name, "Name") == 0) *************** *** 223,230 **** char TempString[17]; TempString[16] = '\0'; ! return(PyString_FromString(strncpy((char *)TempString,(char *)This->m_ncb.ncb_name,NCBNAMSZ))); } else if(strcmp(name, "Buffer") == 0) { if (This->m_obuserbuffer != NULL) { Py_INCREF(This->m_obuserbuffer); --- 226,234 ---- char TempString[17]; TempString[16] = '\0'; ! return(PyWinCoreString_FromString(strncpy((char *)TempString,(char *)This->m_ncb.ncb_name,NCBNAMSZ))); } else if(strcmp(name, "Buffer") == 0) { + // This is logically bytes if (This->m_obuserbuffer != NULL) { Py_INCREF(This->m_obuserbuffer); *************** *** 254,259 **** if (strcmp(name, "Callname") == 0){ char *value; ! Py_ssize_t valuelen; ! if (PyString_AsStringAndSize(v, &value, &valuelen)==-1) return -1; if (valuelen > NCBNAMSZ) // cap string length at NCBNAMSZ(16) --- 258,264 ---- if (strcmp(name, "Callname") == 0){ char *value; ! DWORD valuelen; ! ! if (!PyWinObject_AsString(v, &value, FALSE, &valuelen)) return -1; if (valuelen > NCBNAMSZ) // cap string length at NCBNAMSZ(16) *************** *** 264,267 **** --- 269,273 ---- if (valuelen == 0) // source was null string This->m_ncb.ncb_callname[0] = '\0'; + PyWinObject_FreeString(value); return 0; } *************** *** 269,274 **** if (strcmp(name, "Name") == 0){ char *value; ! Py_ssize_t valuelen; ! if (PyString_AsStringAndSize(v, &value, &valuelen)==-1) return -1; if (valuelen > NCBNAMSZ) // cap string length at NCBNAMSZ(16) --- 275,280 ---- if (strcmp(name, "Name") == 0){ char *value; ! DWORD valuelen; ! if (!PyWinObject_AsString(v, &value, FALSE, &valuelen)) return -1; if (valuelen > NCBNAMSZ) // cap string length at NCBNAMSZ(16) *************** *** 279,282 **** --- 285,289 ---- if (valuelen == 0) // source was null string This->m_ncb.ncb_callname[0] = '\0'; + PyWinObject_FreeString(value); return 0; } Index: Netres.h =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/src/win32wnet/Netres.h,v retrieving revision 1.2.4.1 retrieving revision 1.2.4.2 diff -C2 -d -r1.2.4.1 -r1.2.4.2 *** Netres.h 29 Aug 2008 05:00:24 -0000 1.2.4.1 --- Netres.h 10 Dec 2008 11:01:22 -0000 1.2.4.2 *************** *** 54,58 **** #define PyNETRESOURCE_Check(ob) ((ob)->ob_type == &PyNETRESOURCEType) - __declspec(dllexport) PyObject *PyWinMethod_NewNETRESOURCE(PyObject *self, PyObject *args); __declspec(dllexport) BOOL PyWinObject_AsNETRESOURCE(PyObject *ob, NETRESOURCE **ppNetresource, BOOL bNoneOK = TRUE); __declspec(dllexport) PyObject *PyWinObject_FromNETRESOURCE(const NETRESOURCE *pNetresource); --- 54,57 ---- |
From: Roger U. <ru...@us...> - 2008-12-10 06:36:06
|
Update of /cvsroot/pywin32/pywin32/com/win32com/client In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv18812 Modified Files: Tag: py3k combrowse.py Log Message: Don't encode object names, use key function for sorting Index: combrowse.py =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/win32com/client/combrowse.py,v retrieving revision 1.8.2.6 retrieving revision 1.8.2.7 diff -C2 -d -r1.8.2.6 -r1.8.2.7 *** combrowse.py 9 Dec 2008 13:10:15 -0000 1.8.2.6 --- combrowse.py 10 Dec 2008 06:36:01 -0000 1.8.2.7 *************** *** 50,54 **** if name is None: try: ! name = pythoncom.ProgIDFromCLSID(myobject).encode('mbcs') except pythoncom.com_error: name = str(myobject) --- 50,54 ---- if name is None: try: ! name = pythoncom.ProgIDFromCLSID(myobject) except pythoncom.com_error: name = str(myobject) *************** *** 209,213 **** if extraDescs: extraDesc = " (%s)" % ", ".join(extraDescs) ret.append(HLITypeLib(fname, "Type Library" + extraDesc)) ! ret.sort() return ret --- 209,213 ---- if extraDescs: extraDesc = " (%s)" % ", ".join(extraDescs) ret.append(HLITypeLib(fname, "Type Library" + extraDesc)) ! ret.sort(key=lambda k:k.GetText()) return ret *************** *** 263,267 **** typeinfo = typelib.GetTypeInfo(index) self.id = typeinfo.GetVarDesc(index)[0] ! name = typeinfo.GetNames(self.id)[0].encode('mbcs') HLITypeLibEntry.__init__(self, myitem, name) def GetText(self): --- 263,267 ---- typeinfo = typelib.GetTypeInfo(index) self.id = typeinfo.GetVarDesc(index)[0] ! name = typeinfo.GetNames(self.id)[0] HLITypeLibEntry.__init__(self, myitem, name) def GetText(self): *************** *** 274,278 **** for j in range(attr[7]): vdesc = typeinfo.GetVarDesc(j) ! name = typeinfo.GetNames(vdesc[0])[0].encode('mbcs') ret.append(browser.MakeHLI(vdesc[1], name)) return ret --- 274,278 ---- for j in range(attr[7]): vdesc = typeinfo.GetVarDesc(j) ! name = typeinfo.GetNames(vdesc[0])[0] ret.append(browser.MakeHLI(vdesc[1], name)) return ret *************** *** 282,286 **** typeinfo, index = myitem self.id = typeinfo.GetVarDesc(index)[0] ! name = typeinfo.GetNames(self.id)[0].encode('mbcs') HLICOM.__init__(self, myitem, name) def GetText(self): --- 282,286 ---- typeinfo, index = myitem self.id = typeinfo.GetVarDesc(index)[0] ! name = typeinfo.GetNames(self.id)[0] HLICOM.__init__(self, myitem, name) def GetText(self): *************** *** 372,376 **** typeinfo, index = myitem self.id = typeinfo.GetFuncDesc(index)[0] ! name = typeinfo.GetNames(self.id)[0].encode('mbcs') HLICOM.__init__(self, myitem, name) def GetText(self): --- 372,376 ---- typeinfo, index = myitem self.id = typeinfo.GetFuncDesc(index)[0] ! name = typeinfo.GetNames(self.id)[0] HLICOM.__init__(self, myitem, name) def GetText(self): *************** *** 402,406 **** ret.append(browser.MakeHLI(self.id, "Dispatch ID")) if len(names)>1: ! ret.append(browser.MakeHLI(", ".join(names[1:]).encode('mbcs'), "Named Params")) fd = typeinfo.GetFuncDesc(index) if fd[1]: --- 402,406 ---- ret.append(browser.MakeHLI(self.id, "Dispatch ID")) if len(names)>1: ! ret.append(browser.MakeHLI(", ".join(names[1:]), "Named Params")) fd = typeinfo.GetFuncDesc(index) if fd[1]: *************** *** 468,472 **** except pythoncom.com_error: ret.append(browser.MakeHLI("The type info can not be loaded!")) ! ret.sort() return ret --- 468,472 ---- except pythoncom.com_error: ret.append(browser.MakeHLI("The type info can not be loaded!")) ! ret.sort(key=lambda k:k.GetText()) return ret *************** *** 514,518 **** win32api.RegCloseKey(key) win32ui.DoWaitCursor(0) ! ret.sort() return ret --- 514,518 ---- win32api.RegCloseKey(key) win32ui.DoWaitCursor(0) ! ret.sort(key=lambda k:k.GetText()) return ret |
From: Mark H. <mha...@us...> - 2008-12-09 13:10:19
|
Update of /cvsroot/pywin32/pywin32/com/win32com/client In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv27465/com/win32com/client Modified Files: Tag: py3k combrowse.py gencache.py Log Message: minor import tweaks from the trunk Index: combrowse.py =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/win32com/client/combrowse.py,v retrieving revision 1.8.2.5 retrieving revision 1.8.2.6 diff -C2 -d -r1.8.2.5 -r1.8.2.6 *** combrowse.py 4 Dec 2008 05:08:41 -0000 1.8.2.5 --- combrowse.py 9 Dec 2008 13:10:15 -0000 1.8.2.6 *************** *** 25,29 **** import win32con import win32api, win32ui ! import string, sys import pythoncom from win32com.client import util --- 25,29 ---- import win32con import win32api, win32ui ! import sys import pythoncom from win32com.client import util Index: gencache.py =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/win32com/client/gencache.py,v retrieving revision 1.32.2.4 retrieving revision 1.32.2.5 diff -C2 -d -r1.32.2.4 -r1.32.2.5 *** gencache.py 27 Nov 2008 11:31:04 -0000 1.32.2.4 --- gencache.py 9 Dec 2008 13:10:15 -0000 1.32.2.5 *************** *** 49,56 **** demandGeneratedTypeLibraries = {} ! try: ! import cPickle as pickle ! except ImportError: ! import pickle def __init__(): --- 49,53 ---- demandGeneratedTypeLibraries = {} ! import pickle as pickle def __init__(): |
From: Mark H. <mha...@us...> - 2008-12-09 13:09:45
|
Update of /cvsroot/pywin32/pywin32/com/win32com/demos In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv27312/com/win32com/demos Modified Files: Tag: py3k outlookAddin.py ietoolbar.py iebutton.py excelAddin.py Log Message: corrections for 2to3 bug - _winreg->winreg Index: ietoolbar.py =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/win32com/demos/ietoolbar.py,v retrieving revision 1.1.4.5 retrieving revision 1.1.4.6 diff -C2 -d -r1.1.4.5 -r1.1.4.6 *** ietoolbar.py 4 Dec 2008 07:32:05 -0000 1.1.4.5 --- ietoolbar.py 9 Dec 2008 13:09:33 -0000 1.1.4.6 *************** *** 284,289 **** try: print("Trying to register Toolbar.\n") ! hkey = winreg.CreateKey( _winreg.HKEY_LOCAL_MACHINE, "SOFTWARE\\Microsoft\\Internet Explorer\\Toolbar" ) ! subKey = winreg.SetValueEx( hkey, comclass._reg_clsid_, 0, _winreg.REG_BINARY, "\0" ) except WindowsError: print("Couldn't set registry value.\nhkey: %d\tCLSID: %s\n" % ( hkey, comclass._reg_clsid_ )) --- 284,289 ---- try: print("Trying to register Toolbar.\n") ! hkey = winreg.CreateKey( winreg.HKEY_LOCAL_MACHINE, "SOFTWARE\\Microsoft\\Internet Explorer\\Toolbar" ) ! subKey = winreg.SetValueEx( hkey, comclass._reg_clsid_, 0, winreg.REG_BINARY, "\0" ) except WindowsError: print("Couldn't set registry value.\nhkey: %d\tCLSID: %s\n" % ( hkey, comclass._reg_clsid_ )) *************** *** 299,303 **** try: print("Trying to unregister Toolbar.\n") ! hkey = winreg.CreateKey( _winreg.HKEY_LOCAL_MACHINE, "SOFTWARE\\Microsoft\\Internet Explorer\\Toolbar" ) winreg.DeleteValue( hkey, comclass._reg_clsid_ ) except WindowsError: --- 299,303 ---- try: print("Trying to unregister Toolbar.\n") ! hkey = winreg.CreateKey( winreg.HKEY_LOCAL_MACHINE, "SOFTWARE\\Microsoft\\Internet Explorer\\Toolbar" ) winreg.DeleteValue( hkey, comclass._reg_clsid_ ) except WindowsError: Index: excelAddin.py =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/win32com/demos/excelAddin.py,v retrieving revision 1.1.4.2 retrieving revision 1.1.4.3 diff -C2 -d -r1.1.4.2 -r1.1.4.3 *** excelAddin.py 4 Dec 2008 07:32:05 -0000 1.1.4.2 --- excelAddin.py 9 Dec 2008 13:09:33 -0000 1.1.4.3 *************** *** 117,131 **** def RegisterAddin(klass): import winreg ! key = winreg.CreateKey(_winreg.HKEY_CURRENT_USER, "Software\\Microsoft\\Office\\Excel\\Addins") subkey = winreg.CreateKey(key, klass._reg_progid_) ! winreg.SetValueEx(subkey, "CommandLineSafe", 0, _winreg.REG_DWORD, 0) ! winreg.SetValueEx(subkey, "LoadBehavior", 0, _winreg.REG_DWORD, 3) ! winreg.SetValueEx(subkey, "Description", 0, _winreg.REG_SZ, "Excel Addin") ! winreg.SetValueEx(subkey, "FriendlyName", 0, _winreg.REG_SZ, "A Simple Excel Addin") def UnregisterAddin(klass): import winreg try: ! winreg.DeleteKey(_winreg.HKEY_CURRENT_USER, "Software\\Microsoft\\Office\\Excel\\Addins\\" + klass._reg_progid_) except WindowsError: pass --- 117,131 ---- def RegisterAddin(klass): import winreg ! key = winreg.CreateKey(winreg.HKEY_CURRENT_USER, "Software\\Microsoft\\Office\\Excel\\Addins") subkey = winreg.CreateKey(key, klass._reg_progid_) ! winreg.SetValueEx(subkey, "CommandLineSafe", 0, winreg.REG_DWORD, 0) ! winreg.SetValueEx(subkey, "LoadBehavior", 0, winreg.REG_DWORD, 3) ! winreg.SetValueEx(subkey, "Description", 0, winreg.REG_SZ, "Excel Addin") ! winreg.SetValueEx(subkey, "FriendlyName", 0, winreg.REG_SZ, "A Simple Excel Addin") def UnregisterAddin(klass): import winreg try: ! winreg.DeleteKey(winreg.HKEY_CURRENT_USER, "Software\\Microsoft\\Office\\Excel\\Addins\\" + klass._reg_progid_) except WindowsError: pass Index: outlookAddin.py =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/win32com/demos/outlookAddin.py,v retrieving revision 1.2.4.2 retrieving revision 1.2.4.3 diff -C2 -d -r1.2.4.2 -r1.2.4.3 *** outlookAddin.py 4 Dec 2008 07:32:05 -0000 1.2.4.2 --- outlookAddin.py 9 Dec 2008 13:09:33 -0000 1.2.4.3 *************** *** 92,106 **** def RegisterAddin(klass): import winreg ! key = winreg.CreateKey(_winreg.HKEY_CURRENT_USER, "Software\\Microsoft\\Office\\Outlook\\Addins") subkey = winreg.CreateKey(key, klass._reg_progid_) ! winreg.SetValueEx(subkey, "CommandLineSafe", 0, _winreg.REG_DWORD, 0) ! winreg.SetValueEx(subkey, "LoadBehavior", 0, _winreg.REG_DWORD, 3) ! winreg.SetValueEx(subkey, "Description", 0, _winreg.REG_SZ, klass._reg_progid_) ! winreg.SetValueEx(subkey, "FriendlyName", 0, _winreg.REG_SZ, klass._reg_progid_) def UnregisterAddin(klass): import winreg try: ! winreg.DeleteKey(_winreg.HKEY_CURRENT_USER, "Software\\Microsoft\\Office\\Outlook\\Addins\\" + klass._reg_progid_) except WindowsError: pass --- 92,106 ---- def RegisterAddin(klass): import winreg ! key = winreg.CreateKey(winreg.HKEY_CURRENT_USER, "Software\\Microsoft\\Office\\Outlook\\Addins") subkey = winreg.CreateKey(key, klass._reg_progid_) ! winreg.SetValueEx(subkey, "CommandLineSafe", 0, winreg.REG_DWORD, 0) ! winreg.SetValueEx(subkey, "LoadBehavior", 0, winreg.REG_DWORD, 3) ! winreg.SetValueEx(subkey, "Description", 0, winreg.REG_SZ, klass._reg_progid_) ! winreg.SetValueEx(subkey, "FriendlyName", 0, winreg.REG_SZ, klass._reg_progid_) def UnregisterAddin(klass): import winreg try: ! winreg.DeleteKey(winreg.HKEY_CURRENT_USER, "Software\\Microsoft\\Office\\Outlook\\Addins\\" + klass._reg_progid_) except WindowsError: pass Index: iebutton.py =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/win32com/demos/iebutton.py,v retrieving revision 1.3.4.3 retrieving revision 1.3.4.4 diff -C2 -d -r1.3.4.3 -r1.3.4.4 *** iebutton.py 4 Dec 2008 07:32:05 -0000 1.3.4.3 --- iebutton.py 9 Dec 2008 13:09:33 -0000 1.3.4.4 *************** *** 133,144 **** subKeyCLSID = "SOFTWARE\\Microsoft\\Internet Explorer\\Extensions\\%38s" % classobj._reg_clsid_ try: ! hKey = winreg.CreateKey( _winreg.HKEY_LOCAL_MACHINE, subKeyCLSID ) ! subKey = winreg.SetValueEx( hKey, "ButtonText", 0, _winreg.REG_SZ, classobj._button_text_ ) ! winreg.SetValueEx( hKey, "ClsidExtension", 0, _winreg.REG_SZ, classobj._reg_clsid_ ) # reg value for calling COM object ! winreg.SetValueEx( hKey, "CLSID", 0, _winreg.REG_SZ, "{1FBA04EE-3024-11D2-8F1F-0000F87ABD16}" ) # CLSID for button that sends command to COM object ! winreg.SetValueEx( hKey, "Default Visible", 0, _winreg.REG_SZ, "Yes" ) ! winreg.SetValueEx( hKey, "ToolTip", 0, _winreg.REG_SZ, classobj._tool_tip_ ) ! winreg.SetValueEx( hKey, "Icon", 0, _winreg.REG_SZ, classobj._icon_) ! winreg.SetValueEx( hKey, "HotIcon", 0, _winreg.REG_SZ, classobj._hot_icon_) except WindowsError: print("Couldn't set standard toolbar reg keys.") --- 133,144 ---- subKeyCLSID = "SOFTWARE\\Microsoft\\Internet Explorer\\Extensions\\%38s" % classobj._reg_clsid_ try: ! hKey = winreg.CreateKey( winreg.HKEY_LOCAL_MACHINE, subKeyCLSID ) ! subKey = winreg.SetValueEx( hKey, "ButtonText", 0, winreg.REG_SZ, classobj._button_text_ ) ! winreg.SetValueEx( hKey, "ClsidExtension", 0, winreg.REG_SZ, classobj._reg_clsid_ ) # reg value for calling COM object ! winreg.SetValueEx( hKey, "CLSID", 0, winreg.REG_SZ, "{1FBA04EE-3024-11D2-8F1F-0000F87ABD16}" ) # CLSID for button that sends command to COM object ! winreg.SetValueEx( hKey, "Default Visible", 0, winreg.REG_SZ, "Yes" ) ! winreg.SetValueEx( hKey, "ToolTip", 0, winreg.REG_SZ, classobj._tool_tip_ ) ! winreg.SetValueEx( hKey, "Icon", 0, winreg.REG_SZ, classobj._icon_) ! winreg.SetValueEx( hKey, "HotIcon", 0, winreg.REG_SZ, classobj._hot_icon_) except WindowsError: print("Couldn't set standard toolbar reg keys.") *************** *** 150,154 **** subKeyCLSID = "SOFTWARE\\Microsoft\\Internet Explorer\\Extensions\\%38s" % classobj._reg_clsid_ try: ! hKey = winreg.CreateKey( _winreg.HKEY_LOCAL_MACHINE, subKeyCLSID ) subKey = winreg.DeleteValue( hKey, "ButtonText" ) winreg.DeleteValue( hKey, "ClsidExtension" ) # for calling COM object --- 150,154 ---- subKeyCLSID = "SOFTWARE\\Microsoft\\Internet Explorer\\Extensions\\%38s" % classobj._reg_clsid_ try: ! hKey = winreg.CreateKey( winreg.HKEY_LOCAL_MACHINE, subKeyCLSID ) subKey = winreg.DeleteValue( hKey, "ButtonText" ) winreg.DeleteValue( hKey, "ClsidExtension" ) # for calling COM object *************** *** 158,162 **** winreg.DeleteValue( hKey, "Icon" ) winreg.DeleteValue( hKey, "HotIcon" ) ! winreg.DeleteKey( _winreg.HKEY_LOCAL_MACHINE, subKeyCLSID ) except WindowsError: print("Couldn't delete Standard toolbar regkey.") --- 158,162 ---- winreg.DeleteValue( hKey, "Icon" ) winreg.DeleteValue( hKey, "HotIcon" ) ! winreg.DeleteKey( winreg.HKEY_LOCAL_MACHINE, subKeyCLSID ) except WindowsError: print("Couldn't delete Standard toolbar regkey.") |
From: Mark H. <mha...@us...> - 2008-12-09 13:08:49
|
Update of /cvsroot/pywin32/pywin32/com/win32comext/shell/demos/servers In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv27217/com/win32comext/shell/demos/servers Modified Files: Tag: py3k column_provider.py context_menu.py copy_hook.py empty_volume_cache.py folder_view.py icon_handler.py shell_view.py Log Message: corrections for 2to3 bug - _winreg->winreg Index: column_provider.py =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/win32comext/shell/demos/servers/column_provider.py,v retrieving revision 1.1.4.2 retrieving revision 1.1.4.3 diff -C2 -d -r1.1.4.2 -r1.1.4.3 *** column_provider.py 4 Dec 2008 07:32:06 -0000 1.1.4.2 --- column_provider.py 9 Dec 2008 13:08:36 -0000 1.1.4.3 *************** *** 81,88 **** import winreg # Special ColumnProvider key ! key = winreg.CreateKey(_winreg.HKEY_CLASSES_ROOT, "Folder\\ShellEx\\ColumnHandlers\\" + \ str(ColumnProvider._reg_clsid_ )) ! winreg.SetValueEx(key, None, 0, _winreg.REG_SZ, ColumnProvider._reg_desc_) print(ColumnProvider._reg_desc_, "registration complete.") --- 81,88 ---- import winreg # Special ColumnProvider key ! key = winreg.CreateKey(winreg.HKEY_CLASSES_ROOT, "Folder\\ShellEx\\ColumnHandlers\\" + \ str(ColumnProvider._reg_clsid_ )) ! winreg.SetValueEx(key, None, 0, winreg.REG_SZ, ColumnProvider._reg_desc_) print(ColumnProvider._reg_desc_, "registration complete.") *************** *** 90,94 **** import winreg try: ! key = winreg.DeleteKey(_winreg.HKEY_CLASSES_ROOT, "Folder\\ShellEx\\ColumnHandlers\\" + \ str(ColumnProvider._reg_clsid_) ) --- 90,94 ---- import winreg try: ! key = winreg.DeleteKey(winreg.HKEY_CLASSES_ROOT, "Folder\\ShellEx\\ColumnHandlers\\" + \ str(ColumnProvider._reg_clsid_) ) Index: copy_hook.py =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/win32comext/shell/demos/servers/copy_hook.py,v retrieving revision 1.2.4.2 retrieving revision 1.2.4.3 diff -C2 -d -r1.2.4.2 -r1.2.4.3 *** copy_hook.py 4 Dec 2008 07:32:06 -0000 1.2.4.2 --- copy_hook.py 9 Dec 2008 13:08:36 -0000 1.2.4.3 *************** *** 33,44 **** def DllRegisterServer(): import winreg ! key = winreg.CreateKey(_winreg.HKEY_CLASSES_ROOT, "directory\\shellex\\CopyHookHandlers\\" + ShellExtension._reg_desc_) ! winreg.SetValueEx(key, None, 0, _winreg.REG_SZ, ShellExtension._reg_clsid_) ! key = winreg.CreateKey(_winreg.HKEY_CLASSES_ROOT, "*\\shellex\\CopyHookHandlers\\" + ShellExtension._reg_desc_) ! winreg.SetValueEx(key, None, 0, _winreg.REG_SZ, ShellExtension._reg_clsid_) print(ShellExtension._reg_desc_, "registration complete.") --- 33,44 ---- def DllRegisterServer(): import winreg ! key = winreg.CreateKey(winreg.HKEY_CLASSES_ROOT, "directory\\shellex\\CopyHookHandlers\\" + ShellExtension._reg_desc_) ! winreg.SetValueEx(key, None, 0, winreg.REG_SZ, ShellExtension._reg_clsid_) ! key = winreg.CreateKey(winreg.HKEY_CLASSES_ROOT, "*\\shellex\\CopyHookHandlers\\" + ShellExtension._reg_desc_) ! winreg.SetValueEx(key, None, 0, winreg.REG_SZ, ShellExtension._reg_clsid_) print(ShellExtension._reg_desc_, "registration complete.") *************** *** 46,50 **** import winreg try: ! key = winreg.DeleteKey(_winreg.HKEY_CLASSES_ROOT, "directory\\shellex\\CopyHookHandlers\\" + ShellExtension._reg_desc_) --- 46,50 ---- import winreg try: ! key = winreg.DeleteKey(winreg.HKEY_CLASSES_ROOT, "directory\\shellex\\CopyHookHandlers\\" + ShellExtension._reg_desc_) *************** *** 54,58 **** raise try: ! key = winreg.DeleteKey(_winreg.HKEY_CLASSES_ROOT, "*\\shellex\\CopyHookHandlers\\" + ShellExtension._reg_desc_) --- 54,58 ---- raise try: ! key = winreg.DeleteKey(winreg.HKEY_CLASSES_ROOT, "*\\shellex\\CopyHookHandlers\\" + ShellExtension._reg_desc_) Index: empty_volume_cache.py =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/win32comext/shell/demos/servers/empty_volume_cache.py,v retrieving revision 1.1.2.2 retrieving revision 1.1.2.3 diff -C2 -d -r1.1.2.2 -r1.1.2.3 *** empty_volume_cache.py 4 Dec 2008 07:32:06 -0000 1.1.2.2 --- empty_volume_cache.py 9 Dec 2008 13:08:36 -0000 1.1.2.3 *************** *** 151,156 **** kn = r"Software\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\%s" \ % (EmptyVolumeCache._reg_desc_,) ! key = winreg.CreateKey(_winreg.HKEY_LOCAL_MACHINE, kn) ! winreg.SetValueEx(key, None, 0, _winreg.REG_SZ, EmptyVolumeCache._reg_clsid_) def DllUnregisterServer(): --- 151,156 ---- kn = r"Software\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\%s" \ % (EmptyVolumeCache._reg_desc_,) ! key = winreg.CreateKey(winreg.HKEY_LOCAL_MACHINE, kn) ! winreg.SetValueEx(key, None, 0, winreg.REG_SZ, EmptyVolumeCache._reg_clsid_) def DllUnregisterServer(): *************** *** 159,163 **** % (EmptyVolumeCache._reg_desc_,) try: ! key = winreg.DeleteKey(_winreg.HKEY_LOCAL_MACHINE, kn) except WindowsError as details: import errno --- 159,163 ---- % (EmptyVolumeCache._reg_desc_,) try: ! key = winreg.DeleteKey(winreg.HKEY_LOCAL_MACHINE, kn) except WindowsError as details: import errno Index: folder_view.py =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/win32comext/shell/demos/servers/folder_view.py,v retrieving revision 1.1.2.2 retrieving revision 1.1.2.3 diff -C2 -d -r1.1.2.2 -r1.1.2.3 *** folder_view.py 4 Dec 2008 07:32:06 -0000 1.1.2.2 --- folder_view.py 9 Dec 2008 13:08:36 -0000 1.1.2.3 *************** *** 682,692 **** sys.exit(1) ! key = winreg.CreateKey(_winreg.HKEY_LOCAL_MACHINE, "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\" \ "Explorer\\Desktop\\Namespace\\" + \ ShellFolder._reg_clsid_) ! winreg.SetValueEx(key, None, 0, _winreg.REG_SZ, ShellFolder._reg_desc_) # And special shell keys under our CLSID ! key = winreg.CreateKey(_winreg.HKEY_CLASSES_ROOT, "CLSID\\" + ShellFolder._reg_clsid_ + "\\ShellFolder") # 'Attributes' is an int stored as a binary! use struct --- 682,692 ---- sys.exit(1) ! key = winreg.CreateKey(winreg.HKEY_LOCAL_MACHINE, "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\" \ "Explorer\\Desktop\\Namespace\\" + \ ShellFolder._reg_clsid_) ! winreg.SetValueEx(key, None, 0, winreg.REG_SZ, ShellFolder._reg_desc_) # And special shell keys under our CLSID ! key = winreg.CreateKey(winreg.HKEY_CLASSES_ROOT, "CLSID\\" + ShellFolder._reg_clsid_ + "\\ShellFolder") # 'Attributes' is an int stored as a binary! use struct *************** *** 695,703 **** import struct s = struct.pack("i", attr) ! winreg.SetValueEx(key, "Attributes", 0, _winreg.REG_BINARY, s) # register the context menu handler under the FolderViewSampleType type. keypath = "%s\\shellex\\ContextMenuHandlers\\%s" % (ContextMenu._context_menu_type_, ContextMenu._reg_desc_) ! key = winreg.CreateKey(_winreg.HKEY_CLASSES_ROOT, keypath) ! winreg.SetValueEx(key, None, 0, _winreg.REG_SZ, ContextMenu._reg_clsid_) propsys.PSRegisterPropertySchema(get_schema_fname()) print(ShellFolder._reg_desc_, "registration complete.") --- 695,703 ---- import struct s = struct.pack("i", attr) ! winreg.SetValueEx(key, "Attributes", 0, winreg.REG_BINARY, s) # register the context menu handler under the FolderViewSampleType type. keypath = "%s\\shellex\\ContextMenuHandlers\\%s" % (ContextMenu._context_menu_type_, ContextMenu._reg_desc_) ! key = winreg.CreateKey(winreg.HKEY_CLASSES_ROOT, keypath) ! winreg.SetValueEx(key, None, 0, winreg.REG_SZ, ContextMenu._reg_clsid_) propsys.PSRegisterPropertySchema(get_schema_fname()) print(ShellFolder._reg_desc_, "registration complete.") *************** *** 711,715 **** for path in paths: try: ! winreg.DeleteKey(_winreg.HKEY_LOCAL_MACHINE, path) except WindowsError as details: import errno --- 711,715 ---- for path in paths: try: ! winreg.DeleteKey(winreg.HKEY_LOCAL_MACHINE, path) except WindowsError as details: import errno Index: shell_view.py =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/win32comext/shell/demos/servers/shell_view.py,v retrieving revision 1.12.2.2 retrieving revision 1.12.2.3 diff -C2 -d -r1.12.2.2 -r1.12.2.3 *** shell_view.py 4 Dec 2008 07:32:06 -0000 1.12.2.2 --- shell_view.py 9 Dec 2008 13:08:36 -0000 1.12.2.3 *************** *** 813,823 **** def DllRegisterServer(): import winreg ! key = winreg.CreateKey(_winreg.HKEY_LOCAL_MACHINE, "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\" \ "Explorer\\Desktop\\Namespace\\" + \ ShellFolderRoot._reg_clsid_) ! winreg.SetValueEx(key, None, 0, _winreg.REG_SZ, ShellFolderRoot._reg_desc_) # And special shell keys under our CLSID ! key = winreg.CreateKey(_winreg.HKEY_CLASSES_ROOT, "CLSID\\" + ShellFolderRoot._reg_clsid_ + "\\ShellFolder") # 'Attributes' is an int stored as a binary! use struct --- 813,823 ---- def DllRegisterServer(): import winreg ! key = winreg.CreateKey(winreg.HKEY_LOCAL_MACHINE, "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\" \ "Explorer\\Desktop\\Namespace\\" + \ ShellFolderRoot._reg_clsid_) ! winreg.SetValueEx(key, None, 0, winreg.REG_SZ, ShellFolderRoot._reg_desc_) # And special shell keys under our CLSID ! key = winreg.CreateKey(winreg.HKEY_CLASSES_ROOT, "CLSID\\" + ShellFolderRoot._reg_clsid_ + "\\ShellFolder") # 'Attributes' is an int stored as a binary! use struct *************** *** 826,830 **** import struct s = struct.pack("i", attr) ! winreg.SetValueEx(key, "Attributes", 0, _winreg.REG_BINARY, s) print(ShellFolderRoot._reg_desc_, "registration complete.") --- 826,830 ---- import struct s = struct.pack("i", attr) ! winreg.SetValueEx(key, "Attributes", 0, winreg.REG_BINARY, s) print(ShellFolderRoot._reg_desc_, "registration complete.") *************** *** 832,836 **** import winreg try: ! key = winreg.DeleteKey(_winreg.HKEY_LOCAL_MACHINE, "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\" \ "Explorer\\Desktop\\Namespace\\" + \ --- 832,836 ---- import winreg try: ! key = winreg.DeleteKey(winreg.HKEY_LOCAL_MACHINE, "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\" \ "Explorer\\Desktop\\Namespace\\" + \ Index: icon_handler.py =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/win32comext/shell/demos/servers/icon_handler.py,v retrieving revision 1.1.4.2 retrieving revision 1.1.4.3 diff -C2 -d -r1.1.4.2 -r1.1.4.3 *** icon_handler.py 4 Dec 2008 07:32:06 -0000 1.1.4.2 --- icon_handler.py 9 Dec 2008 13:08:36 -0000 1.1.4.3 *************** *** 47,54 **** def DllRegisterServer(): import winreg ! key = winreg.CreateKey(_winreg.HKEY_CLASSES_ROOT, "Python.File\\shellex") subkey = winreg.CreateKey(key, "IconHandler") ! winreg.SetValueEx(subkey, None, 0, _winreg.REG_SZ, ShellExtension._reg_clsid_) print(ShellExtension._reg_desc_, "registration complete.") --- 47,54 ---- def DllRegisterServer(): import winreg ! key = winreg.CreateKey(winreg.HKEY_CLASSES_ROOT, "Python.File\\shellex") subkey = winreg.CreateKey(key, "IconHandler") ! winreg.SetValueEx(subkey, None, 0, winreg.REG_SZ, ShellExtension._reg_clsid_) print(ShellExtension._reg_desc_, "registration complete.") *************** *** 56,60 **** import winreg try: ! key = winreg.DeleteKey(_winreg.HKEY_CLASSES_ROOT, "Python.File\\shellex\\IconHandler") except WindowsError as details: --- 56,60 ---- import winreg try: ! key = winreg.DeleteKey(winreg.HKEY_CLASSES_ROOT, "Python.File\\shellex\\IconHandler") except WindowsError as details: Index: context_menu.py =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/win32comext/shell/demos/servers/context_menu.py,v retrieving revision 1.4.2.2 retrieving revision 1.4.2.3 diff -C2 -d -r1.4.2.2 -r1.4.2.3 *** context_menu.py 4 Dec 2008 07:32:06 -0000 1.4.2.2 --- context_menu.py 9 Dec 2008 13:08:36 -0000 1.4.2.3 *************** *** 77,85 **** def DllRegisterServer(): import winreg ! key = winreg.CreateKey(_winreg.HKEY_CLASSES_ROOT, "Python.File\\shellex") subkey = winreg.CreateKey(key, "ContextMenuHandlers") subkey2 = winreg.CreateKey(subkey, "PythonSample") ! winreg.SetValueEx(subkey2, None, 0, _winreg.REG_SZ, ShellExtension._reg_clsid_) print(ShellExtension._reg_desc_, "registration complete.") --- 77,85 ---- def DllRegisterServer(): import winreg ! key = winreg.CreateKey(winreg.HKEY_CLASSES_ROOT, "Python.File\\shellex") subkey = winreg.CreateKey(key, "ContextMenuHandlers") subkey2 = winreg.CreateKey(subkey, "PythonSample") ! winreg.SetValueEx(subkey2, None, 0, winreg.REG_SZ, ShellExtension._reg_clsid_) print(ShellExtension._reg_desc_, "registration complete.") *************** *** 87,91 **** import winreg try: ! key = winreg.DeleteKey(_winreg.HKEY_CLASSES_ROOT, "Python.File\\shellex\\ContextMenuHandlers\\PythonSample") except WindowsError as details: --- 87,91 ---- import winreg try: ! key = winreg.DeleteKey(winreg.HKEY_CLASSES_ROOT, "Python.File\\shellex\\ContextMenuHandlers\\PythonSample") except WindowsError as details: |
From: Mark H. <mha...@us...> - 2008-12-09 12:52:46
|
Update of /cvsroot/pywin32/pywin32/Pythonwin/pywin/mfc In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv24496/pythonwin/pywin/mfc Modified Files: object.py Log Message: Don't delegate any special __ attributes to the win32ui type. Index: object.py =================================================================== RCS file: /cvsroot/pywin32/pywin32/Pythonwin/pywin/mfc/object.py,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** object.py 14 Nov 2008 00:22:25 -0000 1.5 --- object.py 9 Dec 2008 12:52:41 -0000 1.6 *************** *** 12,16 **** def __getattr__(self, attr): # Make this object look like the underlying win32ui one. # During cleanup __dict__ is not available, causing recursive death. ! if attr != '__dict__': try: o = self.__dict__['_obj_'] --- 12,16 ---- def __getattr__(self, attr): # Make this object look like the underlying win32ui one. # During cleanup __dict__ is not available, causing recursive death. ! if not attr.startswith('__'): try: o = self.__dict__['_obj_'] |
From: Mark H. <mha...@us...> - 2008-12-09 12:39:07
|
Update of /cvsroot/pywin32/pywin32/win32/src/win32wnet In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv22375/win32/src/win32wnet Modified Files: Tag: py3k win32wnet.cpp Log Message: Merge more PYWIN32_MODULE_* macro usage from the trunk Index: win32wnet.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/src/win32wnet/win32wnet.cpp,v retrieving revision 1.13.2.1 retrieving revision 1.13.2.2 diff -C2 -d -r1.13.2.1 -r1.13.2.2 *** win32wnet.cpp 29 Aug 2008 05:00:24 -0000 1.13.2.1 --- win32wnet.cpp 9 Dec 2008 12:38:52 -0000 1.13.2.2 *************** *** 632,682 **** }; ! extern "C" __declspec(dllexport) ! #if (PY_VERSION_HEX < 0x03000000) ! void initwin32wnet(void) ! #else ! PyObject *PyInit_win32wnet(void) ! #endif { ! PyObject *dict, *module; ! #if (PY_VERSION_HEX < 0x03000000) ! module = Py_InitModule("win32wnet", win32wnet_functions); ! if (!module) ! return; ! dict = PyModule_GetDict(module); ! if (!dict) ! return; - #else - static PyModuleDef win32wnet_def = { - PyModuleDef_HEAD_INIT, - "win32wnet", - "A module that exposes the Windows Networking API.", - -1, - win32wnet_functions - }; - module = PyModule_Create(&win32wnet_def); - if (!module) - return NULL; - dict = PyModule_GetDict(module); - if (!dict) - return NULL; - #endif - PyWinGlobals_Ensure(); - Py_INCREF(PyWinExc_ApiError); PyDict_SetItemString(dict, "error", PyWinExc_ApiError); - #if (PY_VERSION_HEX >= 0x03000000) if ((PyType_Ready(&PyNETRESOURCEType) == -1) || (PyType_Ready(&PyNCBType) == -1)) ! return NULL; ! #endif PyDict_SetItemString(dict, "NETRESOURCEType", (PyObject *)&PyNETRESOURCEType); PyDict_SetItemString(dict, "NCBType", (PyObject *)&PyNCBType); ! #if (PY_VERSION_HEX >= 0x03000000) ! return module; ! #endif; } --- 632,650 ---- }; ! PYWIN_MODULE_INIT_FUNC(win32wnet) { ! PYWIN_MODULE_INIT_PREPARE(win32wnet, win32wnet_functions, ! "A module that exposes the Windows Networking API."); PyDict_SetItemString(dict, "error", PyWinExc_ApiError); if ((PyType_Ready(&PyNETRESOURCEType) == -1) || (PyType_Ready(&PyNCBType) == -1)) ! PYWIN_MODULE_INIT_RETURN_ERROR; PyDict_SetItemString(dict, "NETRESOURCEType", (PyObject *)&PyNETRESOURCEType); PyDict_SetItemString(dict, "NCBType", (PyObject *)&PyNCBType); ! PYWIN_MODULE_INIT_RETURN_SUCCESS; } |
From: Mark H. <mha...@us...> - 2008-12-09 12:39:07
|
Update of /cvsroot/pywin32/pywin32/com/win32comext/bits/src In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv22375/com/win32comext/bits/src Modified Files: Tag: py3k bits.cpp Log Message: Merge more PYWIN32_MODULE_* macro usage from the trunk Index: bits.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/win32comext/bits/src/bits.cpp,v retrieving revision 1.2 retrieving revision 1.2.2.1 diff -C2 -d -r1.2 -r1.2.2.1 *** bits.cpp 12 Feb 2008 00:10:57 -0000 1.2 --- bits.cpp 9 Dec 2008 12:38:52 -0000 1.2.2.1 *************** *** 106,122 **** }; ! extern "C" __declspec(dllexport) void initbits() { ! PyObject *module; ! module = Py_InitModule("bits", bits_methods); ! if (module==NULL) ! return; ! PyObject *dict = PyModule_GetDict(module); ! if (dict==NULL) ! return; // Register all of our interfaces, gateways and IIDs. PyCom_RegisterExtensionSupport(dict, register_data, sizeof(register_data)/sizeof(PyCom_InterfaceSupportInfo)); ! // auth scheme PyModule_AddIntConstant(module, "BG_AUTH_SCHEME_BASIC", BG_AUTH_SCHEME_BASIC); --- 106,117 ---- }; ! PYWIN_MODULE_INIT_FUNC(bits) { ! PYWIN_MODULE_INIT_PREPARE(bits, bits_methods, ! "A module, encapsulating the Background Intelligent Transfer Service (bits)"); // Register all of our interfaces, gateways and IIDs. PyCom_RegisterExtensionSupport(dict, register_data, sizeof(register_data)/sizeof(PyCom_InterfaceSupportInfo)); ! // auth scheme PyModule_AddIntConstant(module, "BG_AUTH_SCHEME_BASIC", BG_AUTH_SCHEME_BASIC); *************** *** 130,143 **** PyModule_AddIntConstant(module, "BG_AUTH_TARGET_PROXY", BG_AUTH_TARGET_PROXY); - // Requires Vista // // cert store location ! // PyModule_AddIntConstant(module, "BG_CERT_STORE_LOCATION_CURRENT_USER", BG_CERT_STORE_LOCATION_CURRENT_USER); ! // PyModule_AddIntConstant(module, "BG_CERT_STORE_LOCATION_LOCAL_MACHINE", BG_CERT_STORE_LOCATION_LOCAL_MACHINE); ! // PyModule_AddIntConstant(module, "BG_CERT_STORE_LOCATION_CURRENT_SERVICE", BG_CERT_STORE_LOCATION_CURRENT_SERVICE); ! // PyModule_AddIntConstant(module, "BG_CERT_STORE_LOCATION_SERVICES", BG_CERT_STORE_LOCATION_SERVICES); ! // PyModule_AddIntConstant(module, "BG_CERT_STORE_LOCATION_USERS", BG_CERT_STORE_LOCATION_USERS); ! // PyModule_AddIntConstant(module, "BG_CERT_STORE_LOCATION_CURRENT_USER_GROUP_POLICY", BG_CERT_STORE_LOCATION_CURRENT_USER_GROUP_POLICY); ! // PyModule_AddIntConstant(module, "BG_CERT_STORE_LOCATION_LOCAL_MACHINE_GROUP_POLICY", BG_CERT_STORE_LOCATION_LOCAL_MACHINE_GROUP_POLICY); ! // PyModule_AddIntConstant(module, "BG_CERT_STORE_LOCATION_LOCAL_MACHINE_ENTERPRISE", BG_CERT_STORE_LOCATION_LOCAL_MACHINE_ENTERPRISE); // error context --- 125,137 ---- PyModule_AddIntConstant(module, "BG_AUTH_TARGET_PROXY", BG_AUTH_TARGET_PROXY); // // cert store location ! PyModule_AddIntConstant(module, "BG_CERT_STORE_LOCATION_CURRENT_USER", BG_CERT_STORE_LOCATION_CURRENT_USER); ! PyModule_AddIntConstant(module, "BG_CERT_STORE_LOCATION_LOCAL_MACHINE", BG_CERT_STORE_LOCATION_LOCAL_MACHINE); ! PyModule_AddIntConstant(module, "BG_CERT_STORE_LOCATION_CURRENT_SERVICE", BG_CERT_STORE_LOCATION_CURRENT_SERVICE); ! PyModule_AddIntConstant(module, "BG_CERT_STORE_LOCATION_SERVICES", BG_CERT_STORE_LOCATION_SERVICES); ! PyModule_AddIntConstant(module, "BG_CERT_STORE_LOCATION_USERS", BG_CERT_STORE_LOCATION_USERS); ! PyModule_AddIntConstant(module, "BG_CERT_STORE_LOCATION_CURRENT_USER_GROUP_POLICY", BG_CERT_STORE_LOCATION_CURRENT_USER_GROUP_POLICY); ! PyModule_AddIntConstant(module, "BG_CERT_STORE_LOCATION_LOCAL_MACHINE_GROUP_POLICY", BG_CERT_STORE_LOCATION_LOCAL_MACHINE_GROUP_POLICY); ! PyModule_AddIntConstant(module, "BG_CERT_STORE_LOCATION_LOCAL_MACHINE_ENTERPRISE", BG_CERT_STORE_LOCATION_LOCAL_MACHINE_ENTERPRISE); // error context *************** *** 186,189 **** // PyModule_AddIntConstant(module, "BG_NOTIFY_FILE_TRANSFERRED", BG_NOTIFY_FILE_TRANSFERRED); ! PyModule_AddIntConstant(module, "BG_JOB_ENUM_ALL_USERS", BG_JOB_ENUM_ALL_USERS); } --- 180,184 ---- // PyModule_AddIntConstant(module, "BG_NOTIFY_FILE_TRANSFERRED", BG_NOTIFY_FILE_TRANSFERRED); ! PyModule_AddIntConstant(module, "BG_JOB_ENUM_ALL_USERS", BG_JOB_ENUM_ALL_USERS); ! PYWIN_MODULE_INIT_RETURN_SUCCESS; } |
From: Mark H. <mha...@us...> - 2008-12-09 12:39:07
|
Update of /cvsroot/pywin32/pywin32/com/win32comext/directsound/src In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv22375/com/win32comext/directsound/src Modified Files: Tag: py3k directsound.cpp Log Message: Merge more PYWIN32_MODULE_* macro usage from the trunk Index: directsound.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/win32comext/directsound/src/directsound.cpp,v retrieving revision 1.8.4.3 retrieving revision 1.8.4.4 diff -C2 -d -r1.8.4.3 -r1.8.4.4 *** directsound.cpp 13 Sep 2008 16:09:51 -0000 1.8.4.3 --- directsound.cpp 9 Dec 2008 12:38:52 -0000 1.8.4.4 *************** *** 238,242 **** ! #define ADD_CONSTANT(tok) if (PyModule_AddIntConstant(module, #tok, tok) == -1) RETURN_ERROR; static const PyCom_InterfaceSupportInfo g_interfaceSupportData[] = --- 238,242 ---- ! #define ADD_CONSTANT(tok) if (PyModule_AddIntConstant(module, #tok, tok) == -1) PYWIN_MODULE_INIT_RETURN_ERROR; static const PyCom_InterfaceSupportInfo g_interfaceSupportData[] = *************** *** 250,283 **** /* Module initialisation */ ! extern "C" __declspec(dllexport) ! #if (PY_VERSION_HEX < 0x03000000) ! void initdirectsound(void) ! #else ! PyObject *PyInit_directsound(void) ! #endif { ! PyObject *dict, *module; ! PyWinGlobals_Ensure(); ! ! #if (PY_VERSION_HEX < 0x03000000) ! #define RETURN_ERROR return; ! module = Py_InitModule("directsound", directsound_methods); ! #else ! #define RETURN_ERROR return NULL; ! static PyModuleDef directsound_def = { ! PyModuleDef_HEAD_INIT, ! "directsound", ! "A module encapsulating the DirectSound interfaces.", ! -1, ! directsound_methods ! }; ! module = PyModule_Create(&directsound_def); ! #endif ! ! if (!module) ! RETURN_ERROR; ! dict = PyModule_GetDict(module); ! if (!dict) ! RETURN_ERROR; --- 250,257 ---- /* Module initialisation */ ! PYWIN_MODULE_INIT_FUNC(directsound) { ! PYWIN_MODULE_INIT_PREPARE(directsound, directsound_methods, ! "A module encapsulating the DirectSound interfaces."); *************** *** 417,425 **** ||PyDict_SetItemString(dict, "DSCBCAPSType", (PyObject *)&PyDSCBCAPSType) == -1 ||PyDict_SetItemString(dict, "DSCBUFFERDESCType", (PyObject *)&PyDSCBUFFERDESCType) == -1) ! RETURN_ERROR; ! #if (PY_VERSION_HEX >= 0x03000000) ! return module; ! #endif } --- 391,397 ---- ||PyDict_SetItemString(dict, "DSCBCAPSType", (PyObject *)&PyDSCBCAPSType) == -1 ||PyDict_SetItemString(dict, "DSCBUFFERDESCType", (PyObject *)&PyDSCBUFFERDESCType) == -1) ! PYWIN_MODULE_INIT_RETURN_ERROR; ! PYWIN_MODULE_INIT_RETURN_SUCCESS; } |
From: Mark H. <mha...@us...> - 2008-12-09 12:39:06
|
Update of /cvsroot/pywin32/pywin32/win32/src/win32print In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv22375/win32/src/win32print Modified Files: Tag: py3k win32print.cpp Log Message: Merge more PYWIN32_MODULE_* macro usage from the trunk Index: win32print.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/src/win32print/win32print.cpp,v retrieving revision 1.30.2.2 retrieving revision 1.30.2.3 diff -C2 -d -r1.30.2.2 -r1.30.2.3 *** win32print.cpp 11 Oct 2008 18:35:00 -0000 1.30.2.2 --- win32print.cpp 9 Dec 2008 12:38:52 -0000 1.30.2.3 *************** *** 2639,2674 **** ! extern "C" __declspec(dllexport) ! #if (PY_VERSION_HEX < 0x03000000) ! void initwin32print(void) ! #else ! PyObject *PyInit_win32print(void) ! #endif { ! PyObject *module, *dict; ! PyWinGlobals_Ensure(); ! ! #if (PY_VERSION_HEX < 0x03000000) ! module = Py_InitModule("win32print", win32print_functions); ! if (!module) ! return; ! dict = PyModule_GetDict(module); ! if (!dict) ! return; ! #else ! static PyModuleDef win32print_def = { ! PyModuleDef_HEAD_INIT, ! "win32print", ! "A module encapsulating the Windows printing API.", ! -1, ! win32print_functions ! }; ! module = PyModule_Create(&win32print_def); ! if (!module) ! return NULL; ! dict = PyModule_GetDict(module); ! if (!dict) ! return NULL; ! #endif AddConstant(dict, "PRINTER_INFO_1", 1); --- 2639,2646 ---- ! PYWIN_MODULE_INIT_FUNC(win32print) { ! PYWIN_MODULE_INIT_PREPARE(win32print, win32print_functions, ! "A module encapsulating the Windows printing API.") AddConstant(dict, "PRINTER_INFO_1", 1); *************** *** 2854,2859 **** dummy_tuple=PyTuple_New(0); ! #if (PY_VERSION_HEX >= 0x03000000) ! return module; ! #endif } --- 2826,2829 ---- dummy_tuple=PyTuple_New(0); ! PYWIN_MODULE_INIT_RETURN_SUCCESS; } |