pywin32-checkins Mailing List for Python for Windows Extensions (Page 70)
OLD project page for the Python extensions for Windows
Brought to you by:
mhammond
You can subscribe to this list here.
2003 |
Jan
|
Feb
|
Mar
|
Apr
(2) |
May
(1) |
Jun
(6) |
Jul
(50) |
Aug
(11) |
Sep
(24) |
Oct
(184) |
Nov
(118) |
Dec
(22) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2004 |
Jan
(31) |
Feb
(25) |
Mar
(34) |
Apr
(105) |
May
(49) |
Jun
(38) |
Jul
(39) |
Aug
(7) |
Sep
(98) |
Oct
(79) |
Nov
(20) |
Dec
(17) |
2005 |
Jan
(66) |
Feb
(32) |
Mar
(43) |
Apr
(30) |
May
(58) |
Jun
(30) |
Jul
(16) |
Aug
(4) |
Sep
(21) |
Oct
(42) |
Nov
(11) |
Dec
(14) |
2006 |
Jan
(42) |
Feb
(30) |
Mar
(22) |
Apr
(1) |
May
(9) |
Jun
(15) |
Jul
(20) |
Aug
(9) |
Sep
(8) |
Oct
(1) |
Nov
(9) |
Dec
(43) |
2007 |
Jan
(52) |
Feb
(45) |
Mar
(20) |
Apr
(12) |
May
(59) |
Jun
(39) |
Jul
(35) |
Aug
(31) |
Sep
(17) |
Oct
(20) |
Nov
(4) |
Dec
(4) |
2008 |
Jan
(28) |
Feb
(111) |
Mar
(4) |
Apr
(27) |
May
(40) |
Jun
(27) |
Jul
(32) |
Aug
(94) |
Sep
(87) |
Oct
(153) |
Nov
(336) |
Dec
(331) |
2009 |
Jan
(298) |
Feb
(127) |
Mar
(20) |
Apr
(8) |
May
|
Jun
(10) |
Jul
(6) |
Aug
|
Sep
(2) |
Oct
(2) |
Nov
|
Dec
(1) |
2010 |
Jan
(7) |
Feb
(1) |
Mar
|
Apr
|
May
(15) |
Jun
(4) |
Jul
(3) |
Aug
(28) |
Sep
(1) |
Oct
(19) |
Nov
(16) |
Dec
(6) |
2011 |
Jan
(2) |
Feb
(18) |
Mar
(17) |
Apr
(12) |
May
(5) |
Jun
(11) |
Jul
(7) |
Aug
(2) |
Sep
(2) |
Oct
(4) |
Nov
(4) |
Dec
|
2012 |
Jan
(6) |
Feb
(2) |
Mar
|
Apr
(8) |
May
(4) |
Jun
(3) |
Jul
(13) |
Aug
(27) |
Sep
(8) |
Oct
(9) |
Nov
(3) |
Dec
(2) |
2013 |
Jan
|
Feb
(1) |
Mar
(5) |
Apr
(10) |
May
|
Jun
(2) |
Jul
|
Aug
|
Sep
|
Oct
|
Nov
(1) |
Dec
(9) |
2014 |
Jan
(2) |
Feb
(4) |
Mar
(4) |
Apr
(1) |
May
(4) |
Jun
(2) |
Jul
|
Aug
|
Sep
|
Oct
(2) |
Nov
|
Dec
(1) |
2015 |
Jan
(1) |
Feb
|
Mar
|
Apr
(6) |
May
(2) |
Jun
|
Jul
|
Aug
(1) |
Sep
|
Oct
|
Nov
|
Dec
|
2016 |
Jan
(3) |
Feb
(2) |
Mar
|
Apr
(3) |
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2017 |
Jan
|
Feb
|
Mar
(1) |
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
(1) |
Oct
|
Nov
|
Dec
|
From: Roger U. <ru...@us...> - 2008-08-31 09:00:12
|
Update of /cvsroot/pywin32/pywin32/com/win32com/client In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7525 Modified Files: Tag: py3k __init__.py Log Message: Add back some error msgs removed by 2to3 Index: __init__.py =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/win32com/client/__init__.py,v retrieving revision 1.34.4.1 retrieving revision 1.34.4.2 diff -C2 -d -r1.34.4.1 -r1.34.4.2 *** __init__.py 29 Aug 2008 08:58:52 -0000 1.34.4.1 --- __init__.py 31 Aug 2008 09:00:21 -0000 1.34.4.2 *************** *** 8,14 **** import builtins # For some bizarre reason, __builtins__ fails with attribute error on __dict__ here? NeedUnicodeConversions = not hasattr(builtins, "unicode") - import pythoncom from . import dynamic, gencache --- 8,14 ---- import builtins # For some bizarre reason, __builtins__ fails with attribute error on __dict__ here? + # This can go away NeedUnicodeConversions = not hasattr(builtins, "unicode") import pythoncom from . import dynamic, gencache *************** *** 67,71 **** if (Pathname is None and Class is None) or \ (Pathname is not None and Class is not None): ! raise ValueError if Class is not None: --- 67,71 ---- if (Pathname is None and Class is None) or \ (Pathname is not None and Class is not None): ! raise ValueError("You must specify a value for Pathname or Class, but not both.") if Class is not None: *************** *** 133,137 **** ob = gencache.EnsureDispatch(ob) if "CLSID" not in ob.__class__.__dict__: ! raise ValueError clsid = ob.CLSID # Lots of hoops to support "demand-build" - ie, generating --- 133,137 ---- ob = gencache.EnsureDispatch(ob) if "CLSID" not in ob.__class__.__dict__: ! raise ValueError("Must be a makepy-able object for this to work") clsid = ob.CLSID # Lots of hoops to support "demand-build" - ie, generating *************** *** 149,153 **** target_clsid = mod.NamesToIIDMap.get(target) if target_clsid is None: ! raise ValueError mod = gencache.GetModuleForCLSID(target_clsid) target_class = getattr(mod, target) --- 149,154 ---- target_clsid = mod.NamesToIIDMap.get(target) if target_clsid is None: ! raise ValueError("The interface name '%s' does not appear in the " \ ! "same library as object '%r'" % (target, ob)) mod = gencache.GetModuleForCLSID(target_clsid) target_class = getattr(mod, target) *************** *** 166,170 **** if a in d: return d[a] ! raise AttributeError # And create an instance. --- 167,171 ---- if a in d: return d[a] ! raise AttributeError(a) # And create an instance. *************** *** 252,256 **** disp_class = gencache.GetClassForProgID(str(disp_clsid)) except pythoncom.com_error: ! raise TypeError else: disp_class = disp.__class__ --- 253,257 ---- disp_class = gencache.GetClassForProgID(str(disp_clsid)) except pythoncom.com_error: ! raise TypeError("This COM object can not automate the makepy process - please run makepy manually for this object") else: disp_class = disp.__class__ *************** *** 261,265 **** events_class = getevents(clsid) if events_class is None: ! raise ValueError result_class = new.classobj("COMEventClass", (disp_class, events_class, user_event_class), {"__setattr__" : _event_setattr_}) instance = result_class(disp._oleobj_) # This only calls the first base class __init__. --- 262,266 ---- events_class = getevents(clsid) if events_class is None: ! raise ValueError("This COM object does not support events.") result_class = new.classobj("COMEventClass", (disp_class, events_class, user_event_class), {"__setattr__" : _event_setattr_}) instance = result_class(disp._oleobj_) # This only calls the first base class __init__. *************** *** 304,308 **** disp_class = gencache.GetClassForProgID(str(disp_clsid)) except pythoncom.com_error: ! raise TypeError else: disp_class = disp.__class__ --- 305,309 ---- disp_class = gencache.GetClassForProgID(str(disp_clsid)) except pythoncom.com_error: ! raise TypeError("This COM object can not automate the makepy process - please run makepy manually for this object") else: disp_class = disp.__class__ *************** *** 314,318 **** events_class = getevents(clsid) if events_class is None: ! raise ValueError result_class = new.classobj("COMEventClass", (events_class, user_event_class), {}) instance = result_class(disp) # This only calls the first base class __init__. --- 315,319 ---- events_class = getevents(clsid) if events_class is None: ! raise ValueError("This COM object does not support events.") result_class = new.classobj("COMEventClass", (events_class, user_event_class), {}) instance = result_class(disp) # This only calls the first base class __init__. *************** *** 388,391 **** --- 389,393 ---- app.MoveTo(point) """ + # XXX - to do - probably should allow "object" to already be a module object. from . import gencache object = gencache.EnsureDispatch(object) *************** *** 400,405 **** struct_guid = package.RecordMap[name] except KeyError: ! raise ValueError ! return pythoncom.GetRecordFromGuids(module.CLSID, module.MajorVersion, module.MinorVersion, module.LCID, struct_guid) --- 402,406 ---- struct_guid = package.RecordMap[name] except KeyError: ! raise ValueError("The structure '%s' is not defined in module '%s'" % (name, package)) return pythoncom.GetRecordFromGuids(module.CLSID, module.MajorVersion, module.MinorVersion, module.LCID, struct_guid) *************** *** 420,424 **** # Eg, Lotus notes. # So just let it use the existing object if E_NOINTERFACE ! if details[0] != winerror.E_NOINTERFACE: raise oobj = oobj._oleobj_ --- 421,425 ---- # Eg, Lotus notes. # So just let it use the existing object if E_NOINTERFACE ! if details.args[0] != winerror.E_NOINTERFACE: raise oobj = oobj._oleobj_ *************** *** 441,455 **** return cmp(self._oleobj_, other) ! def _ApplyTypes_(self, dispid, wFlags, retType, argTypes, user, ! resultCLSID, *args): return self._get_good_object_( ! self._oleobj_.InvokeTypes( ! dispid, 0, wFlags, retType, argTypes, *args), ! user, resultCLSID) def __getattr__(self, attr): args=self._prop_map_get_.get(attr) if args is None: ! raise AttributeError return self._ApplyTypes_(*args) --- 442,454 ---- return cmp(self._oleobj_, other) ! def _ApplyTypes_(self, dispid, wFlags, retType, argTypes, user, resultCLSID, *args): return self._get_good_object_( ! self._oleobj_.InvokeTypes(dispid, 0, wFlags, retType, argTypes, *args), ! user, resultCLSID) def __getattr__(self, attr): args=self._prop_map_get_.get(attr) if args is None: ! raise AttributeError("'%s' object has no attribute '%s'" % (repr(self), attr)) return self._ApplyTypes_(*args) *************** *** 459,463 **** args, defArgs=self._prop_map_put_[attr] except KeyError: ! raise AttributeError self._oleobj_.Invoke(*(args + (value,) + defArgs)) def _get_good_single_object_(self, obj, obUserName=None, resultCLSID=None): --- 458,462 ---- args, defArgs=self._prop_map_put_[attr] except KeyError: ! raise AttributeError("'%s' object has no attribute '%s'" % (repr(self), attr)) self._oleobj_.Invoke(*(args + (value,) + defArgs)) def _get_good_single_object_(self, obj, obUserName=None, resultCLSID=None): *************** *** 494,498 **** d=self.__dict__["_dispobj_"] if d is not None: return getattr(d, attr) ! raise AttributeError def __setattr__(self, attr, value): if attr in self.__dict__: self.__dict__[attr] = value; return --- 493,497 ---- d=self.__dict__["_dispobj_"] if d is not None: return getattr(d, attr) ! raise AttributeError(attr) def __setattr__(self, attr, value): if attr in self.__dict__: self.__dict__[attr] = value; return |
From: Roger U. <ru...@us...> - 2008-08-31 08:31:19
|
Update of /cvsroot/pywin32/pywin32/Pythonwin/pywin/framework In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28311 Modified Files: Tag: py3k intpyapp.py Log Message: Remove a print stmt Index: intpyapp.py =================================================================== RCS file: /cvsroot/pywin32/pywin32/Pythonwin/pywin/framework/intpyapp.py,v retrieving revision 1.11.2.1 retrieving revision 1.11.2.2 diff -C2 -d -r1.11.2.1 -r1.11.2.2 *** intpyapp.py 29 Aug 2008 06:16:41 -0000 1.11.2.1 --- intpyapp.py 31 Aug 2008 08:31:27 -0000 1.11.2.2 *************** *** 302,306 **** # def OnDDECommand(self, command): - print ("DDE Executing", repr(command)) try: exec(command + "\n") --- 302,305 ---- |
From: Roger U. <ru...@us...> - 2008-08-31 02:11:13
|
Update of /cvsroot/pywin32/pywin32/win32/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6485 Modified Files: Tag: py3k PyWinTypes.h PyWinTypesmodule.cpp PythonService.cpp Log Message: Move GetPythonTraceback into pywintypes (used from win32com, win32ui, and pythonservice) Index: PyWinTypesmodule.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/src/PyWinTypesmodule.cpp,v retrieving revision 1.39.2.1 retrieving revision 1.39.2.2 diff -C2 -d -r1.39.2.1 -r1.39.2.2 *** PyWinTypesmodule.cpp 29 Aug 2008 04:59:26 -0000 1.39.2.1 --- PyWinTypesmodule.cpp 31 Aug 2008 02:11:22 -0000 1.39.2.2 *************** *** 1066,1067 **** --- 1066,1162 ---- } + // Function to format a python traceback into a character string. + #define GPEM_ERROR(what) {errorMsg = "<Error getting traceback - " ## what ## ">";goto done;} + char *GetPythonTraceback(PyObject *exc_type, PyObject *exc_value, PyObject *exc_tb) + { + // Sleep (30000); // Time enough to attach the debugger (barely) + char *result = NULL; + char *errorMsg = NULL; + PyObject *modStringIO = NULL; + PyObject *modTB = NULL; + PyObject *obFuncStringIO = NULL; + PyObject *obStringIO = NULL; + PyObject *obFuncTB = NULL; + PyObject *argsTB = NULL; + PyObject *obResult = NULL; + + /* Import the modules we need - cStringIO and traceback */ + #if (PY_VERSION_HEX < 0x03000000) + modStringIO = PyImport_ImportModule("cStringIO"); + #else + // In py3k, cStringIO is in "io" + modStringIO = PyImport_ImportModule("io"); + #endif + + if (modStringIO==NULL) GPEM_ERROR("cant import cStringIO"); + modTB = PyImport_ImportModule("traceback"); + if (modTB==NULL) GPEM_ERROR("cant import traceback"); + + /* Construct a cStringIO object */ + obFuncStringIO = PyObject_GetAttrString(modStringIO, "StringIO"); + if (obFuncStringIO==NULL) GPEM_ERROR("cant find cStringIO.StringIO"); + obStringIO = PyObject_CallObject(obFuncStringIO, NULL); + if (obStringIO==NULL) GPEM_ERROR("cStringIO.StringIO() failed"); + + /* Get the traceback.print_exception function, and call it. */ + obFuncTB = PyObject_GetAttrString(modTB, "print_exception"); + if (obFuncTB==NULL) GPEM_ERROR("cant find traceback.print_exception"); + argsTB = Py_BuildValue("OOOOO" + #if (PY_VERSION_HEX >= 0x03000000) + "i" + // Py3k has added an undocumented 'chain' argument which defaults to True + // and causes all kinds of exceptions while trying to print a goddam exception + #endif + , + exc_type ? exc_type : Py_None, + exc_value ? exc_value : Py_None, + exc_tb ? exc_tb : Py_None, + Py_None, // limit + obStringIO + #if (PY_VERSION_HEX >= 0x03000000) + ,0 // Goddam undocumented 'chain' param, which defaults to True + #endif + ); + if (argsTB==NULL) GPEM_ERROR("cant make print_exception arguments"); + + obResult = PyObject_CallObject(obFuncTB, argsTB); + if (obResult==NULL){ + // Chain parameter when True causes traceback.print_exception to fail, leaving no + // way to see what the original problem is, or even what error print_exc raises + // PyObject *t, *v, *tb; + // PyErr_Fetch(&t, &v, &tb); + // PyUnicodeObject *uo=(PyUnicodeObject *)v; + // DebugBreak(); + GPEM_ERROR("traceback.print_exception() failed"); + } + /* Now call the getvalue() method in the StringIO instance */ + Py_DECREF(obFuncStringIO); + obFuncStringIO = PyObject_GetAttrString(obStringIO, "getvalue"); + if (obFuncStringIO==NULL) GPEM_ERROR("cant find getvalue function"); + Py_DECREF(obResult); + obResult = PyObject_CallObject(obFuncStringIO, NULL); + if (obResult==NULL) GPEM_ERROR("getvalue() failed."); + + /* And it should be a string all ready to go - duplicate it. */ + if (PyString_Check(obResult)) + result = strdup(PyString_AsString(obResult)); + #if (PY_VERSION_HEX >= 0x03000000) + else if (PyUnicode_Check(obResult)) + result = strdup(_PyUnicode_AsString(obResult)); + #endif + else + GPEM_ERROR("getvalue() did not return a string"); + + done: + if (result==NULL && errorMsg != NULL) + result = strdup(errorMsg); + Py_XDECREF(modStringIO); + Py_XDECREF(modTB); + Py_XDECREF(obFuncStringIO); + Py_XDECREF(obStringIO); + Py_XDECREF(obFuncTB); + Py_XDECREF(argsTB); + Py_XDECREF(obResult); + return result; + } + Index: PyWinTypes.h =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/src/PyWinTypes.h,v retrieving revision 1.51.2.1 retrieving revision 1.51.2.2 diff -C2 -d -r1.51.2.1 -r1.51.2.2 *** PyWinTypes.h 29 Aug 2008 04:59:25 -0000 1.51.2.1 --- PyWinTypes.h 31 Aug 2008 02:11:22 -0000 1.51.2.2 *************** *** 112,115 **** --- 112,118 ---- #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); + #include <tchar.h> /* Index: PythonService.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/src/PythonService.cpp,v retrieving revision 1.24.2.2 retrieving revision 1.24.2.3 diff -C2 -d -r1.24.2.2 -r1.24.2.3 *** PythonService.cpp 30 Aug 2008 22:33:34 -0000 1.24.2.2 --- PythonService.cpp 31 Aug 2008 02:11:22 -0000 1.24.2.3 *************** *** 1392,1490 **** } - #define GPEM_ERROR(what) {errorMsg = "<Error getting traceback - " ## what ## ">";goto done;} - static char *GetPythonTraceback(PyObject *exc_type, PyObject *exc_value, PyObject *exc_tb) - { - // Sleep (30000); // Time enough to attach the debugger (barely) - PyErr_Clear(); - char *result = NULL; - char *errorMsg = NULL; - PyObject *modStringIO = NULL; - PyObject *modTB = NULL; - PyObject *obFuncStringIO = NULL; - PyObject *obStringIO = NULL; - PyObject *obFuncTB = NULL; - PyObject *argsTB = NULL; - PyObject *obResult = NULL; - - /* Import the modules we need - cStringIO and traceback */ - #if (PY_VERSION_HEX < 0x03000000) - modStringIO = PyImport_ImportModule("cStringIO"); - #else - // In py3k, cStringIO is in "io" - modStringIO = PyImport_ImportModule("io"); - #endif - - if (modStringIO==NULL) GPEM_ERROR("cant import cStringIO"); - modTB = PyImport_ImportModule("traceback"); - if (modTB==NULL) GPEM_ERROR("cant import traceback"); - - /* Construct a cStringIO object */ - obFuncStringIO = PyObject_GetAttrString(modStringIO, "StringIO"); - if (obFuncStringIO==NULL) GPEM_ERROR("cant find cStringIO.StringIO"); - obStringIO = PyObject_CallObject(obFuncStringIO, NULL); - if (obStringIO==NULL) GPEM_ERROR("cStringIO.StringIO() failed"); - - /* Get the traceback.print_exception function, and call it. */ - obFuncTB = PyObject_GetAttrString(modTB, "print_exception"); - if (obFuncTB==NULL) GPEM_ERROR("cant find traceback.print_exception"); - argsTB = Py_BuildValue("OOOOO" - #if (PY_VERSION_HEX >= 0x03000000) - "i" - // Py3k has added an undocumented 'chain' argument which defaults to True - // and causes all kinds of exceptions while trying to print a goddam exception - #endif - , - exc_type ? exc_type : Py_None, - exc_value ? exc_value : Py_None, - exc_tb ? exc_tb : Py_None, - Py_None, // limit - obStringIO - #if (PY_VERSION_HEX >= 0x03000000) - ,0 // Goddam undocumented 'chain' param, which defaults to True - #endif - ); - if (argsTB==NULL) GPEM_ERROR("cant make print_exception arguments"); - - obResult = PyObject_CallObject(obFuncTB, argsTB); - if (obResult==NULL){ - // Chain parameter when True causes traceback.print_exception to fail, leaving no - // way to see what the original problem is, or even what error print_exc raises - // PyObject *t, *v, *tb; - // PyErr_Fetch(&t, &v, &tb); - // PyUnicodeObject *uo=(PyUnicodeObject *)v; - // DebugBreak(); - GPEM_ERROR("traceback.print_exception() failed"); - } - /* Now call the getvalue() method in the StringIO instance */ - Py_DECREF(obFuncStringIO); - obFuncStringIO = PyObject_GetAttrString(obStringIO, "getvalue"); - if (obFuncStringIO==NULL) GPEM_ERROR("cant find getvalue function"); - Py_DECREF(obResult); - obResult = PyObject_CallObject(obFuncStringIO, NULL); - if (obResult==NULL) GPEM_ERROR("getvalue() failed."); - - /* And it should be a string all ready to go - duplicate it. */ - if (PyString_Check(obResult)) - result = strdup(PyString_AsString(obResult)); - #if (PY_VERSION_HEX >= 0x03000000) - else if (PyUnicode_Check(obResult)) - result = strdup(_PyUnicode_AsString(obResult)); - #endif - else - GPEM_ERROR("getvalue() did not return a string"); - - done: - if (result==NULL && errorMsg != NULL) - result = strdup(errorMsg); - Py_XDECREF(modStringIO); - Py_XDECREF(modTB); - Py_XDECREF(obFuncStringIO); - Py_XDECREF(obStringIO); - Py_XDECREF(obFuncTB); - Py_XDECREF(argsTB); - Py_XDECREF(obResult); - return result; - } - static void ReportPythonError(DWORD code) { --- 1392,1395 ---- |
From: Roger U. <ru...@us...> - 2008-08-31 02:10:55
|
Update of /cvsroot/pywin32/pywin32/com/win32com/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6276 Modified Files: Tag: py3k ErrorUtils.cpp Log Message: Move GetPythonTraceback into pywintypes (used from win32com, win32ui, and pythonservice) Index: ErrorUtils.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/win32com/src/ErrorUtils.cpp,v retrieving revision 1.30.2.1 retrieving revision 1.30.2.2 diff -C2 -d -r1.30.2.1 -r1.30.2.2 *** ErrorUtils.cpp 29 Aug 2008 08:27:37 -0000 1.30.2.1 --- ErrorUtils.cpp 31 Aug 2008 02:11:04 -0000 1.30.2.2 *************** *** 369,465 **** } - //////////////////////////////////////////////////////////////////////// - // Some logging functions - //////////////////////////////////////////////////////////////////////// - /* Obtains a string from a Python traceback. - This is the exact same string as "traceback.print_exc" would return. - - Pass in a Python traceback object (probably obtained from PyErr_Fetch()) - Result is a string which must be free'd using PyMem_Free() - */ - #define TRACEBACK_FETCH_ERROR(what) {errMsg = what; goto done;} - - char *PyTraceback_AsString(PyObject *exc_tb) - { - char *errMsg = NULL; /* holds a local error message */ - char *result = NULL; /* a valid, allocated result. */ - PyObject *modStringIO = NULL; - PyObject *modTB = NULL; - PyObject *obFuncStringIO = NULL; - PyObject *obStringIO = NULL; - PyObject *obFuncTB = NULL; - PyObject *argsTB = NULL; - PyObject *obResult = NULL; - - /* Import the modules we need - cStringIO and traceback */ - modStringIO = PyImport_ImportModule("cStringIO"); - if (modStringIO==NULL) - TRACEBACK_FETCH_ERROR("cant import cStringIO\n"); - - modTB = PyImport_ImportModule("traceback"); - if (modTB==NULL) - TRACEBACK_FETCH_ERROR("cant import traceback\n"); - /* Construct a cStringIO object */ - obFuncStringIO = PyObject_GetAttrString(modStringIO, "StringIO"); - if (obFuncStringIO==NULL) - TRACEBACK_FETCH_ERROR("cant find cStringIO.StringIO\n"); - obStringIO = PyObject_CallObject(obFuncStringIO, NULL); - if (obStringIO==NULL) - TRACEBACK_FETCH_ERROR("cStringIO.StringIO() failed\n"); - /* Get the traceback.print_exception function, and call it. */ - obFuncTB = PyObject_GetAttrString(modTB, "print_tb"); - if (obFuncTB==NULL) - TRACEBACK_FETCH_ERROR("cant find traceback.print_tb\n"); - - argsTB = Py_BuildValue("OOO", - exc_tb ? exc_tb : Py_None, - Py_None, - obStringIO); - if (argsTB==NULL) - TRACEBACK_FETCH_ERROR("cant make print_tb arguments\n"); - - obResult = PyObject_CallObject(obFuncTB, argsTB); - if (obResult==NULL) - TRACEBACK_FETCH_ERROR("traceback.print_tb() failed\n"); - /* Now call the getvalue() method in the StringIO instance */ - Py_DECREF(obFuncStringIO); - obFuncStringIO = PyObject_GetAttrString(obStringIO, "getvalue"); - if (obFuncStringIO==NULL) - TRACEBACK_FETCH_ERROR("cant find getvalue function\n"); - Py_DECREF(obResult); - obResult = PyObject_CallObject(obFuncStringIO, NULL); - if (obResult==NULL) - TRACEBACK_FETCH_ERROR("getvalue() failed.\n"); - - /* And it should be a string all ready to go - duplicate it. */ - if (!PyString_Check(obResult)) - TRACEBACK_FETCH_ERROR("getvalue() did not return a string\n"); - - { // a temp scope so I can use temp locals. - char *tempResult = PyString_AsString(obResult); - result = (char *)PyMem_Malloc(strlen(tempResult)+1); - if (result==NULL) - TRACEBACK_FETCH_ERROR("memory error duplicating the traceback string\n"); - - strcpy(result, tempResult); - } // end of temp scope. - done: - /* All finished - first see if we encountered an error */ - if (result==NULL && errMsg != NULL) { - result = (char *)PyMem_Malloc(strlen(errMsg)+1); - if (result != NULL) - /* if it does, not much we can do! */ - strcpy(result, errMsg); - } - Py_XDECREF(modStringIO); - Py_XDECREF(modTB); - Py_XDECREF(obFuncStringIO); - Py_XDECREF(obStringIO); - Py_XDECREF(obFuncTB); - Py_XDECREF(argsTB); - Py_XDECREF(obResult); - return result; - } - void PyCom_StreamMessage(const char *pszMessageText) { --- 369,372 ---- *************** *** 481,484 **** --- 388,392 ---- PyErr_Restore(typ, val, tb); } + BOOL VLogF_Logger(PyObject *logger, const char *log_method, const TCHAR *prefix, const TCHAR *fmt, va_list argptr) *************** *** 545,574 **** void _LogException(PyObject *exc_typ, PyObject *exc_val, PyObject *exc_tb) { ! if (exc_tb) { ! const char *szTraceback = PyTraceback_AsString(exc_tb); ! if (szTraceback == NULL) ! PyCom_StreamMessage("Can't get the traceback info!"); ! else { ! PyCom_StreamMessage(traceback_prefix); ! PyCom_StreamMessage(szTraceback); ! PyMem_Free((void *)szTraceback); ! } ! } ! PyObject *temp = PyObject_Str(exc_typ); ! if (temp) { ! PyCom_StreamMessage(PyString_AsString(temp)); ! Py_DECREF(temp); ! } else ! PyCom_StreamMessage("Can't convert exception to a string!"); ! PyCom_StreamMessage(": "); ! if (exc_val != NULL) { ! temp = PyObject_Str(exc_val); ! if (temp) { ! PyCom_StreamMessage(PyString_AsString(temp)); ! Py_DECREF(temp); ! } else ! PyCom_StreamMessage("Can't convert exception value to a string!"); ! } ! PyCom_StreamMessage("\n"); } --- 453,459 ---- void _LogException(PyObject *exc_typ, PyObject *exc_val, PyObject *exc_tb) { ! char *szTraceback = GetPythonTraceback(exc_typ, exc_val, exc_tb); ! PyCom_StreamMessage(szTraceback); ! free(szTraceback); } |
From: Roger U. <ru...@us...> - 2008-08-31 02:10:41
|
Update of /cvsroot/pywin32/pywin32/Pythonwin In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6098 Modified Files: Tag: py3k win32uimodule.cpp Log Message: Move GetPythonTraceback into pywintypes (used from win32com, win32ui, and pythonservice) Index: win32uimodule.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/Pythonwin/win32uimodule.cpp,v retrieving revision 1.39.2.1 retrieving revision 1.39.2.2 diff -C2 -d -r1.39.2.1 -r1.39.2.2 *** win32uimodule.cpp 29 Aug 2008 05:53:29 -0000 1.39.2.1 --- win32uimodule.cpp 31 Aug 2008 02:10:51 -0000 1.39.2.2 *************** *** 453,529 **** } - #define GPEM_ERROR(what) {errorMsg = "<Error getting traceback - " ## what ## ">";goto done;} - static char *GetPythonTraceback(PyObject *exc_tb) - { - char *result = NULL; - char *errorMsg = NULL; - PyObject *modStringIO = NULL; - PyObject *modTB = NULL; - PyObject *obFuncStringIO = NULL; - PyObject *obStringIO = NULL; - PyObject *obFuncTB = NULL; - PyObject *argsTB = NULL; - PyObject *obResult = NULL; - - /* Import the modules we need - cStringIO and traceback */ - #if (PY_VERSION_HEX < 0x03000000) - modStringIO = PyImport_ImportModule("cStringIO"); - #else - // In py3k, cStringIO is in "io" - modStringIO = PyImport_ImportModule("io"); - #endif - - if (modStringIO==NULL) GPEM_ERROR("cant import cStringIO"); - modTB = PyImport_ImportModule("traceback"); - if (modTB==NULL) GPEM_ERROR("cant import traceback"); - - /* Construct a cStringIO object */ - obFuncStringIO = PyObject_GetAttrString(modStringIO, "StringIO"); - if (obFuncStringIO==NULL) GPEM_ERROR("cant find cStringIO.StringIO"); - obStringIO = PyObject_CallObject(obFuncStringIO, NULL); - if (obStringIO==NULL) GPEM_ERROR("cStringIO.StringIO() failed"); - - /* Get the traceback.print_exception function, and call it. */ - obFuncTB = PyObject_GetAttrString(modTB, "print_tb"); - if (obFuncTB==NULL) GPEM_ERROR("cant find traceback.print_tb"); - argsTB = Py_BuildValue("OOO", - exc_tb ? exc_tb : Py_None, - Py_None, - obStringIO); - if (argsTB==NULL) GPEM_ERROR("cant make print_tb arguments"); - - obResult = PyObject_CallObject(obFuncTB, argsTB); - if (obResult==NULL) GPEM_ERROR("traceback.print_tb() failed"); - - /* Now call the getvalue() method in the StringIO instance */ - Py_DECREF(obFuncStringIO); - obFuncStringIO = PyObject_GetAttrString(obStringIO, "getvalue"); - if (obFuncStringIO==NULL) GPEM_ERROR("cant find getvalue function"); - Py_DECREF(obResult); - obResult = PyObject_CallObject(obFuncStringIO, NULL); - if (obResult==NULL) GPEM_ERROR("getvalue() failed."); - - /* And it should be a string all ready to go - duplicate it. */ - if (PyString_Check(obResult)) - result = strdup(PyString_AsString(obResult)); - #if (PY_VERSION_HEX >= 0x03000000) - else if (PyUnicode_Check(obResult)) - result = strdup(_PyUnicode_AsString(obResult)); - #endif - else - GPEM_ERROR("getvalue() did not return a string"); - - done: - if (result==NULL && errorMsg != NULL) - result = strdup(errorMsg); - Py_XDECREF(modStringIO); - Py_XDECREF(modTB); - Py_XDECREF(obFuncStringIO); - Py_XDECREF(obStringIO); - Py_XDECREF(obFuncTB); - Py_XDECREF(argsTB); - Py_XDECREF(obResult); - return result; - } BOOL DisplayPythonTraceback(PyObject *exc_type, PyObject *exc_val, PyObject *exc_tb, const TCHAR *extraTitleMsg = NULL) --- 453,456 ---- *************** *** 558,562 **** GetDlgItem(IDCANCEL)->ShowWindow(SW_HIDE); GetDlgItem(IDOK)->SetWindowText(_T("Close")); ! char *msg = GetPythonTraceback(m_exc_tb); char *msg_free = msg; // Translate '\n' to '\r\n' - do it the easy way! --- 485,489 ---- GetDlgItem(IDCANCEL)->ShowWindow(SW_HIDE); GetDlgItem(IDOK)->SetWindowText(_T("Close")); ! char *msg = GetPythonTraceback(m_exc_type, m_exc_value, m_exc_tb); char *msg_free = msg; // Translate '\n' to '\r\n' - do it the easy way! *************** *** 568,574 **** useMsg += *msg; free(msg_free); - useMsg += GetReprText(m_exc_type); - useMsg += ": "; - useMsg += GetReprText(m_exc_value); #ifdef _DEBUG { --- 495,498 ---- |
From: Roger U. <ru...@us...> - 2008-08-30 22:37:57
|
Update of /cvsroot/pywin32/pywin32 In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18640 Modified Files: Tag: py3k ToDo.txt Log Message: Couple more odds and ends to finish up Index: ToDo.txt =================================================================== RCS file: /cvsroot/pywin32/pywin32/Attic/ToDo.txt,v retrieving revision 1.1.2.2 retrieving revision 1.1.2.3 diff -C2 -d -r1.1.2.2 -r1.1.2.3 *** ToDo.txt 29 Aug 2008 07:06:02 -0000 1.1.2.2 --- ToDo.txt 30 Aug 2008 22:38:06 -0000 1.1.2.3 *************** *** 14,17 **** --- 14,19 ---- Several types set Py_TPFLAGS_BASETYPE but do not have required infrastructure to actually subclass. + servicemanager (PythonService.cpp) - Py_SetProgram and PySys_SetArgv don't work for 2.x, need char * args + but __argv is NULL *************** *** 46,48 **** Figure out a clean way to switch between commctrl.*A and commctrl.*W constants for hooking messages ! \ No newline at end of file --- 48,50 ---- Figure out a clean way to switch between commctrl.*A and commctrl.*W constants for hooking messages ! Add /ENTRY:wWinMainCRTStartup to linker args \ No newline at end of file |
From: Roger U. <ru...@us...> - 2008-08-30 22:33:25
|
Update of /cvsroot/pywin32/pywin32/win32/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16690 Modified Files: Tag: py3k PythonService.cpp Log Message: Get service framework working for py3k Index: PythonService.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/src/PythonService.cpp,v retrieving revision 1.24.2.1 retrieving revision 1.24.2.2 diff -C2 -d -r1.24.2.1 -r1.24.2.2 *** PythonService.cpp 29 Aug 2008 04:59:26 -0000 1.24.2.1 --- PythonService.cpp 30 Aug 2008 22:33:34 -0000 1.24.2.2 *************** *** 32,36 **** PYSERVICE_EXPORT BOOL PythonService_PrepareToHostMultiple(const TCHAR *service_name, PyObject *klass); PYSERVICE_EXPORT BOOL PythonService_StartServiceCtrlDispatcher(); ! PYSERVICE_EXPORT int PythonService_main(int argc, char **argv); TCHAR g_szEventSourceName[MAX_PATH] = _T("Python Service"); --- 32,36 ---- PYSERVICE_EXPORT BOOL PythonService_PrepareToHostMultiple(const TCHAR *service_name, PyObject *klass); PYSERVICE_EXPORT BOOL PythonService_StartServiceCtrlDispatcher(); ! PYSERVICE_EXPORT int PythonService_main(int argc, TCHAR **argv); TCHAR g_szEventSourceName[MAX_PATH] = _T("Python Service"); *************** *** 121,129 **** static PY_SERVICE_TABLE_ENTRY *FindPythonServiceEntry(LPCTSTR svcName); ! static PyObject *LoadPythonServiceClass(char *svcInitString); static PyObject *LoadPythonServiceInstance(PyObject *, DWORD dwArgc, LPTSTR *lpszArgv ); ! static BOOL LocatePythonServiceClassString( TCHAR *svcName, char *buf, int cchBuf); --- 121,129 ---- static PY_SERVICE_TABLE_ENTRY *FindPythonServiceEntry(LPCTSTR svcName); ! static PyObject *LoadPythonServiceClass(TCHAR *svcInitString); static PyObject *LoadPythonServiceInstance(PyObject *, DWORD dwArgc, LPTSTR *lpszArgv ); ! static BOOL LocatePythonServiceClassString( TCHAR *svcName, TCHAR *buf, int cchBuf); *************** *** 542,546 **** ! #define ADD_CONSTANT(tok) PyModule_AddIntConstant(dict, #tok, tok) extern "C" __declspec(dllexport) --- 542,546 ---- ! #define ADD_CONSTANT(tok) if (PyModule_AddIntConstant(module, #tok, tok) == -1) RETURN_ERROR; extern "C" __declspec(dllexport) *************** *** 637,645 **** // This, however, shouldnt be a problem, as Python itself // knows how to get the .EXE name when it needs. #if (PY_VERSION_HEX < 0x03000000) ! Py_SetProgramName(__argv[0]); #else ! Py_SetProgramName(__wargv[0]); ! #endif; #ifdef BUILD_FREEZE --- 637,649 ---- // This, however, shouldnt be a problem, as Python itself // knows how to get the .EXE name when it needs. + int pyargc; #if (PY_VERSION_HEX < 0x03000000) ! pyargc = __argc; ! char **pyargv = __argv; #else ! WCHAR **pyargv; ! pyargv = CommandLineToArgvW(GetCommandLineW(), &pyargc); ! #endif ! Py_SetProgramName(pyargv[0]); #ifdef BUILD_FREEZE *************** *** 652,662 **** // Ensure we are set for threading. PyEval_InitThreads(); ! #if (PY_VERSION_HEX < 0x03000000) - PySys_SetArgv(__argc, __argv); initservicemanager(); #else - PySys_SetArgv(__argc, __wargv); PyInit_servicemanager(); #endif } --- 656,665 ---- // Ensure we are set for threading. PyEval_InitThreads(); ! PySys_SetArgv(pyargc, pyargv); #if (PY_VERSION_HEX < 0x03000000) initservicemanager(); #else PyInit_servicemanager(); + LocalFree(pyargv); #endif } *************** *** 865,870 **** pe = PythonServiceTable; if (!pe->klass) { ! char svcInitBuf[256]; ! LocatePythonServiceClassString(lpszArgv[0], svcInitBuf, sizeof(svcInitBuf)); pe->klass = LoadPythonServiceClass(svcInitBuf); } --- 868,873 ---- pe = PythonServiceTable; if (!pe->klass) { ! TCHAR svcInitBuf[256]; ! LocatePythonServiceClassString(lpszArgv[0], svcInitBuf, sizeof(svcInitBuf)/sizeof(svcInitBuf[0])); pe->klass = LoadPythonServiceClass(svcInitBuf); } *************** *** 1072,1076 **** // the service has stopped, so exit. // ! int PythonService_main(int argc, char **argv) { // Note that we don't know the service name we are hosting yet! --- 1075,1079 ---- // the service has stopped, so exit. // ! int PythonService_main(int argc, TCHAR **argv) { // Note that we don't know the service name we are hosting yet! *************** *** 1111,1116 **** { #ifndef BUILD_FREEZE ! if ( _stricmp( "register", argv[1]+1 ) == 0 || ! _stricmp( "install", argv[1]+1 ) == 0 ) { // Get out of here. --- 1114,1119 ---- { #ifndef BUILD_FREEZE ! if ( _tcsicmp( _T("register"), argv[1]+1 ) == 0 || ! _tcsicmp( _T("install"), argv[1]+1 ) == 0 ) { // Get out of here. *************** *** 1118,1122 **** } #endif ! if ( _stricmp( "debug", argv[1]+1 ) == 0 ) { /* Debugging the service. If this EXE has a service name embedded in it, use it, otherwise insist one is passed on the --- 1121,1125 ---- } #endif ! if ( _tcsicmp( _T("debug"), argv[1]+1 ) == 0 ) { /* Debugging the service. If this EXE has a service name embedded in it, use it, otherwise insist one is passed on the *************** *** 1179,1191 **** // Given the string in form [path\]module.ClassName, return // an instance of the class ! PyObject *LoadPythonServiceClass(char *svcInitString) { ! char valueBuf[512]; // Initialize Python PyService_InitPython(); ! strncpy(valueBuf, svcInitString, sizeof(valueBuf)); // Find the last "\\" ! char *sep = strrchr(valueBuf, '\\'); ! char *fname; if (sep) { *sep = '\0'; --- 1182,1194 ---- // Given the string in form [path\]module.ClassName, return // an instance of the class ! PyObject *LoadPythonServiceClass(TCHAR *svcInitString) { ! TCHAR valueBuf[512]; // Initialize Python PyService_InitPython(); ! _tcsncpy(valueBuf, svcInitString, sizeof(valueBuf)/sizeof(valueBuf[0])); // Find the last "\\" ! TCHAR *sep = _tcsrchr(valueBuf, _T('\\')); ! TCHAR *fname; if (sep) { *sep = '\0'; *************** *** 1197,1201 **** return NULL; } ! PyObject *obNew = PyString_FromString(valueBuf); if (obNew==NULL) { ReportPythonError(PYS_E_NO_MEMORY_FOR_SYS_PATH); --- 1200,1204 ---- return NULL; } ! PyObject *obNew = PyWinObject_FromTCHAR(valueBuf); if (obNew==NULL) { ReportPythonError(PYS_E_NO_MEMORY_FOR_SYS_PATH); *************** *** 1208,1212 **** } // Find the last "." in the name, and assume it is a module name. ! char *classNamePos = strrchr(fname, '.'); if (classNamePos==NULL) { ReportError(PYS_E_CANT_LOCATE_MODULE_NAME); --- 1211,1215 ---- } // Find the last "." in the name, and assume it is a module name. ! TCHAR *classNamePos = _tcsrchr(fname, _T('.')); if (classNamePos==NULL) { ReportError(PYS_E_CANT_LOCATE_MODULE_NAME); *************** *** 1217,1226 **** // PyImport_ImportModule("foo.bar") will return 'foo', not bar. *classNamePos++ = '\0'; ! module = PyImport_ImportModule(fname); if (module==NULL) { ReportPythonError(E_PYS_NO_MODULE); return NULL; } ! PyObject *pyclass = PyObject_GetAttrString(module, classNamePos); Py_DECREF(module); if (pyclass==NULL) { --- 1220,1233 ---- // PyImport_ImportModule("foo.bar") will return 'foo', not bar. *classNamePos++ = '\0'; ! PyObject *obname=PyWinObject_FromTCHAR(fname); ! module = PyImport_Import(obname); ! Py_DECREF(obname); if (module==NULL) { ReportPythonError(E_PYS_NO_MODULE); return NULL; } ! PyObject *obclassName=PyWinObject_FromTCHAR(classNamePos); ! PyObject *pyclass = PyObject_GetAttr(module, obclassName); ! Py_DECREF(obclassName); Py_DECREF(module); if (pyclass==NULL) { *************** *** 1270,1281 **** } ! BOOL LocatePythonServiceClassString( TCHAR *svcName, char *buf, int cchBuf) { ! char keyName[1024]; // If not error loading, and not an empty string // (NOTE: Embedding a resource to specify the service name is // deprecated) ! if (LoadStringA(GetModuleHandle(NULL), RESOURCE_SERVICE_NAME, buf, cchBuf)>1) // Get out of here now! return TRUE; --- 1277,1288 ---- } ! BOOL LocatePythonServiceClassString( TCHAR *svcName, TCHAR *buf, int cchBuf) { ! TCHAR keyName[1024]; // If not error loading, and not an empty string // (NOTE: Embedding a resource to specify the service name is // deprecated) ! if (LoadString(GetModuleHandle(NULL), RESOURCE_SERVICE_NAME, buf, cchBuf)>1) // Get out of here now! return TRUE; *************** *** 1283,1294 **** HKEY key = NULL; BOOL ok = TRUE; ! wsprintfA(keyName, "System\\CurrentControlSet\\Services\\%S\\PythonClass", svcName); ! if (RegOpenKeyA(HKEY_LOCAL_MACHINE, keyName, &key) != ERROR_SUCCESS) { ReportAPIError(PYS_E_API_CANT_LOCATE_PYTHON_CLASS); return FALSE; } DWORD dataType; ! DWORD valueBufSize = cchBuf; ! if ((RegQueryValueExA(key, "", 0, &dataType, (LPBYTE)buf, &valueBufSize)!=ERROR_SUCCESS) || (dataType != REG_SZ)) { ReportAPIError(PYS_E_API_CANT_LOCATE_PYTHON_CLASS); --- 1290,1303 ---- HKEY key = NULL; BOOL ok = TRUE; ! _sntprintf(keyName, sizeof(keyName)/sizeof(keyName[0]), ! _T("System\\CurrentControlSet\\Services\\%s\\PythonClass"), ! svcName); ! if (RegOpenKey(HKEY_LOCAL_MACHINE, keyName, &key) != ERROR_SUCCESS) { ReportAPIError(PYS_E_API_CANT_LOCATE_PYTHON_CLASS); return FALSE; } DWORD dataType; ! DWORD valueBufSize = cchBuf * sizeof(TCHAR); ! if ((RegQueryValueEx(key, NULL, 0, &dataType, (LPBYTE)buf, &valueBufSize)!=ERROR_SUCCESS) || (dataType != REG_SZ)) { ReportAPIError(PYS_E_API_CANT_LOCATE_PYTHON_CLASS); *************** *** 1384,1389 **** #define GPEM_ERROR(what) {errorMsg = "<Error getting traceback - " ## what ## ">";goto done;} ! static char *GetPythonTraceback(PyObject *exc_tb) { char *result = NULL; char *errorMsg = NULL; --- 1393,1400 ---- #define GPEM_ERROR(what) {errorMsg = "<Error getting traceback - " ## what ## ">";goto done;} ! static char *GetPythonTraceback(PyObject *exc_type, PyObject *exc_value, PyObject *exc_tb) { + // Sleep (30000); // Time enough to attach the debugger (barely) + PyErr_Clear(); char *result = NULL; char *errorMsg = NULL; *************** *** 1397,1401 **** --- 1408,1418 ---- /* Import the modules we need - cStringIO and traceback */ + #if (PY_VERSION_HEX < 0x03000000) modStringIO = PyImport_ImportModule("cStringIO"); + #else + // In py3k, cStringIO is in "io" + modStringIO = PyImport_ImportModule("io"); + #endif + if (modStringIO==NULL) GPEM_ERROR("cant import cStringIO"); modTB = PyImport_ImportModule("traceback"); *************** *** 1409,1423 **** /* Get the traceback.print_exception function, and call it. */ ! obFuncTB = PyObject_GetAttrString(modTB, "print_tb"); ! if (obFuncTB==NULL) GPEM_ERROR("cant find traceback.print_tb"); ! argsTB = Py_BuildValue("OOO", ! exc_tb ? exc_tb : Py_None, ! Py_None, ! obStringIO); ! if (argsTB==NULL) GPEM_ERROR("cant make print_tb arguments"); obResult = PyObject_CallObject(obFuncTB, argsTB); ! if (obResult==NULL) GPEM_ERROR("traceback.print_tb() failed"); ! /* Now call the getvalue() method in the StringIO instance */ Py_DECREF(obFuncStringIO); --- 1426,1459 ---- /* Get the traceback.print_exception function, and call it. */ ! obFuncTB = PyObject_GetAttrString(modTB, "print_exception"); ! if (obFuncTB==NULL) GPEM_ERROR("cant find traceback.print_exception"); ! argsTB = Py_BuildValue("OOOOO" ! #if (PY_VERSION_HEX >= 0x03000000) ! "i" ! // Py3k has added an undocumented 'chain' argument which defaults to True ! // and causes all kinds of exceptions while trying to print a goddam exception ! #endif ! , ! exc_type ? exc_type : Py_None, ! exc_value ? exc_value : Py_None, ! exc_tb ? exc_tb : Py_None, ! Py_None, // limit ! obStringIO ! #if (PY_VERSION_HEX >= 0x03000000) ! ,0 // Goddam undocumented 'chain' param, which defaults to True ! #endif ! ); ! if (argsTB==NULL) GPEM_ERROR("cant make print_exception arguments"); obResult = PyObject_CallObject(obFuncTB, argsTB); ! if (obResult==NULL){ ! // Chain parameter when True causes traceback.print_exception to fail, leaving no ! // way to see what the original problem is, or even what error print_exc raises ! // PyObject *t, *v, *tb; ! // PyErr_Fetch(&t, &v, &tb); ! // PyUnicodeObject *uo=(PyUnicodeObject *)v; ! // DebugBreak(); ! GPEM_ERROR("traceback.print_exception() failed"); ! } /* Now call the getvalue() method in the StringIO instance */ Py_DECREF(obFuncStringIO); *************** *** 1429,1435 **** /* And it should be a string all ready to go - duplicate it. */ ! if (!PyString_Check(obResult)) GPEM_ERROR("getvalue() did not return a string"); ! result = strdup(PyString_AsString(obResult)); done: if (result==NULL && errorMsg != NULL) --- 1465,1477 ---- /* And it should be a string all ready to go - duplicate it. */ ! if (PyString_Check(obResult)) ! result = strdup(PyString_AsString(obResult)); ! #if (PY_VERSION_HEX >= 0x03000000) ! else if (PyUnicode_Check(obResult)) ! result = strdup(_PyUnicode_AsString(obResult)); ! #endif ! else GPEM_ERROR("getvalue() did not return a string"); ! done: if (result==NULL && errorMsg != NULL) *************** *** 1448,1458 **** { if (PyErr_Occurred()) { ! LPTSTR inserts[4]; ! inserts[3] = NULL; // terminate array PyObject *type, *value, *traceback; PyErr_Fetch(&type, &value, &traceback); ! WCHAR *szTracebackUse = L"<No memory!>"; // default. ! WCHAR *szTraceback = NULL; // to be freed. ! char *szmbTraceback = GetPythonTraceback(traceback); if (szmbTraceback) { int tb_len = strlen(szmbTraceback) + 1; --- 1490,1499 ---- { if (PyErr_Occurred()) { ! LPTSTR inserts[4] = {NULL, NULL, NULL, NULL}; PyObject *type, *value, *traceback; PyErr_Fetch(&type, &value, &traceback); ! TCHAR *szTracebackUse = L"<No memory!>"; // default. ! TCHAR *szTraceback = NULL; // to be freed. ! char *szmbTraceback = GetPythonTraceback(type, value, traceback); if (szmbTraceback) { int tb_len = strlen(szmbTraceback) + 1; *************** *** 1467,1480 **** } inserts[0] = szTracebackUse; - PyObject *obStr = PyObject_Str(type); - PyWinObject_AsWCHAR(obStr, inserts+1); - Py_XDECREF(obStr); - obStr = PyObject_Str(value); - PyWinObject_AsWCHAR(PyObject_Str(obStr), inserts+2); - Py_XDECREF(obStr); ReportError(code, (LPCTSTR *)inserts); if (szTraceback) free(szTraceback); ! PyWinObject_FreeWCHAR(inserts[1]); ! PyWinObject_FreeWCHAR(inserts[2]); if (bServiceDebug) { // If debugging, restore for traceback print, PyErr_Restore(type, value, traceback); --- 1508,1514 ---- } inserts[0] = szTracebackUse; ReportError(code, (LPCTSTR *)inserts); if (szTraceback) free(szTraceback); ! if (bServiceDebug) { // If debugging, restore for traceback print, PyErr_Restore(type, value, traceback); *************** *** 1608,1612 **** // Our EXE entry point. ! int main(int argc, char **argv) { PyObject *module, *f; --- 1642,1646 ---- // Our EXE entry point. ! int _tmain(int argc, TCHAR **argv) { PyObject *module, *f; *************** *** 1616,1619 **** --- 1650,1654 ---- Py_Initialize(); PyEval_InitThreads(); + module = PyImport_ImportModule("site"); // ??? remove when site bug is fixed ??? module = PyImport_ImportModule("servicemanager"); if (!module) goto failed; *************** *** 1621,1630 **** Py_DECREF(module); if (!f) goto failed; ! if (!PyString_Check(f)) { ! PyErr_SetString(PyExc_TypeError, "servicemanager.__file__ is not a string!"); goto failed; } ! // now get the handle to the DLL, and call the main function. ! hmod = GetModuleHandleA(PyString_AsString(f)); Py_DECREF(f); if (!hmod) { --- 1656,1670 ---- Py_DECREF(module); if (!f) goto failed; ! ! // now get the handle to the DLL, and call the main function. ! if (PyString_Check(f)) ! hmod = GetModuleHandleA(PyString_AsString(f)); ! else if (PyUnicode_Check(f)) ! hmod = GetModuleHandleW(PyUnicode_AsUnicode(f)); ! else{ ! PyErr_SetString(PyExc_TypeError, "servicemanager.__file__ is not a string or unicode !"); goto failed; } ! Py_DECREF(f); if (!hmod) { *************** *** 1642,1647 **** PyEval_ReleaseThread(threadState); ! typedef int (* FNPythonService_main)(int argc, char **argv); ! return ((FNPythonService_main)proc)(argc, argv); failed: fprintf(stderr, "PythonService was unable to locate the service manager. " --- 1682,1687 ---- PyEval_ReleaseThread(threadState); ! typedef int (* FNPythonService_main)(int argc, TCHAR **argv); ! return (*(FNPythonService_main)proc)(argc, argv); failed: fprintf(stderr, "PythonService was unable to locate the service manager. " |
From: Vernon C. <kf...@us...> - 2008-08-29 14:45:17
|
Update of /cvsroot/pywin32/pywin32 In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv32213 Modified Files: CHANGES.txt Log Message: adodbapi update to version 2.2. Index: CHANGES.txt =================================================================== RCS file: /cvsroot/pywin32/pywin32/CHANGES.txt,v retrieving revision 1.26 retrieving revision 1.27 diff -C2 -d -r1.26 -r1.27 *** CHANGES.txt 10 Aug 2008 13:13:20 -0000 1.26 --- CHANGES.txt 29 Aug 2008 14:45:26 -0000 1.27 *************** *** 17,20 **** --- 17,24 ---- Since build 211: ---------------- + * adodbapi updated to version 2.2. Supports Iron Python. Better + logic for .rowcount. New .cvtString convertion method. Multiple + result sets work correctly. Code cleanup and eliminate classic + classes and string exceptions. Fix CoInitialize bug. * Remove warning about VARDESCs in obscure circumstances when using |
From: Vernon C. <kf...@us...> - 2008-08-29 14:32:37
|
Update of /cvsroot/pywin32/pywin32/adodbapi/tests In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv26776 Modified Files: adodbapitest.py Log Message: update to version 2.2. Works on Iron Python improved test for multiple result sets, Decimal data, user defined convertions. Index: adodbapitest.py =================================================================== RCS file: /cvsroot/pywin32/pywin32/adodbapi/tests/adodbapitest.py,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** adodbapitest.py 6 Aug 2008 16:18:06 -0000 1.2 --- adodbapitest.py 29 Aug 2008 14:32:44 -0000 1.3 *************** *** 25,34 **** import unittest ! import win32com.client import adodbapi import adodbapitestconfig ! #adodbapi.verbose = True import types --- 25,39 ---- import unittest ! ! try: ! import win32com.client ! win32 = True ! except ImportError: ! win32 = False import adodbapi import adodbapitestconfig ! #adodbapi.adodbapi.verbose = True import types *************** *** 408,419 **** class TestADOwithSQLServer(CommonDBTests): def setUp(self): - try: - conn=win32com.client.Dispatch("ADODB.Connection") - except: - self.fail('SetUpError: Is MDAC installed?') - try: - conn.Open(adodbapitestconfig.connStrSQLServer) - except: - self.fail('SetUpError: Can not connect to the testdatabase, all other tests will fail...\nAdo error:%s' % conn.Errors(0)) self.conn=adodbapi.connect(adodbapitestconfig.connStrSQLServer) self.engine = 'MSSQL' --- 413,416 ---- *************** *** 525,537 **** class TestADOwithAccessDB(CommonDBTests): def setUp(self): ! try: ! adoConn=win32com.client.Dispatch("ADODB.Connection") ! except: ! self.fail('SetUpError: Is MDAC installed?') ! ! try: ! adoConn.Open(adodbapitestconfig.connStrAccess) ! except: ! self.fail('SetUpError: Can not connect to the testdatabase, all other tests will fail...\nAdo error:%s' % adoConn.Errors(0)) self.engine = 'ACCESS' --- 522,526 ---- class TestADOwithAccessDB(CommonDBTests): def setUp(self): ! self.conn = adodbapi.connect(adodbapitestconfig.connStrAccess) self.engine = 'ACCESS' *************** *** 546,571 **** pass self.conn=None ! def getConnection(self): ! return adodbapi.connect(adodbapitestconfig.connStrAccess) def testOkConnect(self): c=adodbapi.connect(adodbapitestconfig.connStrAccess) assert c != None class TestADOwithMySql(CommonDBTests): def setUp(self): try: ! adoConn=win32com.client.Dispatch("ADODB.Connection") except: ! self.fail('SetUpError: Is MDAC installed?') try: ! adoConn.Open(adodbapitestconfig.connStrMySql) except: ! self.fail('SetUpError: Can not connect to the testdatabase, all other tests will fail...\nAdo error:%s' % adoConn.Errors(0)) ! self.engine = 'MySQL' def getConnection(self): ! return adodbapi.connect(adodbapitestconfig.connStrMySql) def testOkConnect(self): --- 535,565 ---- pass self.conn=None ! def getConnection(self): ! return self.conn def testOkConnect(self): c=adodbapi.connect(adodbapitestconfig.connStrAccess) assert c != None + c.close() class TestADOwithMySql(CommonDBTests): def setUp(self): + self.conn = adodbapi.connect(adodbapitestconfig.connStrMySql) + self.engine = 'MySQL' + + def tearDown(self): try: ! self.conn.rollback() except: ! pass try: ! self.conn.close() except: ! pass ! self.conn=None def getConnection(self): ! return self.conn def testOkConnect(self): *************** *** 649,662 **** def testCOMDate(self): ! t=time.localtime(time.mktime((2002,6,28,18,15,01, 4,31+28+31+30+31+28,-1))) # Fri, 28 Jun 2002 18:15:01 +0000 cmd=self.tc.COMDate(t) ! assert abs(cmd - 37435.7604282) < 1.0/24,"more than an hour wrong" - def testDateObjectFromCOMDate(self): cmd=self.tc.DateObjectFromCOMDate(37435.7604282) ! t1=time.localtime(time.mktime((2002,6,28,18,14,01, 4,31+28+31+30+31+28,-1))) ! t2=time.localtime(time.mktime((2002,6,28,18,16,01, 4,31+28+31+30+31+28,-1))) assert t1<cmd<t2,cmd --- 643,656 ---- def testCOMDate(self): ! mk = time.mktime((2002,6,28,18,15,01, 4,31+28+31+30+31+28,-1)) ! t=time.localtime(mk) # Fri, 28 Jun 2002 18:15:01 +0000 cmd=self.tc.COMDate(t) ! assert abs(cmd - 37435.7604282) < 1.0/24,"%f more than an hour wrong" % cmd def testDateObjectFromCOMDate(self): cmd=self.tc.DateObjectFromCOMDate(37435.7604282) ! t1=time.gmtime(time.mktime((2002,6,28,12,14,01, 4,31+28+31+30+31+28,-1))) ! t2=time.gmtime(time.mktime((2002,6,28,12,16,01, 4,31+28+31+30+31+28,-1))) assert t1<cmd<t2,cmd *************** *** 687,692 **** cmd=self.tc.COMDate(t) assert abs(cmd - 37435.7604282) < 1.0/24,"more than an hour wrong" ! ! def testDateObjectFromCOMDate(self): cmd=self.tc.DateObjectFromCOMDate(37435.7604282) --- 681,685 ---- cmd=self.tc.COMDate(t) assert abs(cmd - 37435.7604282) < 1.0/24,"more than an hour wrong" ! def testDateObjectFromCOMDate(self): cmd=self.tc.DateObjectFromCOMDate(37435.7604282) |
From: Vernon C. <kf...@us...> - 2008-08-29 14:31:09
|
Update of /cvsroot/pywin32/pywin32/adodbapi/tests In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv26290 Modified Files: adodbapitestconfig.py Log Message: update to version 2.2. Index: adodbapitestconfig.py =================================================================== RCS file: /cvsroot/pywin32/pywin32/adodbapi/tests/adodbapitestconfig.py,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** adodbapitestconfig.py 6 Aug 2008 16:18:06 -0000 1.2 --- adodbapitestconfig.py 29 Aug 2008 14:31:19 -0000 1.3 *************** *** 4,9 **** doAccessTest = True ! doSqlServerTest = True ! doMySqlTest = True try: #If mx extensions are installed, use mxDateTime --- 4,9 ---- doAccessTest = True ! doSqlServerTest = False #True ! doMySqlTest = False #True try: #If mx extensions are installed, use mxDateTime *************** *** 21,25 **** print 'Error: adodbapi 2.1 requires Python 2.3' ! iterateOverTimeTests=True if doAccessTest: --- 21,25 ---- print 'Error: adodbapi 2.1 requires Python 2.3' ! iterateOverTimeTests=False #True if doAccessTest: *************** *** 36,40 **** from win32com.client import constants win32 = True ! except importError: #perhaps we are running IronPython win32 = False if not win32: --- 36,40 ---- from win32com.client import constants win32 = True ! except ImportError: #perhaps we are running IronPython win32 = False if not win32: *************** *** 45,49 **** # Create a brand-new database - what is the story with these? for suffix in (".36", ".35", ".30"): - ###print 'trying DAO.DBEngine',suffix try: if win32: --- 45,48 ---- *************** *** 51,55 **** else: type= Type.GetTypeFromProgID("DAO.DBEngine" + suffix) ! dbe = Activator.CreateInstance(typ) break except: --- 50,54 ---- else: type= Type.GetTypeFromProgID("DAO.DBEngine" + suffix) ! dbe = Activator.CreateInstance(type) break except: |
From: Vernon C. <kf...@us...> - 2008-08-29 14:30:45
|
Update of /cvsroot/pywin32/pywin32/adodbapi In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25906 Modified Files: readme.txt Log Message: update to version 2.2. Index: readme.txt =================================================================== RCS file: /cvsroot/pywin32/pywin32/adodbapi/readme.txt,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** readme.txt 6 Aug 2008 16:18:06 -0000 1.2 --- readme.txt 29 Aug 2008 14:30:55 -0000 1.3 *************** *** 1,5 **** Project ------- ! adodbapi -- win32 inclusion version A Python DB-API 2.0 module that makes it easy to use Microsoft ADO --- 1,5 ---- Project ------- ! adodbapi A Python DB-API 2.0 module that makes it easy to use Microsoft ADO *************** *** 16,22 **** Prerequisites: ! * Python 2.3 or higher. ! * (this version included within) Mark Hammond's win32all python for windows extensions. Whats new in version 2.1.1? --- 16,35 ---- Prerequisites: ! * C Python 2.3 or higher ! and pywin32 (Mark Hammond's python for windows extensions.) ! Note: as of 2.1.1, adodbapi is included in pywin32 versions 211 and later. ! or ! Iron Python 2.0b4 or higher. + Whats new in version 2.2 + 1. Runs on Iron Python 2.0b4 with a few restrictions. It will not handle Longs or BLOB correcly, + and has some date/time problems (using the "time" module as opposed to "datetime"). + Bug reports have been submitted to Iron Python, which, if fixed, will remove all restrictions. + 2. More agressive at making sure to retrieve Numeric and Currency colums as decimal.Decimal. + 3. Has a new conversion module. To make Numerics retrieve as strings, execute: + adodbapi.variantConversions[adodbapi.adNumeric] = adodbapi.cvtString + 4. Switch to new-style classes and eliminate string exceptions. + 5. Lots of cleanup in the code and the unit test. + 6. More agressive at determining .rowcount after an operation. Whats new in version 2.1.1? |
From: Vernon C. <kf...@us...> - 2008-08-29 14:30:18
|
Update of /cvsroot/pywin32/pywin32/adodbapi In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25843 Modified Files: adodbapi.py Log Message: update to version 2.2. Support for Iron Python. Better .rowcount logic. added cvtString method. code cleanup Index: adodbapi.py =================================================================== RCS file: /cvsroot/pywin32/pywin32/adodbapi/adodbapi.py,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** adodbapi.py 6 Aug 2008 16:18:06 -0000 1.2 --- adodbapi.py 29 Aug 2008 14:30:26 -0000 1.3 *************** *** 1,3 **** ! """adodbapi v2.1.1 - A python DB API 2.0 interface to Microsoft ADO Copyright (C) 2002 Henrik Ekelund --- 1,3 ---- ! """adodbapi v2.2 - A python DB API 2.0 interface to Microsoft ADO Copyright (C) 2002 Henrik Ekelund *************** *** 42,47 **** return win32com.client.Dispatch(dispatch) win32 = True ! except ImportError: #perhaps running on IronPython (someday) ! from System import Activator, Type def Dispatch(dispatch): type = Type.GetTypeFromProgID(dispatch) --- 42,50 ---- return win32com.client.Dispatch(dispatch) win32 = True ! DBNull = types.NoneType ! DateTime = types.NotImplementedType #impossible value ! except ImportError: # implies running on IronPython ! from System import Activator, Type, DBNull, DateTime ! from clr import Reference def Dispatch(dispatch): type = Type.GetTypeFromProgID(dispatch) *************** *** 60,66 **** raise errorclass(errorvalue) ! ! class TimeConverter: def __init__(self): #Use self.types to compare if an input parameter is a datetime self.types = (type(self.Date(2000,1,1)), --- 63,69 ---- raise errorclass(errorvalue) ! class TimeConverter(object): def __init__(self): + self._ordinal_1899_12_31=datetime.date(1899,12,31).toordinal()-1 #Use self.types to compare if an input parameter is a datetime self.types = (type(self.Date(2000,1,1)), *************** *** 69,93 **** def COMDate(self,obj): 'Returns a ComDate from a datetime in inputformat' ! raise "Abstract class" def DateObjectFromCOMDate(self,comDate): 'Returns an object of the wanted type from a ComDate' ! raise "Abstract class" def Date(self,year,month,day): "This function constructs an object holding a date value. " ! raise "Abstract class" def Time(self,hour,minute,second): "This function constructs an object holding a time value. " ! raise "Abstract class" def Timestamp(self,year,month,day,hour,minute,second): "This function constructs an object holding a time stamp value. " ! raise "Abstract class" def DateObjectToIsoFormatString(self,obj): "This function should return a string in the format 'YYYY-MM-dd HH:MM:SS:ms' (ms optional) " ! raise "Abstract class" --- 72,96 ---- def COMDate(self,obj): 'Returns a ComDate from a datetime in inputformat' ! raise NotImplementedError #"Abstract class" def DateObjectFromCOMDate(self,comDate): 'Returns an object of the wanted type from a ComDate' ! raise NotImplementedError #"Abstract class" def Date(self,year,month,day): "This function constructs an object holding a date value. " ! raise NotImplementedError #"Abstract class" def Time(self,hour,minute,second): "This function constructs an object holding a time value. " ! raise NotImplementedError #"Abstract class" def Timestamp(self,year,month,day,hour,minute,second): "This function constructs an object holding a time stamp value. " ! raise NotImplementedError #"Abstract class" def DateObjectToIsoFormatString(self,obj): "This function should return a string in the format 'YYYY-MM-dd HH:MM:SS:ms' (ms optional) " ! raise NotImplementedError #"Abstract class" *************** *** 113,117 **** class pythonDateTimeConverter(TimeConverter): # datetime module is available in Python 2.3 def __init__(self): - self._ordinal_1899_12_31=datetime.date(1899,12,31).toordinal()-1 TimeConverter.__init__(self) --- 116,119 ---- *************** *** 127,131 **** def DateObjectFromCOMDate(self,comDate): #ComDate is number of days since 1899-12-31 ! fComDate=float(comDate) millisecondsperday=86400000 # 24*60*60*1000 integerPart = int(fComDate) --- 129,136 ---- def DateObjectFromCOMDate(self,comDate): #ComDate is number of days since 1899-12-31 ! if isinstance(comDate,DateTime): ! fComDate = comDate.ToOADate() ! else: ! fComDate=float(comDate) millisecondsperday=86400000 # 24*60*60*1000 integerPart = int(fComDate) *************** *** 133,141 **** if floatpart == 0.0: return datetime.date.fromordinal(integerPart + self._ordinal_1899_12_31) ! dte=datetime.datetime.fromordinal(integerPart + self._ordinal_1899_12_31) ! dte=dte+datetime.timedelta(milliseconds=floatpart*millisecondsperday) return dte - def Date(self,year,month,day): return datetime.date(year,month,day) --- 138,145 ---- if floatpart == 0.0: return datetime.date.fromordinal(integerPart + self._ordinal_1899_12_31) ! dte=datetime.datetime.fromordinal(integerPart + self._ordinal_1899_12_31) \ ! + datetime.timedelta(milliseconds=floatpart*millisecondsperday) return dte def Date(self,year,month,day): return datetime.date(year,month,day) *************** *** 148,154 **** def COMDateFromTuple(self,YMDHMSmsTuple): ! t=pythoncom.MakeTime(YMDHMSmsTuple) ! return float(t) ! def DateObjectToIsoFormatString(self,obj): if isinstance(obj,datetime.datetime): --- 152,164 ---- def COMDateFromTuple(self,YMDHMSmsTuple): ! d = datetime.date(YMDHMSmsTuple[0],YMDHMSmsTuple[1],YMDHMSmsTuple[2]) ! integerPart = d.toordinal() - self._ordinal_1899_12_31 ! ms = ((YMDHMSmsTuple[3]*60 \ ! +YMDHMSmsTuple[4])*60 \ ! +YMDHMSmsTuple[5])*1000 \ ! +YMDHMSmsTuple[6] ! fractPart = ms / 86400000.0 ! return integerPart + fractPart ! def DateObjectToIsoFormatString(self,obj): if isinstance(obj,datetime.datetime): *************** *** 163,188 **** class pythonTimeConverter(TimeConverter): def __init__(self): - year,month,day,hour,minute,second,weekday,julianday,daylightsaving=time.gmtime(0) - self.com1970=self.COMDateFromTuple((year,month,day,hour,minute,second)) - daysInMonth=[31,28,31,30,31,30,31,30,31,30,31,30] - cumulative=0 - self.monthCumDays={} - for i in range(12): - self.monthCumDays[i+1]=cumulative - cumulative+=daysInMonth[i] TimeConverter.__init__(self) ! ! def COMDate(self,timeobj): ! return float(pythoncom.MakeTime(time.mktime(timeobj))) ! ! def COMDateFromTuple(self,YMDHMSmsTuple): ! t=pythoncom.MakeTime(YMDHMSmsTuple) ! return float(t) ! def DateObjectFromCOMDate(self,comDate): 'Returns ticks since 1970' secondsperday=86400 # 24*60*60 ! #ComDate is number of days since 1899-12-31 ! t=time.gmtime(secondsperday*(float(comDate)-self.com1970 )) return t #year,month,day,hour,minute,second,weekday,julianday,daylightsaving=t --- 173,203 ---- class pythonTimeConverter(TimeConverter): def __init__(self): TimeConverter.__init__(self) ! if win32: ! def COMDate(self,timeobj): ! return float(pythoncom.MakeTime(time.mktime(timeobj))) ! def COMDateFromTuple(self,YMDHMSmsTuple): ! t=pythoncom.MakeTime(YMDHMSmsTuple) ! return float(t) ! else: #iron Python ! def COMDate(self,timeobj): ! return self.COMDateFromTuple(timeobj) ! def COMDateFromTuple(self,t): ! d = datetime.date(t[0],t[1],t[2]) ! integerPart = d.toordinal() - self._ordinal_1899_12_31 ! sec = (t[3]*60 + t[4])*60 + t[5] ! fractPart = sec / 86400.0 ! return integerPart + fractPart ! def DateObjectFromCOMDate(self,comDate): 'Returns ticks since 1970' + if isinstance(comDate,DateTime): + fcomDate = comDate.ToOADate() + else: + fcomDate = float(comDate) secondsperday=86400 # 24*60*60 ! #ComDate is number of days since 1899-12-31, gmtime epoch is 1970-1-1 = 25569 days ! ##if not win32: fcomDate += (2.0/24) # fudge an error in iron python gmtime ! t=time.gmtime(secondsperday*(fcomDate-25569.0)) return t #year,month,day,hour,minute,second,weekday,julianday,daylightsaving=t *************** *** 194,203 **** def Timestamp(self,year,month,day,hour,minute,second): ! julian=self.monthCumDays[month] + day ! if month>2: ! julian+=calendar.isleap(year) ! weekday=calendar.weekday(year,month,day) ! daylightsaving=-1 ! return time.localtime(time.mktime((year,month,day,hour,minute,second,weekday,julian,daylightsaving))) def DateObjectToIsoFormatString(self,obj): --- 209,213 ---- def Timestamp(self,year,month,day,hour,minute,second): ! return time.localtime(time.mktime((year,month,day,hour,minute,second,0,0,-1))) def DateObjectToIsoFormatString(self,obj): *************** *** 244,248 **** def connect(connstr, timeout=30): #v2.1 Simons "Connection string as in the ADO documentation, SQL timeout in seconds" - global verbose try: if win32: --- 254,257 ---- *************** *** 305,316 **** # It may be one of the above ! class Connection: def __init__(self,adoConn): self.adoConn=adoConn self.supportsTransactions=False for indx in range(adoConn.Properties.Count): ! if adoConn.Properties(indx).Name == 'Transaction DDL' \ ! and adoConn.Properties(indx).Value != 0: #v2.1 Albrecht ! self.supportsTransactions=True self.adoConn.CursorLocation = defaultCursorLocation #v2.1 Rose if self.supportsTransactions: --- 314,326 ---- # It may be one of the above ! class Connection(object): def __init__(self,adoConn): self.adoConn=adoConn self.supportsTransactions=False for indx in range(adoConn.Properties.Count): ! if adoConn.Properties[indx].Name == 'Transaction DDL': ! if adoConn.Properties[indx].Value != 0: #v2.1 Albrecht ! self.supportsTransactions=True ! break self.adoConn.CursorLocation = defaultCursorLocation #v2.1 Rose if self.supportsTransactions: *************** *** 319,323 **** self.errorhandler=None self.messages=[] - global verbose if verbose: print 'adodbapi New connection at %X' % id(self) --- 329,332 ---- *************** *** 410,416 **** def printADOerrors(self): j=self.adoConn.Errors.Count ! print 'ADO Errors:(%i)' % j for i in range(j): ! e=self.adoConn.Errors(i) print 'Description: %s' % e.Description print 'Number: %s ' % e.Number --- 419,426 ---- def printADOerrors(self): j=self.adoConn.Errors.Count ! if j: ! print 'ADO Errors:(%i)' % j for i in range(j): ! e=self.adoConn.Errors[i] print 'Description: %s' % e.Description print 'Number: %s ' % e.Number *************** *** 433,437 **** ! class Cursor: description=None ## This read-only attribute is a sequence of 7-item sequences. --- 443,447 ---- ! class Cursor(object): description=None ## This read-only attribute is a sequence of 7-item sequences. *************** *** 491,497 **** retLst=[] for i in range(adoCommand.Parameters.Count): ! p=adoCommand.Parameters(i) if verbose > 2: ! 'return', p.Name, p.Type, p.Direction, repr(p.Value) type_code=p.Type pyObject=convertVariantToPython(p.Value,type_code) --- 501,507 ---- retLst=[] for i in range(adoCommand.Parameters.Count): ! p=adoCommand.Parameters[i] if verbose > 2: ! print 'return', p.Name, p.Type, p.Direction, repr(p.Value) type_code=p.Type pyObject=convertVariantToPython(p.Value,type_code) *************** *** 508,512 **** self.description=None else: - #self.rowcount=rs.RecordCount # Since the current implementation has a forward-only cursor, RecordCount will always return -1 # The ADO documentation hints that obtaining the recordcount may be timeconsuming --- 518,521 ---- *************** *** 516,525 **** # Switching to client-side cursors will force a static cursor, # and rowcount will then be set accurately [Cole] - self.rowcount = -1 - ##self.rs=rs #removed v2.1.1 bkline nOfFields=rs.Fields.Count self.description=[] for i in range(nOfFields): ! f=rs.Fields(i) name=f.Name type_code=f.Type --- 525,532 ---- # Switching to client-side cursors will force a static cursor, # and rowcount will then be set accurately [Cole] nOfFields=rs.Fields.Count self.description=[] for i in range(nOfFields): ! f=rs.Fields[i] name=f.Name type_code=f.Type *************** *** 591,598 **** defaultParameterList = False except: # if it blows up ! #-- build own parameter list if verbose: print 'error in COM Refresh(). adodbapi building default parameter list' - defaultParameterList = True # we don't know whether db is expecting dates for i,elem in enumerate(parameters): name='p%i' % i --- 598,605 ---- defaultParameterList = False except: # if it blows up ! defaultParameterList = True ! if defaultParameterList: #-- build own parameter list if verbose: print 'error in COM Refresh(). adodbapi building default parameter list' for i,elem in enumerate(parameters): name='p%i' % i *************** *** 604,614 **** if verbose > 2: for i in range(self.cmd.Parameters.Count): ! P = self.cmd.Parameters(i) ! print 'adodbapi parameter attributes before=', P.Name, P.Type, P.Direction, P.Size if isStoredProcedureCall: cnt=self.cmd.Parameters.Count if cnt<>len(parameters): for i in range(cnt): ! if self.cmd.Parameters(i).Direction == adParamReturnValue: returnValueIndex=i break --- 611,621 ---- if verbose > 2: for i in range(self.cmd.Parameters.Count): ! P = self.cmd.Parameters[i] ! print 'adodbapi parameter attributes=', P.Name, P.Type, P.Direction, P.Size if isStoredProcedureCall: cnt=self.cmd.Parameters.Count if cnt<>len(parameters): for i in range(cnt): ! if self.cmd.Parameters[i].Direction == adParamReturnValue: returnValueIndex=i break *************** *** 617,621 **** if parmIndx == returnValueIndex: parmIndx+=1 ! p=self.cmd.Parameters(parmIndx) if p.Direction in [adParamInput,adParamInputOutput,adParamUnknown]: tp = type(elem) --- 624,630 ---- if parmIndx == returnValueIndex: parmIndx+=1 ! p=self.cmd.Parameters[parmIndx] ! if verbose > 2: ! print 'Parameter %d ADOtype %d, python %s' % (parmIndx,p.Type,type(elem)) if p.Direction in [adParamInput,adParamInputOutput,adParamUnknown]: tp = type(elem) *************** *** 630,645 **** p.Value = s p.Size = len(s) ! elif tp in types.StringTypes: #v2.1 Jevon if defaultParameterList: p.Value = elem - L = len(elem) else: ! L = min(len(elem),p.Size) #v2.1 Cole limit data to defined size p.Value = elem[:L] #v2.1 Jevon & v2.1 Cole if L>0: #v2.1 Cole something does not like p.Size as Zero p.Size = L #v2.1 Jevon elif tp == types.BufferType: #v2.1 Cole -- ADO BINARY - p.Size = len(elem) p.AppendChunk(elem) else: p.Value=elem --- 639,657 ---- p.Value = s p.Size = len(s) ! elif tp in types.StringTypes: #v2.1 Jevon ! L = len(elem) if defaultParameterList: p.Value = elem else: ! L = min(L,p.Size) #v2.1 Cole limit data to defined size p.Value = elem[:L] #v2.1 Jevon & v2.1 Cole if L>0: #v2.1 Cole something does not like p.Size as Zero p.Size = L #v2.1 Jevon elif tp == types.BufferType: #v2.1 Cole -- ADO BINARY p.AppendChunk(elem) + elif isinstance(elem,decimal.Decimal): #v2.2 Cole + s = str(elem) + p.Value = s + p.Size = len(s) else: p.Value=elem *************** *** 647,655 **** print 'Parameter %d type %d stored as: %s' % (parmIndx,p.Type,repr(p.Value)) parmIndx = -2 # kludge to prevent exception handler picking out one parameter ! ! # ----- the actual SQL is executed here --- ! adoRetVal=self.cmd.Execute() # ----- ------------------------------- --- ! except (Exception), e: tbk = u'\n--ADODBAPI\n' if parmIndx >= 0: --- 659,672 ---- print 'Parameter %d type %d stored as: %s' % (parmIndx,p.Type,repr(p.Value)) parmIndx = -2 # kludge to prevent exception handler picking out one parameter ! ! # ----- the actual SQL is executed here --- ! if win32: ! adoRetVal=self.cmd.Execute() ! else: #Iron Python ! ra = Reference[int]() ! rs = self.cmd.Execute(ra) ! adoRetVal=(rs,ra.Value) #return a tuple like win32 does # ----- ------------------------------- --- ! except Exception, e: tbk = u'\n--ADODBAPI\n' if parmIndx >= 0: *************** *** 665,680 **** self._raiseCursorError(DatabaseError,tracebackhistory) return ! rs=adoRetVal[0] ! ##self.rowcount=adoRetVal[1] # NOTE: usually will be -1 for SELECT :-( ! recs=adoRetVal[1] #[begin Jorgensen ] ## but it breaks unit test ! ## skip over empty record sets to get to one that isn't empty ! ##while rs and rs.State == adStateClosed: ! ## try: ! ## rs, recs = rs.NextRecordset() ! ## except: ! ## break ! self.rowcount=recs #[end Jorgensen] ! self._makeDescriptionFromRS(rs) --- 682,692 ---- self._raiseCursorError(DatabaseError,tracebackhistory) return ! rs=adoRetVal[0] ! try: ! self.rowcount = rs.RecordCount ! except: ! self.rowcount = adoRetVal[1] ! self._makeDescriptionFromRS(rs) *************** *** 758,768 **** returnList=[] i=0 ! for descTuple in d: ! # Desctuple =(name, type_code, display_size, internal_size, precision, scale, null_ok). ! type_code=descTuple[1] ! returnList.append([convertVariantToPython(r,type_code) for r in ado_results[i]]) ! i+=1 ! return tuple(zip(*returnList)) ! def fetchone(self): --- 770,788 ---- returnList=[] i=0 ! if win32: ! for descTuple in d: ! # Desctuple =(name, type_code, display_size, internal_size, precision, scale, null_ok). ! type_code=descTuple[1] ! returnList.append([convertVariantToPython(r,type_code) for r in ado_results[i]]) ! i+=1 ! return tuple(zip(*returnList)) ! else: #Iron Python ! type_codes = [descTuple[1] for descTuple in d] ! for j in range(len(ado_results)/len(d)): ! L = [] ! for i in range(len(d)): ! L.append(convertVariantToPython(ado_results[i,j],type_codes[i])) ! returnList.append(tuple(L)) ! return tuple(returnList) def fetchone(self): *************** *** 831,843 **** return else: ! try: #[begin 2.1 ekelund] ! rsTuple=self.rs.NextRecordset() # ! except pywintypes.com_error, exc: # return appropriate error ! self._raiseCursorError(NotSupportedError, exc.args)#[end 2.1 ekelund] ! rs=rsTuple[0] ! if rs==None: ! return None self._makeDescriptionFromRS(rs) ! return 1 def setinputsizes(self,sizes): --- 851,871 ---- return else: ! if win32: ! try: #[begin 2.1 ekelund] ! rsTuple=self.rs.NextRecordset() # ! except pywintypes.com_error, exc: # return appropriate error ! self._raiseCursorError(NotSupportedError, exc.args)#[end 2.1 ekelund] ! rs=rsTuple[0] ! else: # iron ! try: ! rs = self.rs.NextRecordset() ! except TypeError: ! rs = None ! except Error, exc: ! self._raiseCursorError(NotSupportedError, exc.args) self._makeDescriptionFromRS(rs) ! if rs: ! return True ! return None def setinputsizes(self,sizes): *************** *** 852,857 **** #string format. Similar problems exist for "Row ID" columns or large binary items (e.g. blobs or RAW columns). #This presents problems for Python since the parameters to the executeXXX() method are untyped. ! #When the database module sees a Python string object, it doesn't know if it should be bound as a simple CHAR column, ! #as a raw BINARY item, or as a DATE. # #To overcome this problem, a module must provide the constructors defined below to create objects that can --- 880,885 ---- #string format. Similar problems exist for "Row ID" columns or large binary items (e.g. blobs or RAW columns). #This presents problems for Python since the parameters to the executeXXX() method are untyped. ! #When the database module sees a Python string object, it doesn't know if it should be bound as a simple CHAR ! #column, as a raw BINARY item, or as a DATE. # #To overcome this problem, a module must provide the constructors defined below to create objects that can *************** *** 879,889 **** """This function constructs an object holding a date value from the given ticks value (number of seconds since the epoch; see the documentation of the standard Python time module for details). """ ! return apply(Date,time.localtime(ticks)[:3]) ! def TimeFromTicks(ticks): """This function constructs an object holding a time value from the given ticks value (number of seconds since the epoch; see the documentation of the standard Python time module for details). """ ! return apply(Time,time.localtime(ticks)[3:6]) def TimestampFromTicks(ticks): --- 907,916 ---- """This function constructs an object holding a date value from the given ticks value (number of seconds since the epoch; see the documentation of the standard Python time module for details). """ ! return apply(Date,time.gmtime(ticks)[:3]) def TimeFromTicks(ticks): """This function constructs an object holding a time value from the given ticks value (number of seconds since the epoch; see the documentation of the standard Python time module for details). """ ! return apply(Time,time.gmtime(ticks)[3:6]) def TimestampFromTicks(ticks): *************** *** 891,895 **** ticks value (number of seconds since the epoch; see the documentation of the standard Python time module for details). """ ! return apply(Timestamp,time.localtime(ticks)[:6]) def Binary(aString): --- 918,922 ---- ticks value (number of seconds since the epoch; see the documentation of the standard Python time module for details). """ ! return apply(Timestamp,time.gmtime(ticks)[:6]) def Binary(aString): *************** *** 910,972 **** if tp in dateconverter.types: return adDate raise DataError - def cvtCurrency((hi, lo), decimal=2): #special for type adCurrency - if lo < 0: - lo += (2L ** 32) - # was: return round((float((long(hi) << 32) + lo))/10000.0,decimal) - return decimal.Decimal((long(hi) << 32) + lo)/decimal.Decimal(1000) #v2.1 Cole - - def cvtNumeric(variant): #all v2.1 Cole - try: - return decimal.Decimal(variant) - except (ValueError,TypeError): - pass - try: - europeVsUS=str(variant).replace(",",".") - return decimal.Decimal(europeVsUS) - except (ValueError,TypeError): - pass - - def cvtFloat(variant): - try: - return float(variant) - except (ValueError,TypeError): - pass - # if type(variant)==types.TupleType: #v2.1 Cole (should be unnecessary now) - # return cvtCurrency(variant) - try: - europeVsUS=str(variant).replace(",",".") #v2.1 Cole - return float(europeVsUS) - except (ValueError,TypeError): - pass - - def identity(x): return x - - class VariantConversionMap(dict): - def __init__(self, aDict): - for k, v in aDict.iteritems(): - self[k] = v # we must call __setitem__ - - def __setitem__(self, adoType, cvtFn): - "don't make adoType a string :-)" - try: # user passed us a tuple, set them individually - for type in adoType: - dict.__setitem__(self, type, cvtFn) - except TypeError: # single value - dict.__setitem__(self, adoType, cvtFn) - - def __getitem__(self, fromType): - try: - return dict.__getitem__(self, fromType) - except KeyError: - return identity - - def convertVariantToPython(variant, adType): - if variant is None: - return None - return variantConversions[adType](variant) - - adCmdText = 1 adCmdStoredProc = 4 --- 937,944 ---- if tp in dateconverter.types: return adDate + if tp == type(decimal.Decimal): + return adDecimal raise DataError adCmdText = 1 adCmdStoredProc = 4 *************** *** 1135,1140 **** } ! ! class DBAPITypeObject: def __init__(self,valuesTuple): self.values = valuesTuple --- 1107,1111 ---- } ! class DBAPITypeObject(object): def __init__(self,valuesTuple): self.values = valuesTuple *************** *** 1187,1198 **** types.NoneType: adEmpty, types.UnicodeType: adBSTR, ! types.BooleanType:adBoolean, #v2.1 Cole ! type(decimal.Decimal): adNumeric #v2.1 Cole } ! try: #If mx extensions are installed, use mxDateTime import mx.DateTime dateconverter=mxDateTimeConverter() ! except: #Python 2.3 or later, use datetimelibrary by default dateconverter=pythonDateTimeConverter() --- 1158,1168 ---- types.NoneType: adEmpty, types.UnicodeType: adBSTR, ! types.BooleanType:adBoolean #v2.1 Cole } ! try: # If mx extensions are installed, use mxDateTime import mx.DateTime dateconverter=mxDateTimeConverter() ! except: # use datetimelibrary by default dateconverter=pythonDateTimeConverter() *************** *** 1202,1210 **** return dateconverter.DateObjectFromCOMDate(v) variantConversions = VariantConversionMap( { adoDateTimeTypes : variantConvertDate, adoApproximateNumericTypes: cvtFloat, ! adCurrency: cvtCurrency, ! adoExactNumericTypes: identity, # use cvtNumeric to force decimal rather than unicode adoLongTypes : long, adoIntegerTypes: int, --- 1172,1251 ---- return dateconverter.DateObjectFromCOMDate(v) + # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + # functions to convert database values to Python objects + + def cvtString(variant): # use to get old action of adodbapi v1 if desired + if not win32: # iron python + try: + return variant.ToString() + except: + pass + return str(variant) + + def cvtNumeric(variant): #all v2.1 Cole + if not win32: # iron python + try: + return decimal.Decimal(variant.ToString()) + except: + pass + try: + return decimal.Decimal(variant) + except (ValueError,TypeError): + try: + europeVsUS=str(variant).replace(",",".") + return decimal.Decimal(europeVsUS) + except: + raise + except: + raise + + def cvtFloat(variant): + try: + return float(variant) + except (ValueError,TypeError): + try: + europeVsUS=str(variant).replace(",",".") #v2.1 Cole + return float(europeVsUS) + except: + raise + except: + raise + + def identity(x): return x + + class VariantConversionMap(dict): + def __init__(self, aDict): + for k, v in aDict.iteritems(): + self[k] = v # we must call __setitem__ + + def __setitem__(self, adoType, cvtFn): + "don't make adoType a string :-)" + try: # user passed us a tuple, set them individually + for type in adoType: + dict.__setitem__(self, type, cvtFn) + except TypeError: # single value + dict.__setitem__(self, adoType, cvtFn) + + def __getitem__(self, fromType): + try: + return dict.__getitem__(self, fromType) + except KeyError: + return identity + + def convertVariantToPython(variant, adType): + #if verbose > 2: + # print 'Converting type_code=%s, val=%s'%(adType,repr(variant)) + # print ' str=%s'%str(variant) + # print 'conversion=',repr(variantConversions[adType]) + if isinstance(variant,DBNull): + return None + return variantConversions[adType](variant) + + #initialize variantConversions dictionary used to convert SQL to Python variantConversions = VariantConversionMap( { adoDateTimeTypes : variantConvertDate, adoApproximateNumericTypes: cvtFloat, ! adCurrency: cvtNumeric, ! adoExactNumericTypes: cvtNumeric, # use cvtNumeric to force decimal rather than unicode adoLongTypes : long, adoIntegerTypes: int, |
From: Roger U. <ru...@us...> - 2008-08-29 09:15:30
|
Update of /cvsroot/pywin32/pywin32/com/win32com/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27766 Modified Files: Tag: py3k PythonCOM.cpp Log Message: Call PyType_Ready for Empty, Missing, and ArgNotFound Index: PythonCOM.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/win32com/src/PythonCOM.cpp,v retrieving revision 1.52.2.1 retrieving revision 1.52.2.2 diff -C2 -d -r1.52.2.1 -r1.52.2.2 *** PythonCOM.cpp 29 Aug 2008 08:27:37 -0000 1.52.2.1 --- PythonCOM.cpp 29 Aug 2008 09:15:38 -0000 1.52.2.2 *************** *** 2035,2038 **** --- 2035,2042 ---- PyDict_SetItemString(dict, "InterfaceNames", g_obPyCom_MapInterfaceNameToIID); + if (PyType_Ready(&PyOleEmptyType) == -1 + ||PyType_Ready(&PyOleMissingType) == -1 + ||PyType_Ready(&PyOleArgNotFoundType) == -1) + RETURN_ERROR; g_obEmpty = new PyOleEmpty; PyDict_SetItemString(dict, "Empty", g_obEmpty); |
From: Roger U. <ru...@us...> - 2008-08-29 08:58:45
|
Update of /cvsroot/pywin32/pywin32/com/win32com In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20885 Modified Files: Tag: py3k __init__.py decimal_23.py olectl.py storagecon.py universal.py Log Message: Changes to build for Py3k Index: decimal_23.py =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/win32com/decimal_23.py,v retrieving revision 1.1 retrieving revision 1.1.4.1 diff -C2 -d -r1.1 -r1.1.4.1 *** decimal_23.py 31 May 2005 12:36:01 -0000 1.1 --- decimal_23.py 29 Aug 2008 08:58:52 -0000 1.1.4.1 *************** *** 507,511 **** # From an integer ! if isinstance(value, (int,long)): if value >= 0: self._sign = 0 --- 507,511 ---- # From an integer ! if isinstance(value, (int,int)): if value >= 0: self._sign = 0 *************** *** 519,528 **** if isinstance(value, (list,tuple)): if len(value) != 3: ! raise ValueError, 'Invalid arguments' if value[0] not in (0,1): ! raise ValueError, 'Invalid sign' for digit in value[1]: ! if not isinstance(digit, (int,long)) or digit < 0: ! raise ValueError, "The second value in the tuple must be composed of non negative integer elements." self._sign = value[0] --- 519,528 ---- if isinstance(value, (list,tuple)): if len(value) != 3: ! raise ValueError('Invalid arguments') if value[0] not in (0,1): ! raise ValueError('Invalid sign') for digit in value[1]: ! if not isinstance(digit, (int,int)) or digit < 0: ! raise ValueError("The second value in the tuple must be composed of non negative integer elements.") self._sign = value[0] *************** *** 545,549 **** # From a string # REs insist on real strings, so we can too. ! if isinstance(value, basestring): if _isinfinity(value): self._exp = 'F' --- 545,549 ---- # From a string # REs insist on real strings, so we can too. ! if isinstance(value, str): if _isinfinity(value): self._exp = 'F' *************** *** 638,642 **** return 0 ! def __nonzero__(self): """Is the number non-zero? --- 638,642 ---- return 0 ! def __bool__(self): """Is the number non-zero? *************** *** 700,709 **** def __eq__(self, other): ! if not isinstance(other, (Decimal, int, long)): return False return self.__cmp__(other) == 0 def __ne__(self, other): ! if not isinstance(other, (Decimal, int, long)): return True return self.__cmp__(other) != 0 --- 700,709 ---- def __eq__(self, other): ! if not isinstance(other, (Decimal, int, int)): return False return self.__cmp__(other) == 0 def __ne__(self, other): ! if not isinstance(other, (Decimal, int, int)): return True return self.__cmp__(other) != 0 *************** *** 777,781 **** context = getcontext() ! tmp = map(str, self._int) numdigits = len(self._int) leftdigits = self._exp + numdigits --- 777,781 ---- context = getcontext() ! tmp = list(map(str, self._int)) numdigits = len(self._int) leftdigits = self._exp + numdigits *************** *** 1120,1124 **** op2 = _WorkRep(other) ! ans = Decimal( (resultsign, map(int, str(op1.int * op2.int)), resultexp)) if shouldround: ans = ans._fix(context) --- 1120,1124 ---- op2 = _WorkRep(other) ! ans = Decimal( (resultsign, list(map(int, str(op1.int * op2.int))), resultexp)) if shouldround: ans = ans._fix(context) *************** *** 1429,1433 **** return context._raise_error(InvalidContext) elif self._isinfinity(): ! raise OverflowError, "Cannot convert infinity to long" if self._exp >= 0: s = ''.join(map(str, self._int)) + '0'*self._exp --- 1429,1433 ---- return context._raise_error(InvalidContext) elif self._isinfinity(): ! raise OverflowError("Cannot convert infinity to long") if self._exp >= 0: s = ''.join(map(str, self._int)) + '0'*self._exp *************** *** 1444,1448 **** Equivalent to long(int(self)) """ ! return long(self.__int__()) def _fix(self, context): --- 1444,1448 ---- Equivalent to long(int(self)) """ ! return int(self.__int__()) def _fix(self, context): *************** *** 2132,2136 **** # get rounding method function: ! rounding_functions = [name for name in Decimal.__dict__.keys() if name.startswith('_round_')] for name in rounding_functions: #name is like _round_half_even, goes to the global ROUND_HALF_EVEN value. --- 2132,2136 ---- # get rounding method function: ! rounding_functions = [name for name in list(Decimal.__dict__.keys()) if name.startswith('_round_')] for name in rounding_functions: #name is like _round_half_even, goes to the global ROUND_HALF_EVEN value. *************** *** 2177,2181 **** traps = dict([(s,s in traps) for s in _signals]) del s ! for name, val in locals().items(): if val is None: setattr(self, name, copy.copy(getattr(DefaultContext, name))) --- 2177,2181 ---- traps = dict([(s,s in traps) for s in _signals]) del s ! for name, val in list(locals().items()): if val is None: setattr(self, name, copy.copy(getattr(DefaultContext, name))) *************** *** 2188,2193 **** s = [] s.append('Context(prec=%(prec)d, rounding=%(rounding)s, Emin=%(Emin)d, Emax=%(Emax)d, capitals=%(capitals)d' % vars(self)) ! s.append('flags=[' + ', '.join([f.__name__ for f, v in self.flags.items() if v]) + ']') ! s.append('traps=[' + ', '.join([t.__name__ for t, v in self.traps.items() if v]) + ']') return ', '.join(s) + ')' --- 2188,2193 ---- s = [] s.append('Context(prec=%(prec)d, rounding=%(rounding)s, Emin=%(Emin)d, Emax=%(Emax)d, capitals=%(capitals)d' % vars(self)) ! s.append('flags=[' + ', '.join([f.__name__ for f, v in list(self.flags.items()) if v]) + ']') ! s.append('traps=[' + ', '.join([t.__name__ for t, v in list(self.traps.items()) if v]) + ']') return ', '.join(s) + ')' *************** *** 2232,2236 **** # Errors should only be risked on copies of the context #self._ignored_flags = [] ! raise error, explanation def _ignore_all_flags(self): --- 2232,2236 ---- # Errors should only be risked on copies of the context #self._ignored_flags = [] ! raise error(explanation) def _ignore_all_flags(self): *************** *** 2255,2259 **** """A Context cannot be hashed.""" # We inherit object.__hash__, so we must deny this explicitly ! raise TypeError, "Cannot hash a Context." def Etiny(self): --- 2255,2259 ---- """A Context cannot be hashed.""" # We inherit object.__hash__, so we must deny this explicitly ! raise TypeError("Cannot hash a Context.") def Etiny(self): *************** *** 2877,2884 **** if isinstance(other, Decimal): return other ! if isinstance(other, (int, long)): return Decimal(other) ! raise TypeError, "You can interact Decimal only with int, long or Decimal data types." _infinity_map = { --- 2877,2884 ---- if isinstance(other, Decimal): return other ! if isinstance(other, (int, int)): return Decimal(other) ! raise TypeError("You can interact Decimal only with int, long or Decimal data types.") _infinity_map = { *************** *** 3028,3032 **** mantissa = intpart + fracpart ! tmp = map(int, mantissa) backup = tmp while tmp and tmp[0] == 0: --- 3028,3032 ---- mantissa = intpart + fracpart ! tmp = list(map(int, mantissa)) backup = tmp while tmp and tmp[0] == 0: Index: olectl.py =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/win32com/olectl.py,v retrieving revision 1.2 retrieving revision 1.2.4.1 diff -C2 -d -r1.2 -r1.2.4.1 *** olectl.py 10 Nov 2003 00:51:07 -0000 1.2 --- olectl.py 29 Aug 2008 08:58:52 -0000 1.2.4.1 *************** *** 9,13 **** def MAKE_SCODE(sev, fac, code): ! return int((long(-sev)<<31) | ((fac)<<16) | ((code))) def STD_CTL_SCODE(n): --- 9,13 ---- def MAKE_SCODE(sev, fac, code): ! return int((int(-sev)<<31) | ((fac)<<16) | ((code))) def STD_CTL_SCODE(n): Index: __init__.py =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/win32com/__init__.py,v retrieving revision 1.10 retrieving revision 1.10.4.1 diff -C2 -d -r1.10 -r1.10.4.1 *** __init__.py 20 Jan 2004 01:55:42 -0000 1.10 --- __init__.py 29 Aug 2008 08:58:52 -0000 1.10.4.1 *************** *** 105,115 **** # we must have a __gen_path__, but may not have a gen_py module - # set that up. ! if not sys.modules.has_key("win32com.gen_py"): # Create a "win32com.gen_py", but with a custom __path__ ! import new ! gen_py = new.module("win32com.gen_py") gen_py.__path__ = [ __gen_path__ ] sys.modules[gen_py.__name__]=gen_py ! del new gen_py = sys.modules["win32com.gen_py"] --- 105,115 ---- # we must have a __gen_path__, but may not have a gen_py module - # set that up. ! if "win32com.gen_py" not in sys.modules: # Create a "win32com.gen_py", but with a custom __path__ ! import imp ! gen_py = imp.new_module("win32com.gen_py") gen_py.__path__ = [ __gen_path__ ] sys.modules[gen_py.__name__]=gen_py ! del imp gen_py = sys.modules["win32com.gen_py"] Index: universal.py =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/win32com/universal.py,v retrieving revision 1.13 retrieving revision 1.13.4.1 diff -C2 -d -r1.13 -r1.13.4.1 *** universal.py 8 Jun 2005 05:19:03 -0000 1.13 --- universal.py 29 Aug 2008 08:58:52 -0000 1.13.4.1 *************** *** 35,39 **** # impl looks correct.. if type_info is None: ! raise ValueError, "The interface '%s' can not be located" % (name,) # If we got back a Dispatch interface, convert to the real interface. attr = type_info.GetTypeAttr() --- 35,39 ---- # impl looks correct.. if type_info is None: ! raise ValueError("The interface '%s' can not be located" % (name,)) # If we got back a Dispatch interface, convert to the real interface. attr = type_info.GetTypeAttr() *************** *** 51,60 **** # Cool - can used cached info. if not interface_names: ! interface_names = mod.VTablesToClassMap.values() for name in interface_names: try: iid = mod.NamesToIIDMap[name] except KeyError: ! raise ValueError, "Interface '%s' does not exist in this cached typelib" % (name,) # print "Processing interface", name sub_mod = gencache.GetModuleForCLSID(iid) --- 51,60 ---- # Cool - can used cached info. if not interface_names: ! interface_names = list(mod.VTablesToClassMap.values()) for name in interface_names: try: iid = mod.NamesToIIDMap[name] except KeyError: ! raise ValueError("Interface '%s' does not exist in this cached typelib" % (name,)) # print "Processing interface", name sub_mod = gencache.GetModuleForCLSID(iid) *************** *** 62,66 **** method_defs = getattr(sub_mod, name + "_vtables_", None) if is_dispatch is None or method_defs is None: ! raise ValueError, "Interface '%s' is IDispatch only" % (name,) # And create the univgw defn --- 62,66 ---- method_defs = getattr(sub_mod, name + "_vtables_", None) if is_dispatch is None or method_defs is None: ! raise ValueError("Interface '%s' is IDispatch only" % (name,)) # And create the univgw defn *************** *** 162,166 **** return self._iid def vtbl_argsizes(self): ! return map(lambda m: m.cbArgs, self._methods) def dispatch(self, ob, index, argPtr, ReadFromInTuple=_univgw.ReadFromInTuple, --- 162,166 ---- return self._iid def vtbl_argsizes(self): ! return [m.cbArgs for m in self._methods] def dispatch(self, ob, index, argPtr, ReadFromInTuple=_univgw.ReadFromInTuple, *************** *** 178,182 **** # None is an allowed return value stating that # the code doesn't want to touch any output arguments. ! if type(retVal) == types.TupleType: # Like pythoncom, we special case a tuple. # However, if they want to return a specific HRESULT, # then they have to return all of the out arguments --- 178,182 ---- # None is an allowed return value stating that # the code doesn't want to touch any output arguments. ! if type(retVal) == tuple: # Like pythoncom, we special case a tuple. # However, if they want to return a specific HRESULT, # then they have to return all of the out arguments *************** *** 186,190 **** retVal = retVal[1:] else: ! raise TypeError, "Expected %s return values, got: %s" % (len(meth._gw_out_args) + 1, len(retVal)) else: retVal = [retVal] --- 186,190 ---- retVal = retVal[1:] else: ! raise TypeError("Expected %s return values, got: %s" % (len(meth._gw_out_args) + 1, len(retVal))) else: retVal = [retVal] Index: storagecon.py =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/win32com/storagecon.py,v retrieving revision 1.5 retrieving revision 1.5.4.1 diff -C2 -d -r1.5 -r1.5.4.1 *** storagecon.py 3 Dec 2006 06:03:43 -0000 1.5 --- storagecon.py 29 Aug 2008 08:58:52 -0000 1.5.4.1 *************** *** 26,52 **** CWCSTORAGENAME = 32 ! STGM_DIRECT = 0x00000000L ! STGM_TRANSACTED = 0x00010000L ! STGM_SIMPLE = 0x08000000L ! STGM_READ = 0x00000000L ! STGM_WRITE = 0x00000001L ! STGM_READWRITE = 0x00000002L ! STGM_SHARE_DENY_NONE = 0x00000040L ! STGM_SHARE_DENY_READ = 0x00000030L ! STGM_SHARE_DENY_WRITE = 0x00000020L ! STGM_SHARE_EXCLUSIVE = 0x00000010L ! STGM_PRIORITY = 0x00040000L ! STGM_DELETEONRELEASE = 0x04000000L ! STGM_NOSCRATCH = 0x00100000L ! STGM_CREATE = 0x00001000L ! STGM_CONVERT = 0x00020000L ! STGM_FAILIFTHERE = 0x00000000L ! STGM_NOSNAPSHOT = 0x00200000L ! ASYNC_MODE_COMPATIBILITY = 0x00000001L ! ASYNC_MODE_DEFAULT = 0x00000000L ! STGTY_REPEAT = 0x00000100L ! STG_TOEND = 0xFFFFFFFFL ! STG_LAYOUT_SEQUENTIAL = 0x00000000L ! STG_LAYOUT_INTERLEAVED = 0x00000001L ## access rights used with COM server ACL's --- 26,52 ---- CWCSTORAGENAME = 32 ! STGM_DIRECT = 0x00000000 ! STGM_TRANSACTED = 0x00010000 ! STGM_SIMPLE = 0x08000000 ! STGM_READ = 0x00000000 ! STGM_WRITE = 0x00000001 ! STGM_READWRITE = 0x00000002 ! STGM_SHARE_DENY_NONE = 0x00000040 ! STGM_SHARE_DENY_READ = 0x00000030 ! STGM_SHARE_DENY_WRITE = 0x00000020 ! STGM_SHARE_EXCLUSIVE = 0x00000010 ! STGM_PRIORITY = 0x00040000 ! STGM_DELETEONRELEASE = 0x04000000 ! STGM_NOSCRATCH = 0x00100000 ! STGM_CREATE = 0x00001000 ! STGM_CONVERT = 0x00020000 ! STGM_FAILIFTHERE = 0x00000000 ! STGM_NOSNAPSHOT = 0x00200000 ! ASYNC_MODE_COMPATIBILITY = 0x00000001 ! ASYNC_MODE_DEFAULT = 0x00000000 ! STGTY_REPEAT = 0x00000100 ! STG_TOEND = 0xFFFFFFFF ! STG_LAYOUT_SEQUENTIAL = 0x00000000 ! STG_LAYOUT_INTERLEAVED = 0x00000001 ## access rights used with COM server ACL's *************** *** 78,82 **** ## DiscardableInformation ! PIDDI_THUMBNAIL = 0x00000002L ## SummaryInformation --- 78,82 ---- ## DiscardableInformation ! PIDDI_THUMBNAIL = 0x00000002 ## SummaryInformation |
From: Roger U. <ru...@us...> - 2008-08-29 08:58:44
|
Update of /cvsroot/pywin32/pywin32/com/win32com/client In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20885/client Modified Files: Tag: py3k CLSIDToClass.py __init__.py build.py combrowse.py dynamic.py gencache.py genpy.py makepy.py selecttlb.py tlbrowse.py util.py Log Message: Changes to build for Py3k Index: makepy.py =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/win32com/client/makepy.py,v retrieving revision 1.25 retrieving revision 1.25.2.1 diff -C2 -d -r1.25 -r1.25.2.1 *** makepy.py 1 Jul 2008 00:17:41 -0000 1.25 --- makepy.py 29 Aug 2008 08:58:53 -0000 1.25.2.1 *************** *** 67,74 **** """ ! import genpy, string, sys, os, types, pythoncom ! import codecs ! import selecttlb ! import gencache from win32com.client import NeedUnicodeConversions, Dispatch --- 67,74 ---- """ ! import sys, os, types, pythoncom ! from win32com.client import genpy ! from . import selecttlb ! from . import gencache from win32com.client import NeedUnicodeConversions, Dispatch *************** *** 102,110 **** else: desc = tlb.GetDocumentation(-1)[0] ! print desc ! print " %s, lcid=%s, major=%s, minor=%s" % (tlbSpec.clsid, tlbSpec.lcid, tlbSpec.major, tlbSpec.minor) ! print " >>> # Use these commands in Python code to auto generate .py support" ! print " >>> from win32com.client import gencache" ! print " >>> gencache.EnsureModule('%s', %s, %s, %s)" % (tlbSpec.clsid, tlbSpec.lcid, tlbSpec.major, tlbSpec.minor) class SimpleProgress(genpy.GeneratorProgress): --- 102,110 ---- else: desc = tlb.GetDocumentation(-1)[0] ! print(desc) ! print(" %s, lcid=%s, major=%s, minor=%s" % (tlbSpec.clsid, tlbSpec.lcid, tlbSpec.major, tlbSpec.minor)) ! print(" >>> # Use these commands in Python code to auto generate .py support") ! print(" >>> from win32com.client import gencache") ! print(" >>> gencache.EnsureModule('%s', %s, %s, %s)" % (tlbSpec.clsid, tlbSpec.lcid, tlbSpec.major, tlbSpec.minor)) class SimpleProgress(genpy.GeneratorProgress): *************** *** 190,194 **** pass if len(tlbs)==0: ! print "Could not locate a type library matching '%s'" % (arg) for spec in tlbs: # Version numbers not always reliable if enumerated from registry. --- 190,194 ---- pass if len(tlbs)==0: ! print("Could not locate a type library matching '%s'" % (arg)) for spec in tlbs: # Version numbers not always reliable if enumerated from registry. *************** *** 218,222 **** if bForDemand and file is not None: ! raise RuntimeError, "You can only perform a demand-build when the output goes to the gen_py directory" if type(typelibInfo)==type(()): # Tuple --- 218,222 ---- if bForDemand and file is not None: ! raise RuntimeError("You can only perform a demand-build when the output goes to the gen_py directory") if type(typelibInfo)==type(()): # Tuple *************** *** 267,279 **** else: outputName = full_name + ".py" ! # generate to a temp file (so errors don't leave a 1/2 ! # generated file) and one which can handle unicode! ! try: ! os.unlink(outputName) ! except os.error: ! pass ! encoding = 'mbcs' # could make this a param. ! fileUse = codecs.open(outputName + ".temp", "wt", ! encoding) progress.LogBeginGenerate(outputName) else: --- 267,271 ---- else: outputName = full_name + ".py" ! fileUse = open(outputName, "wt") progress.LogBeginGenerate(outputName) else: *************** *** 286,290 **** if file is None: fileUse.close() - os.rename(outputName + ".temp", outputName) if bToGenDir: --- 278,281 ---- *************** *** 357,361 **** bForDemand = not bForDemand ! except (getopt.error, error), msg: sys.stderr.write (str(msg) + "\n") usage() --- 348,352 ---- bForDemand = not bForDemand ! except (getopt.error, error) as msg: sys.stderr.write (str(msg) + "\n") usage() Index: dynamic.py =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/win32com/client/dynamic.py,v retrieving revision 1.22 retrieving revision 1.22.2.1 diff -C2 -d -r1.22 -r1.22.2.1 *** dynamic.py 26 Aug 2007 03:42:13 -0000 1.22 --- dynamic.py 29 Aug 2008 08:58:53 -0000 1.22.2.1 *************** *** 17,29 **** """ import traceback - import string - import new - import pythoncom import winerror ! import build ! from types import StringType, IntType, TupleType, ListType ! from pywintypes import UnicodeType, IIDType import win32com.client # Needed as code we eval() references it. --- 17,27 ---- """ import traceback import pythoncom import winerror ! from . import build ! ! import types ! from pywintypes import IIDType import win32com.client # Needed as code we eval() references it. *************** *** 56,76 **** if debugging: for arg in args: ! print arg, ! print def debug_attr_print(*args): if debugging_attr: for arg in args: ! print arg, ! print # get the type objects for IDispatch and IUnknown dispatchType = pythoncom.TypeIIDs[pythoncom.IID_IDispatch] iunkType = pythoncom.TypeIIDs[pythoncom.IID_IUnknown] - _GoodDispatchType=[StringType,IIDType,UnicodeType] _defaultDispatchItem=build.DispatchItem def _GetGoodDispatch(IDispatch, clsctx = pythoncom.CLSCTX_SERVER): ! if type(IDispatch) in _GoodDispatchType: try: IDispatch = pythoncom.connect(IDispatch) --- 54,73 ---- if debugging: for arg in args: ! print(arg, end=' ') ! print() def debug_attr_print(*args): if debugging_attr: for arg in args: ! print(arg, end=' ') ! print() # get the type objects for IDispatch and IUnknown dispatchType = pythoncom.TypeIIDs[pythoncom.IID_IDispatch] iunkType = pythoncom.TypeIIDs[pythoncom.IID_IUnknown] _defaultDispatchItem=build.DispatchItem def _GetGoodDispatch(IDispatch, clsctx = pythoncom.CLSCTX_SERVER): ! if isinstance(IDispatch, (str, IIDType)): try: IDispatch = pythoncom.connect(IDispatch) *************** *** 86,98 **** # displayed to the user in repr() etc. if userName is None: ! if type(IDispatch) == StringType: userName = IDispatch ! elif type(IDispatch) == UnicodeType: ! # We always want the displayed name to be a real string ! userName = IDispatch.encode("ascii", "replace") ! elif type(userName) == UnicodeType: ! # As above - always a string... ! userName = userName.encode("ascii", "replace") ! else: userName = str(userName) return (_GetGoodDispatch(IDispatch, clsctx), userName) --- 83,93 ---- # displayed to the user in repr() etc. if userName is None: ! if isinstance(IDispatch, str): userName = IDispatch ! ## elif type(IDispatch) == UnicodeType: ! ## # We always want the displayed name to be a real string ! ## userName = IDispatch.encode("ascii", "replace") ! elif not isinstance(userName, str): ! userName = str(userName) return (_GetGoodDispatch(IDispatch, clsctx), userName) *************** *** 171,177 **** allArgs = (dispid,LCID,invkind,1) + args return self._get_good_object_(self._oleobj_.Invoke(*allArgs),self._olerepr_.defaultDispatchName,None) ! raise TypeError, "This dispatch object does not define a default method" ! def __nonzero__(self): return 1 # ie "if object:" should always be "true" - without this, __len__ is tried. # _Possibly_ want to defer to __len__ if available, but Im not sure this is --- 166,172 ---- allArgs = (dispid,LCID,invkind,1) + args return self._get_good_object_(self._oleobj_.Invoke(*allArgs),self._olerepr_.defaultDispatchName,None) ! raise TypeError("This dispatch object does not define a default method") ! def __bool__(self): return 1 # ie "if object:" should always be "true" - without this, __len__ is tried. # _Possibly_ want to defer to __len__ if available, but Im not sure this is *************** *** 186,191 **** try: return str(self.__call__()) ! except pythoncom.com_error, details: ! if details[0] not in ERRORS_BAD_CONTEXT: raise return self.__repr__() --- 181,186 ---- try: return str(self.__call__()) ! except pythoncom.com_error as details: ! if details.args[0] not in ERRORS_BAD_CONTEXT: raise return self.__repr__() *************** *** 203,207 **** if invkind: return self._oleobj_.Invoke(dispid, LCID, invkind, 1) ! raise TypeError, "This dispatch object does not define a Count method" def _NewEnum(self): --- 198,202 ---- if invkind: return self._oleobj_.Invoke(dispid, LCID, invkind, 1) ! raise TypeError("This dispatch object does not define a Count method") def _NewEnum(self): *************** *** 211,215 **** except pythoncom.com_error: return None # no enumerator for this object. ! import util return util.WrapEnum(enum, None) --- 206,210 ---- except pythoncom.com_error: return None # no enumerator for this object. ! from . import util return util.WrapEnum(enum, None) *************** *** 217,221 **** # Improved __getitem__ courtesy Syver Enstad # Must check _NewEnum before Item, to ensure b/w compat. ! if isinstance(index, IntType): if self.__dict__['_enum_'] is None: self.__dict__['_enum_'] = self._NewEnum() --- 212,216 ---- # Improved __getitem__ courtesy Syver Enstad # Must check _NewEnum before Item, to ensure b/w compat. ! if isinstance(index, int): if self.__dict__['_enum_'] is None: self.__dict__['_enum_'] = self._NewEnum() *************** *** 226,230 **** if invkind is not None: return self._get_good_object_(self._oleobj_.Invoke(dispid, LCID, invkind, 1, index)) ! raise TypeError, "This object does not support enumeration" def __setitem__(self, index, *args): --- 221,225 ---- if invkind is not None: return self._get_good_object_(self._oleobj_.Invoke(dispid, LCID, invkind, 1, index)) ! raise TypeError("This object does not support enumeration") def __setitem__(self, index, *args): *************** *** 238,249 **** allArgs = (dispid,LCID,invkind,0,index) + args return self._get_good_object_(self._oleobj_.Invoke(*allArgs),self._olerepr_.defaultDispatchName,None) ! raise TypeError, "This dispatch object does not define a default method" def _find_dispatch_type_(self, methodName): ! if self._olerepr_.mapFuncs.has_key(methodName): item = self._olerepr_.mapFuncs[methodName] return item.desc[4], item.dispid ! if self._olerepr_.propMapGet.has_key(methodName): item = self._olerepr_.propMapGet[methodName] return item.desc[4], item.dispid --- 233,244 ---- allArgs = (dispid,LCID,invkind,0,index) + args return self._get_good_object_(self._oleobj_.Invoke(*allArgs),self._olerepr_.defaultDispatchName,None) ! raise TypeError("This dispatch object does not define a default method") def _find_dispatch_type_(self, methodName): ! if methodName in self._olerepr_.mapFuncs: item = self._olerepr_.mapFuncs[methodName] return item.desc[4], item.dispid ! if methodName in self._olerepr_.propMapGet: item = self._olerepr_.propMapGet[methodName] return item.desc[4], item.dispid *************** *** 274,281 **** # make a new instance of (probably this) class. return self._wrap_dispatch_(ob, userName, ReturnCLSID) ! elif self._unicode_to_string_ and UnicodeType==type(ob): ! return str(ob) ! else: ! return ob def _get_good_object_(self,ob,userName = None, ReturnCLSID=None): --- 269,273 ---- # make a new instance of (probably this) class. return self._wrap_dispatch_(ob, userName, ReturnCLSID) ! return ob def _get_good_object_(self,ob,userName = None, ReturnCLSID=None): *************** *** 285,289 **** if ob is None: # Quick exit! return None ! elif type(ob)==TupleType: return tuple(map(lambda o, s=self, oun=userName, rc=ReturnCLSID: s._get_good_single_object_(o, oun, rc), ob)) else: --- 277,281 ---- if ob is None: # Quick exit! return None ! elif isinstance(ob, tuple): return tuple(map(lambda o, s=self, oun=userName, rc=ReturnCLSID: s._get_good_single_object_(o, oun, rc), ob)) else: *************** *** 294,298 **** methodName = build.MakePublicAttributeName(name) # translate keywords etc. methodCodeList = self._olerepr_.MakeFuncMethod(self._olerepr_.mapFuncs[name], methodName,0) ! methodCode = string.join(methodCodeList,"\n") try: # print "Method code for %s is:\n" % self._username_, methodCode --- 286,290 ---- methodName = build.MakePublicAttributeName(name) # translate keywords etc. methodCodeList = self._olerepr_.MakeFuncMethod(self._olerepr_.mapFuncs[name], methodName,0) ! methodCode = "\n".join(methodCodeList) try: # print "Method code for %s is:\n" % self._username_, methodCode *************** *** 304,312 **** globNameSpace = globals().copy() globNameSpace["Dispatch"] = win32com.client.Dispatch ! exec codeObject in globNameSpace, tempNameSpace # self.__dict__, self.__dict__ name = methodName # Save the function in map. fn = self._builtMethods_[name] = tempNameSpace[name] ! newMeth = new.instancemethod(fn, self, self.__class__) return newMeth except: --- 296,304 ---- globNameSpace = globals().copy() globNameSpace["Dispatch"] = win32com.client.Dispatch ! exec(codeObject, globNameSpace, tempNameSpace) # self.__dict__, self.__dict__ name = methodName # Save the function in map. fn = self._builtMethods_[name] = tempNameSpace[name] ! newMeth = types.MethodType(fn, self) return newMeth except: *************** *** 318,322 **** """Cleanup object - like a close - to force cleanup when you dont want to rely on Python's reference counting.""" ! for childCont in self._mapCachedItems_.values(): childCont._Release_() self._mapCachedItems_ = {} --- 310,314 ---- """Cleanup object - like a close - to force cleanup when you dont want to rely on Python's reference counting.""" ! for childCont in list(self._mapCachedItems_.values()): childCont._Release_() self._mapCachedItems_ = {} *************** *** 336,357 **** return self._get_good_object_(self._oleobj_.Invoke(*(dispId, LCID, item.desc[4], 0) + (args) )) except KeyError: ! raise AttributeError, name def _print_details_(self): "Debug routine - dumps what it knows about an object." ! print "AxDispatch container",self._username_ try: ! print "Methods:" ! for method in self._olerepr_.mapFuncs.keys(): ! print "\t", method ! print "Props:" ! for prop, entry in self._olerepr_.propMap.items(): ! print "\t%s = 0x%x - %s" % (prop, entry.dispid, `entry`) ! print "Get Props:" ! for prop, entry in self._olerepr_.propMapGet.items(): ! print "\t%s = 0x%x - %s" % (prop, entry.dispid, `entry`) ! print "Put Props:" ! for prop, entry in self._olerepr_.propMapPut.items(): ! print "\t%s = 0x%x - %s" % (prop, entry.dispid, `entry`) except: traceback.print_exc() --- 328,349 ---- return self._get_good_object_(self._oleobj_.Invoke(*(dispId, LCID, item.desc[4], 0) + (args) )) except KeyError: ! raise AttributeError(name) def _print_details_(self): "Debug routine - dumps what it knows about an object." ! print("AxDispatch container",self._username_) try: ! print("Methods:") ! for method in list(self._olerepr_.mapFuncs.keys()): ! print("\t", method) ! print("Props:") ! for prop, entry in list(self._olerepr_.propMap.items()): ! print("\t%s = 0x%x - %s" % (prop, entry.dispid, repr(entry))) ! print("Get Props:") ! for prop, entry in list(self._olerepr_.propMapGet.items()): ! print("\t%s = 0x%x - %s" % (prop, entry.dispid, repr(entry))) ! print("Put Props:") ! for prop, entry in list(self._olerepr_.propMapPut.items()): ! print("\t%s = 0x%x - %s" % (prop, entry.dispid, repr(entry))) except: traceback.print_exc() *************** *** 428,432 **** enum = self._oleobj_.InvokeTypes(pythoncom.DISPID_NEWENUM,LCID,invkind,(13, 10),()) except pythoncom.com_error: ! raise AttributeError, "This object can not function as an iterator" # We must return a callable object. class Factory: --- 420,424 ---- enum = self._oleobj_.InvokeTypes(pythoncom.DISPID_NEWENUM,LCID,invkind,(13, 10),()) except pythoncom.com_error: ! raise AttributeError("This object can not function as an iterator") # We must return a callable object. class Factory: *************** *** 439,446 **** if attr[0]=='_' and attr[-1]=='_': # Fast-track. ! raise AttributeError, attr # If a known method, create new instance and return. try: ! return new.instancemethod(self._builtMethods_[attr], self, self.__class__) except KeyError: pass --- 431,438 ---- if attr[0]=='_' and attr[-1]=='_': # Fast-track. ! raise AttributeError(attr) # If a known method, create new instance and return. try: ! return types.MethodType(self._builtMethods_[attr], self) except KeyError: pass *************** *** 451,455 **** # means we create the actual method object - which also means # this code will never be asked for that method name again. ! if self._olerepr_.mapFuncs.has_key(attr): return self._make_method_(attr) --- 443,447 ---- # means we create the actual method object - which also means # this code will never be asked for that method name again. ! if attr in self._olerepr_.mapFuncs: return self._make_method_(attr) *************** *** 465,469 **** try: if self.__LazyMap__(attr): ! if self._olerepr_.mapFuncs.has_key(attr): return self._make_method_(attr) retEntry = self._olerepr_.propMap.get(attr) if retEntry is None: --- 457,461 ---- try: if self.__LazyMap__(attr): ! if attr in self._olerepr_.mapFuncs: return self._make_method_(attr) retEntry = self._olerepr_.propMap.get(attr) if retEntry is None: *************** *** 488,505 **** try: ret = self._oleobj_.Invoke(retEntry.dispid,0,invoke_type,1) ! except pythoncom.com_error, details: if details[0] in ERRORS_BAD_CONTEXT: # May be a method. self._olerepr_.mapFuncs[attr] = retEntry return self._make_method_(attr) ! raise pythoncom.com_error, details debug_attr_print("OLE returned ", ret) return self._get_good_object_(ret) # no where else to look. ! raise AttributeError, "%s.%s" % (self._username_, attr) def __setattr__(self, attr, value): ! if self.__dict__.has_key(attr): # Fast-track - if already in our dict, just make the assignment. # XXX - should maybe check method map - if someone assigns to a method, # it could mean something special (not sure what, tho!) --- 480,497 ---- try: ret = self._oleobj_.Invoke(retEntry.dispid,0,invoke_type,1) ! except pythoncom.com_error as details: if details[0] in ERRORS_BAD_CONTEXT: # May be a method. self._olerepr_.mapFuncs[attr] = retEntry return self._make_method_(attr) ! raise pythoncom.com_error(details) debug_attr_print("OLE returned ", ret) return self._get_good_object_(ret) # no where else to look. ! raise AttributeError("%s.%s" % (self._username_, attr)) def __setattr__(self, attr, value): ! if attr in self.__dict__: # Fast-track - if already in our dict, just make the assignment. # XXX - should maybe check method map - if someone assigns to a method, # it could mean something special (not sure what, tho!) *************** *** 507,515 **** return # Allow property assignment. ! debug_attr_print("SetAttr called for %s.%s=%s on DispatchContainer" % (self._username_, attr, `value`)) if self._olerepr_: # Check the "general" property map. ! if self._olerepr_.propMap.has_key(attr): entry = self._olerepr_.propMap[attr] invoke_type = _GetDescInvokeType(entry, pythoncom.INVOKE_PROPERTYPUT) --- 499,507 ---- return # Allow property assignment. ! debug_attr_print("SetAttr called for %s.%s=%s on DispatchContainer" % (self._username_, attr, repr(value))) if self._olerepr_: # Check the "general" property map. ! if attr in self._olerepr_.propMap: entry = self._olerepr_.propMap[attr] invoke_type = _GetDescInvokeType(entry, pythoncom.INVOKE_PROPERTYPUT) *************** *** 517,521 **** return # Check the specific "put" map. ! if self._olerepr_.propMapPut.has_key(attr): entry = self._olerepr_.propMapPut[attr] invoke_type = _GetDescInvokeType(entry, pythoncom.INVOKE_PROPERTYPUT) --- 509,513 ---- return # Check the specific "put" map. ! if attr in self._olerepr_.propMapPut: entry = self._olerepr_.propMapPut[attr] invoke_type = _GetDescInvokeType(entry, pythoncom.INVOKE_PROPERTYPUT) *************** *** 527,531 **** if self.__LazyMap__(attr): # Check the "general" property map. ! if self._olerepr_.propMap.has_key(attr): entry = self._olerepr_.propMap[attr] invoke_type = _GetDescInvokeType(entry, pythoncom.INVOKE_PROPERTYPUT) --- 519,523 ---- if self.__LazyMap__(attr): # Check the "general" property map. ! if attr in self._olerepr_.propMap: entry = self._olerepr_.propMap[attr] invoke_type = _GetDescInvokeType(entry, pythoncom.INVOKE_PROPERTYPUT) *************** *** 533,537 **** return # Check the specific "put" map. ! if self._olerepr_.propMapPut.has_key(attr): entry = self._olerepr_.propMapPut[attr] invoke_type = _GetDescInvokeType(entry, pythoncom.INVOKE_PROPERTYPUT) --- 525,529 ---- return # Check the specific "put" map. ! if attr in self._olerepr_.propMapPut: entry = self._olerepr_.propMapPut[attr] invoke_type = _GetDescInvokeType(entry, pythoncom.INVOKE_PROPERTYPUT) *************** *** 552,554 **** except pythoncom.com_error: pass ! raise AttributeError, "Property '%s.%s' can not be set." % (self._username_, attr) --- 544,546 ---- except pythoncom.com_error: pass ! raise AttributeError("Property '%s.%s' can not be set." % (self._username_, attr)) Index: combrowse.py =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/win32com/client/combrowse.py,v retrieving revision 1.8 retrieving revision 1.8.2.1 diff -C2 -d -r1.8 -r1.8.2.1 *** combrowse.py 1 Jul 2008 01:04:40 -0000 1.8 --- combrowse.py 29 Aug 2008 08:58:52 -0000 1.8.2.1 *************** *** 15,19 **** Details ! This module allows browsing of registered Type Libraries, COM categories, and running COM objects. The display is similar to the Pythonwin object browser, and displays the objects in a hierarchical window. --- 15,19 ---- Details ! This module allows browsing of registered Type Libraries, COM categories, and running COM objects. The display is similar to the Pythonwin object [...1005 lines suppressed...] ! if "app" in sys.modules: ! # do it in a window ! browser.MakeTemplate() ! browser.template.OpenObject(root) ! else: ! # list=hierlist.HierListWithItems( root, win32ui.IDB_BROWSER_HIER ) ! # dlg=hierlist.HierDialog("COM Browser",list) ! dlg = browser.dynamic_browser(root) ! dlg.DoModal() if __name__=='__main__': ! main() ! ! ni = pythoncom._GetInterfaceCount() ! ng = pythoncom._GetGatewayCount() ! if ni or ng: ! print("Warning - exiting with %d/%d objects alive" % (ni,ng)) Index: util.py =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/win32com/client/util.py,v retrieving revision 1.3 retrieving revision 1.3.2.1 diff -C2 -d -r1.3 -r1.3.2.1 *** util.py 24 May 2007 13:00:03 -0000 1.3 --- util.py 29 Aug 2008 08:58:53 -0000 1.3.2.1 *************** *** 40,44 **** def __GetIndex(self, index): ! if type(index)!=type(0): raise TypeError, "Only integer indexes are supported for enumerators" # NOTE # In this context, self.index is users purely as a flag to say --- 40,44 ---- def __GetIndex(self, index): ! if type(index)!=type(0): raise TypeError("Only integer indexes are supported for enumerators") # NOTE # In this context, self.index is users purely as a flag to say *************** *** 54,58 **** if len(result): return self._make_retval_(result[0]) ! raise IndexError, "list index out of range" def Next(self, count=1): ret = self._oleobj_.Next(count) --- 54,58 ---- if len(result): return self._make_retval_(result[0]) ! raise IndexError("list index out of range") def Next(self, count=1): ret = self._oleobj_.Next(count) *************** *** 81,84 **** def __iter__(self): return self ! def next(self): ! return _get_good_object_(self._iter_.next(), resultCLSID = self.resultCLSID) --- 81,84 ---- def __iter__(self): return self ! def __next__(self): ! return _get_good_object_(next(self._iter_), resultCLSID = self.resultCLSID) Index: __init__.py =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/win32com/client/__init__.py,v retrieving revision 1.34 retrieving revision 1.34.4.1 diff -C2 -d -r1.34 -r1.34.4.1 *** __init__.py 24 May 2005 14:30:04 -0000 1.34 --- __init__.py 29 Aug 2008 08:58:52 -0000 1.34.4.1 *************** *** 6,18 **** # dispatch object, the known class will be used. This contrasts # with dynamic.Dispatch behaviour, where dynamic objects are always used. ! import __builtin__ # For some bizarre reason, __builtins__ fails with attribute error on __dict__ here? ! NeedUnicodeConversions = not hasattr(__builtin__, "unicode") ! import dynamic, gencache, pythoncom import sys import pywintypes ! from types import TupleType ! from pywintypes import UnicodeType _PyIDispatchType = pythoncom.TypeIIDs[pythoncom.IID_IDispatch] --- 6,19 ---- # dispatch object, the known class will be used. This contrasts # with dynamic.Dispatch behaviour, where dynamic objects are always used. ! import builtins # For some bizarre reason, __builtins__ fails with attribute error on __dict__ here? ! NeedUnicodeConversions = not hasattr(builtins, "unicode") ! ! import pythoncom ! from . import dynamic, gencache import sys import pywintypes ! _PyIDispatchType = pythoncom.TypeIIDs[pythoncom.IID_IDispatch] *************** *** 33,37 **** pass if resultCLSID is not None: ! import gencache # Attempt to load generated module support # This may load the module, and make it available --- 34,38 ---- pass if resultCLSID is not None: ! from . import gencache # Attempt to load generated module support # This may load the module, and make it available *************** *** 66,70 **** if (Pathname is None and Class is None) or \ (Pathname is not None and Class is not None): ! raise ValueError, "You must specify a value for Pathname or Class, but not both." if Class is not None: --- 67,71 ---- if (Pathname is None and Class is None) or \ (Pathname is not None and Class is not None): ! raise ValueError if Class is not None: *************** *** 128,136 **** if hasattr(target, "index"): # string like # for now, we assume makepy for this to work. ! if not ob.__class__.__dict__.has_key("CLSID"): # Eeek - no makepy support - try and build it. ob = gencache.EnsureDispatch(ob) ! if not ob.__class__.__dict__.has_key("CLSID"): ! raise ValueError, "Must be a makepy-able object for this to work" clsid = ob.CLSID # Lots of hoops to support "demand-build" - ie, generating --- 129,137 ---- if hasattr(target, "index"): # string like # for now, we assume makepy for this to work. ! if "CLSID" not in ob.__class__.__dict__: # Eeek - no makepy support - try and build it. ob = gencache.EnsureDispatch(ob) ! if "CLSID" not in ob.__class__.__dict__: ! raise ValueError clsid = ob.CLSID # Lots of hoops to support "demand-build" - ie, generating *************** *** 148,153 **** target_clsid = mod.NamesToIIDMap.get(target) if target_clsid is None: ! raise ValueError, "The interface name '%s' does not appear in the " \ ! "same library as object '%r'" % (target, ob) mod = gencache.GetModuleForCLSID(target_clsid) target_class = getattr(mod, target) --- 149,153 ---- target_clsid = mod.NamesToIIDMap.get(target) if target_clsid is None: ! raise ValueError mod = gencache.GetModuleForCLSID(target_clsid) target_class = getattr(mod, target) *************** *** 155,159 **** target_class = getattr(target_class, "default_interface", target_class) return target_class(ob) # auto QI magic happens ! raise ValueError, "This object can not be cast" class Constants: --- 155,159 ---- target_class = getattr(target_class, "default_interface", target_class) return target_class(ob) # auto QI magic happens ! raise ValueError class Constants: *************** *** 164,170 **** def __getattr__(self, a): for d in self.__dicts__: ! if d.has_key(a): return d[a] ! raise AttributeError, a # And create an instance. --- 164,170 ---- def __getattr__(self, a): for d in self.__dicts__: ! if a in d: return d[a] ! raise AttributeError # And create an instance. *************** *** 252,256 **** disp_class = gencache.GetClassForProgID(str(disp_clsid)) except pythoncom.com_error: ! raise TypeError, "This COM object can not automate the makepy process - please run makepy manually for this object" else: disp_class = disp.__class__ --- 252,256 ---- disp_class = gencache.GetClassForProgID(str(disp_clsid)) except pythoncom.com_error: ! raise TypeError else: disp_class = disp.__class__ *************** *** 261,265 **** events_class = getevents(clsid) if events_class is None: ! raise ValueError, "This COM object does not support events." result_class = new.classobj("COMEventClass", (disp_class, events_class, user_event_class), {"__setattr__" : _event_setattr_}) instance = result_class(disp._oleobj_) # This only calls the first base class __init__. --- 261,265 ---- events_class = getevents(clsid) if events_class is None: ! raise ValueError result_class = new.classobj("COMEventClass", (disp_class, events_class, user_event_class), {"__setattr__" : _event_setattr_}) instance = result_class(disp._oleobj_) # This only calls the first base class __init__. *************** *** 304,308 **** disp_class = gencache.GetClassForProgID(str(disp_clsid)) except pythoncom.com_error: ! raise TypeError, "This COM object can not automate the makepy process - please run makepy manually for this object" else: disp_class = disp.__class__ --- 304,308 ---- disp_class = gencache.GetClassForProgID(str(disp_clsid)) except pythoncom.com_error: ! raise TypeError else: disp_class = disp.__class__ *************** *** 314,318 **** events_class = getevents(clsid) if events_class is None: ! raise ValueError, "This COM object does not support events." result_class = new.classobj("COMEventClass", (events_class, user_event_class), {}) instance = result_class(disp) # This only calls the first base class __init__. --- 314,318 ---- events_class = getevents(clsid) if events_class is None: ! raise ValueError result_class = new.classobj("COMEventClass", (events_class, user_event_class), {}) instance = result_class(disp) # This only calls the first base class __init__. *************** *** 388,393 **** app.MoveTo(point) """ ! # XXX - to do - probably should allow "object" to already be a module object. ! import gencache object = gencache.EnsureDispatch(object) module = sys.modules[object.__class__.__module__] --- 388,392 ---- app.MoveTo(point) """ ! from . import gencache object = gencache.EnsureDispatch(object) module = sys.modules[object.__class__.__module__] *************** *** 401,405 **** struct_guid = package.RecordMap[name] except KeyError: ! raise ValueError, "The structure '%s' is not defined in module '%s'" % (name, package) return pythoncom.GetRecordFromGuids(module.CLSID, module.MajorVersion, module.MinorVersion, module.LCID, struct_guid) --- 400,404 ---- struct_guid = package.RecordMap[name] except KeyError: ! raise ValueError return pythoncom.GetRecordFromGuids(module.CLSID, module.MajorVersion, module.MinorVersion, module.LCID, struct_guid) *************** *** 416,420 **** try: oobj = oobj._oleobj_.QueryInterface(self.CLSID, pythoncom.IID_IDispatch) # Must be a valid COM instance ! except pythoncom.com_error, details: import winerror # Some stupid objects fail here, even tho it is _already_ IDispatch!!?? --- 415,419 ---- try: oobj = oobj._oleobj_.QueryInterface(self.CLSID, pythoncom.IID_IDispatch) # Must be a valid COM instance ! except pythoncom.com_error as details: import winerror # Some stupid objects fail here, even tho it is _already_ IDispatch!!?? *************** *** 452,464 **** args=self._prop_map_get_.get(attr) if args is None: ! raise AttributeError, "'%s' object has no attribute '%s'" % (repr(self), attr) return self._ApplyTypes_(*args) def __setattr__(self, attr, value): ! if self.__dict__.has_key(attr): self.__dict__[attr] = value; return try: args, defArgs=self._prop_map_put_[attr] except KeyError: ! raise AttributeError, "'%s' object has no attribute '%s'" % (repr(self), attr) self._oleobj_.Invoke(*(args + (value,) + defArgs)) def _get_good_single_object_(self, obj, obUserName=None, resultCLSID=None): --- 451,463 ---- args=self._prop_map_get_.get(attr) if args is None: ! raise AttributeError return self._ApplyTypes_(*args) def __setattr__(self, attr, value): ! if attr in self.__dict__: self.__dict__[attr] = value; return try: args, defArgs=self._prop_map_put_[attr] except KeyError: ! raise AttributeError self._oleobj_.Invoke(*(args + (value,) + defArgs)) def _get_good_single_object_(self, obj, obUserName=None, resultCLSID=None): *************** *** 471,476 **** if _PyIDispatchType==type(obj): return Dispatch(obj, obUserName, resultCLSID, UnicodeToString=NeedUnicodeConversions) ! elif NeedUnicodeConversions and UnicodeType==type(obj): ! return str(obj) return obj --- 470,475 ---- if _PyIDispatchType==type(obj): return Dispatch(obj, obUserName, resultCLSID, UnicodeToString=NeedUnicodeConversions) ! ## elif NeedUnicodeConversions and UnicodeType==type(obj): ! ## return str(obj) return obj *************** *** 478,482 **** if obj is None: return None ! elif type(obj)==TupleType: obUserNameTuple = (obUserName,) * len(obj) resultCLSIDTuple = (resultCLSID,) * len(obj) --- 477,481 ---- if obj is None: return None ! elif isinstance(obj, tuple): obUserNameTuple = (obUserName,) * len(obj) resultCLSIDTuple = (resultCLSID,) * len(obj) *************** *** 495,501 **** d=self.__dict__["_dispobj_"] if d is not None: return getattr(d, attr) ! raise AttributeError, attr def __setattr__(self, attr, value): ! if self.__dict__.has_key(attr): self.__dict__[attr] = value; return try: d=self.__dict__["_dispobj_"] --- 494,500 ---- d=self.__dict__["_dispobj_"] if d is not None: return getattr(d, attr) ! raise AttributeError def __setattr__(self, attr, value): ! if attr in self.__dict__: self.__dict__[attr] = value; return try: d=self.__dict__["_dispobj_"] Index: build.py =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/win32com/client/build.py,v retrieving revision 1.31 retrieving revision 1.31.2.1 diff -C2 -d -r1.31 -r1.31.2.1 *** build.py 29 Jun 2008 23:57:20 -0000 1.31 --- build.py 29 Aug 2008 08:58:52 -0000 1.31.2.1 *************** *** 121,125 **** else: deleteExisting = 1 # No good to us ! if self.mapFuncs.has_key(key) or self.propMapGet.has_key(key): newKey = "Set" + key else: --- 121,125 ---- else: deleteExisting = 1 # No good to us ! if key in self.mapFuncs or key in self.propMapGet: newKey = "Set" + key else: *************** *** 138,142 **** else: deleteExisting = 1 # No good to us ! if self.mapFuncs.has_key(key): newKey = "Get" + key else: --- 138,142 ---- else: deleteExisting = 1 # No good to us ! if key in self.mapFuncs: newKey = "Get" + key else: *************** *** 257,266 **** if typeinfo is None: return # Loop over all methods ! for j in xrange(attr[6]): fdesc = typeinfo.GetFuncDesc(j) self._AddFunc_(typeinfo,fdesc,bForUser) # Loop over all variables (ie, properties) ! for j in xrange(attr[7]): fdesc = typeinfo.GetVarDesc(j) self._AddVar_(typeinfo,fdesc,bForUser) --- 257,266 ---- if typeinfo is None: return # Loop over all methods ! for j in range(attr[6]): fdesc = typeinfo.GetFuncDesc(j) self._AddFunc_(typeinfo,fdesc,bForUser) # Loop over all variables (ie, properties) ! for j in range(attr[7]): fdesc = typeinfo.GetVarDesc(j) self._AddVar_(typeinfo,fdesc,bForUser) *************** *** 269,276 **** # that have arguments, we must turn them into methods. If a method # of the same name already exists, change the name. ! for key, item in self.propMapGet.items(): self._propMapGetCheck_(key,item) ! for key, item in self.propMapPut.items(): self._propMapPutCheck_(key,item) --- 269,276 ---- # that have arguments, we must turn them into methods. If a method # of the same name already exists, change the name. ! for key, item in list(self.propMapGet.items()): self._propMapGetCheck_(key,item) ! for key, item in list(self.propMapPut.items()): self._propMapPutCheck_(key,item) *************** *** 316,319 **** --- 316,320 ---- defOutArg = "pythoncom.Missing" id = fdesc[0] + s = linePrefix + 'def ' + name + '(self' + BuildCallList(fdesc, names, defNamedOptArg, defNamedNotOptArg, defUnnamedArg, defOutArg) + '):' ret.append(s) *************** *** 330,347 **** # Strip the default values from the arg desc retDesc = fdesc[8][:2] ! argsDesc = tuple(map(lambda what: what[:2], fdesc[2])) # The runtime translation of the return types is expensive, so when we know the # return type of the function, there is no need to check the type at runtime. # To qualify, this function must return a "simple" type, and have no byref args. # Check if we have byrefs or anything in the args which mean we still need a translate. ! param_flags = map(lambda what: what[1], fdesc[2]) ! bad_params = filter(lambda flag: flag & (pythoncom.PARAMFLAG_FOUT | pythoncom.PARAMFLAG_FRETVAL)!=0, param_flags) s = None if len(bad_params)==0 and len(retDesc)==2 and retDesc[1]==0: rd = retDesc[0] ! if NoTranslateMap.has_key(rd): s = '%s\treturn self._oleobj_.InvokeTypes(%d, LCID, %s, %s, %s%s)' % (linePrefix, id, fdesc[4], retDesc, argsDesc, _BuildArgList(fdesc, names)) elif rd in [pythoncom.VT_DISPATCH, pythoncom.VT_UNKNOWN]: ! s = '%s\tret = self._oleobj_.InvokeTypes(%d, LCID, %s, %s, %s%s)\n' % (linePrefix, id, fdesc[4], retDesc, `argsDesc`, _BuildArgList(fdesc, names)) s = s + '%s\tif ret is not None:\n' % (linePrefix,) if rd == pythoncom.VT_UNKNOWN: --- 331,348 ---- # Strip the default values from the arg desc retDesc = fdesc[8][:2] ! argsDesc = tuple([what[:2] for what in fdesc[2]]) # The runtime translation of the return types is expensive, so when we know the # return type of the function, there is no need to check the type at runtime. # To qualify, this function must return a "simple" type, and have no byref args. # Check if we have byrefs or anything in the args which mean we still need a translate. ! param_flags = [what[1] for what in fdesc[2]] ! bad_params = [flag for flag in param_flags if flag & (pythoncom.PARAMFLAG_FOUT | pythoncom.PARAMFLAG_FRETVAL)!=0] s = None if len(bad_params)==0 and len(retDesc)==2 and retDesc[1]==0: rd = retDesc[0] ! if rd in NoTranslateMap: s = '%s\treturn self._oleobj_.InvokeTypes(%d, LCID, %s, %s, %s%s)' % (linePrefix, id, fdesc[4], retDesc, argsDesc, _BuildArgList(fdesc, names)) elif rd in [pythoncom.VT_DISPATCH, pythoncom.VT_UNKNOWN]: ! s = '%s\tret = self._oleobj_.InvokeTypes(%d, LCID, %s, %s, %s%s)\n' % (linePrefix, id, fdesc[4], retDesc, repr(argsDesc), _BuildArgList(fdesc, names)) s = s + '%s\tif ret is not None:\n' % (linePrefix,) if rd == pythoncom.VT_UNKNOWN: *************** *** 351,366 **** s = s + "%s\t\texcept pythoncom.error:\n" % (linePrefix,) s = s + "%s\t\t\treturn ret\n" % (linePrefix,) ! s = s + '%s\t\tret = Dispatch(ret, %s, %s, UnicodeToString=%d)\n' % (linePrefix,`name`, resclsid, NeedUnicodeConversions) s = s + '%s\treturn ret' % (linePrefix) elif rd == pythoncom.VT_BSTR: if NeedUnicodeConversions: s = "%s\t# Result is a Unicode object - perform automatic string conversion\n" % (linePrefix,) ! s = s + '%s\treturn str(self._oleobj_.InvokeTypes(%d, LCID, %s, %s, %s%s))' % (linePrefix, id, fdesc[4], retDesc, `argsDesc`, _BuildArgList(fdesc, names)) else: s = "%s\t# Result is a Unicode object - return as-is for this version of Python\n" % (linePrefix,) ! s = s + '%s\treturn self._oleobj_.InvokeTypes(%d, LCID, %s, %s, %s%s)' % (linePrefix, id, fdesc[4], retDesc, `argsDesc`, _BuildArgList(fdesc, names)) # else s remains None if s is None: ! s = '%s\treturn self._ApplyTypes_(%d, %s, %s, %s, %s, %s%s)' % (linePrefix, id, fdesc[4], retDesc, argsDesc, `name`, resclsid, _BuildArgList(fdesc, names)) ret.append(s) --- 352,367 ---- s = s + "%s\t\texcept pythoncom.error:\n" % (linePrefix,) s = s + "%s\t\t\treturn ret\n" % (linePrefix,) ! s = s + '%s\t\tret = Dispatch(ret, %s, %s, UnicodeToString=%d)\n' % (linePrefix,repr(name), resclsid, NeedUnicodeConversions) s = s + '%s\treturn ret' % (linePrefix) elif rd == pythoncom.VT_BSTR: if NeedUnicodeConversions: s = "%s\t# Result is a Unicode object - perform automatic string conversion\n" % (linePrefix,) ! s = s + '%s\treturn str(self._oleobj_.InvokeTypes(%d, LCID, %s, %s, %s%s))' % (linePrefix, id, fdesc[4], retDesc, repr(argsDesc), _BuildArgList(fdesc, names)) else: s = "%s\t# Result is a Unicode object - return as-is for this version of Python\n" % (linePrefix,) ! s = s + '%s\treturn self._oleobj_.InvokeTypes(%d, LCID, %s, %s, %s%s)' % (linePrefix, id, fdesc[4], retDesc, repr(argsDesc), _BuildArgList(fdesc, names)) # else s remains None if s is None: ! s = '%s\treturn self._ApplyTypes_(%d, %s, %s, %s, %s, %s%s)' % (linePrefix, id, fdesc[4], retDesc, argsDesc, repr(name), resclsid, _BuildArgList(fdesc, names)) ret.append(s) *************** *** 395,404 **** assert typeinfo is not None, "Cant build vtables without type info!" ! def cmp_vtable_off(m1, m2): ! return cmp(m1.desc[7], m2.desc[7]) ! meth_list = self.mapFuncs.values() + self.propMapGet.values() + self.propMapPut.values() ! meth_list.sort( cmp_vtable_off ) # Now turn this list into the run-time representation # (ready for immediate use or writing to gencache) --- 396,405 ---- assert typeinfo is not None, "Cant build vtables without type info!" ! def cmp_vtable_off(m1): ! return m1.desc[7] ! meth_list = list(self.mapFuncs.values()) + list(self.propMapGet.values()) + list(self.propMapPut.values()) ! meth_list.sort(key = cmp_vtable_off ) # Now turn this list into the run-time representation # (ready for immediate use or writing to gencache) *************** *** 425,429 **** # Resolve VT_USERDEFINED (often aliases or typed IDispatches) ! if type(typerepr)==types.TupleType: indir_vt, subrepr = typerepr if indir_vt == pythoncom.VT_PTR: --- 426,430 ---- # Resolve VT_USERDEFINED (often aliases or typed IDispatches) ! if type(typerepr)==tuple: indir_vt, subrepr = typerepr if indir_vt == pythoncom.VT_PTR: *************** *** 435,439 **** # only when "somehandle" is an object. # but (VT_PTR, (VT_USERDEFINED, otherhandle)) doesnt get the indirection dropped. ! was_user = type(subrepr)==types.TupleType and subrepr[0]==pythoncom.VT_USERDEFINED subrepr, sub_clsid, sub_doc = _ResolveType(subrepr, itypeinfo) if was_user and subrepr in [pythoncom.VT_DISPATCH, pythoncom.VT_UNKNOWN, pythoncom.VT_RECORD]: --- 436,440 ---- # only when "somehandle" is an object. # but (VT_PTR, (VT_USERDEFINED, otherhandle)) doesnt get the indirection dropped. ! was_user = type(subrepr)==tuple and subrepr[0]==pythoncom.VT_USERDEFINED subrepr, sub_clsid, sub_doc = _ResolveType(subrepr, itypeinfo) if was_user and subrepr in [pythoncom.VT_DISPATCH, pythoncom.VT_UNKNOWN, pythoncom.VT_RECORD]: *************** *** 453,457 **** try: resultTypeInfo = itypeinfo.GetRefTypeInfo(subrepr) ! except pythoncom.com_error, details: if details[0] in [winerror.TYPE_E_CANTLOADLIBRARY, winerror.TYPE_E_LIBNOTREGISTERED]: --- 454,458 ---- try: resultTypeInfo = itypeinfo.GetRefTypeInfo(subrepr) ! except pythoncom.com_error as details: if details[0] in [winerror.TYPE_E_CANTLOADLIBRARY, winerror.TYPE_E_LIBNOTREGISTERED]: *************** *** 494,498 **** i = names.index(None) names[i] = "arg%d" % (i,) ! names = map(MakePublicAttributeName, names[1:]) name_num = 0 while len(names) < numArgs: --- 495,499 ---- i = names.index(None) names[i] = "arg%d" % (i,) ! names = list(map(MakePublicAttributeName, names[1:])) name_num = 0 while len(names) < numArgs: *************** *** 503,507 **** for i in range(0, len(names), 5): names[i] = names[i] + "\n\t\t\t" ! return "," + string.join(names, ", ") valid_identifier_chars = string.ascii_letters + string.digits + "_" --- 504,508 ---- for i in range(0, len(names), 5): names[i] = names[i] + "\n\t\t\t" ! return "," + ", ".join(names) valid_identifier_chars = string.ascii_letters + string.digits + "_" *************** *** 527,536 **** return demunge_leading_underscores(className) elif iskeyword(className): # all keywords are lower case ! return string.capitalize(className) elif className == 'None': # assign to None is evil (and SyntaxError in 2.4) - note # that if it was a global it would get picked up below className = 'NONE' ! elif is_global and __builtins__.has_key(className): # builtins may be mixed case. If capitalizing it doesn't change it, # force to all uppercase (eg, "None", "True" become "NONE", "TRUE" --- 528,537 ---- return demunge_leading_underscores(className) elif iskeyword(className): # all keywords are lower case ! return className.capitalize() elif className == 'None': # assign to None is evil (and SyntaxError in 2.4) - note # that if it was a global it would get picked up below className = 'NONE' ! elif is_global and className in __builtins__: # builtins may be mixed case. If capitalizing it doesn't change it, # force to all uppercase (eg, "None", "True" become "NONE", "TRUE" *************** *** 540,544 **** return ret # Strip non printable chars ! return filter( lambda char: char in valid_identifier_chars, className) # Given a default value passed by a type library, return a string with --- 541,545 ---- return ret # Strip non printable chars ! return ''.join([char for char in className if char in valid_identifier_chars]) # Given a default value passed by a type library, return a string with *************** *** 577,581 **** else: firstOptArg = numArgs - numOptArgs ! for arg in xrange(numArgs): try: argName = names[arg+1] --- 578,582 ---- else: firstOptArg = numArgs - numOptArgs ! for arg in range(numArgs): try: argName = names[arg+1] *************** *** 603,606 **** --- 604,608 ---- argName = MakePublicAttributeName(argName) + # insanely long lines with an 'encoding' flag crashes python 2.4.0 # keep 5 args per line *************** *** 622,624 **** if __name__=='__main__': ! print "Use 'makepy.py' to generate Python code - this module is just a helper" --- 624,626 ---- if __name__=='__main__': ! print("Use 'makepy.py' to generate Python code - this module is just a helper") Index: genpy.py =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/win32com/client/genpy.py,v retrieving revision 1.55 retrieving revision 1.55.2.1 diff -C2 -d -r1.55 -r1.55.2.1 *** genpy.py 1 Jul 2008 00:11:14 -0000 1.55 --- genpy.py 29 Aug 2008 08:58:53 -0000 1.55.2.1 *************** *** 16,28 **** import os import sys - import string import time import win32com import pythoncom ! import build error = "makepy.error" [...1167 lines suppressed...] def checkWriteDispatchBaseClass(self): if not self.bHaveWrittenDispatchBaseClass: ! print("from win32com.client import DispatchBaseClass", file=self.file) self.bHaveWrittenDispatchBaseClass = 1 def checkWriteCoClassBaseClass(self): if not self.bHaveWrittenCoClassBaseClass: ! print("from win32com.client import CoClassBaseClass", file=self.file) self.bHaveWrittenCoClassBaseClass = 1 *************** *** 1024,1026 **** if __name__=='__main__': ! print "This is a worker module. Please use makepy to generate Python files." --- 1021,1023 ---- if __name__=='__main__': ! print("This is a worker module. Please use makepy to generate Python files.") Index: gencache.py =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/win32com/client/gencache.py,v retrieving revision 1.32 retrieving revision 1.32.2.1 diff -C2 -d -r1.32 -r1.32.2.1 *** gencache.py 22 Jan 2007 22:18:44 -0000 1.32 --- gencache.py 29 Aug 2008 08:58:53 -0000 1.32.2.1 *************** *** 21,30 **** Maybe an OLE2 compound file, or a bsddb file? """ ! import pywintypes, os, string, sys import pythoncom import win32com, win32com.client import glob import traceback ! import CLSIDToClass import operator --- 21,30 ---- Maybe an OLE2 compound file, or a bsddb file? """ ! import pywintypes, os, sys import pythoncom import win32com, win32com.client import glob import traceback ! from . import CLSIDToClass import operator *************** *** 59,68 **** def _SaveDicts(): if is_readonly: ! raise RuntimeError, "Trying to write to a readonly gencache ('%s')!" \ ! % win32com.__gen_path__ ! import cPickle f = open(os.path.join(GetGeneratePath(), "dicts.dat"), "wb") try: ! p = cPickle.Pickler(f) p.dump(pickleVersion) p.dump(clsidToTypelib) --- 59,68 ---- def _SaveDicts(): if is_readonly: ! raise RuntimeError("Trying to write to a readonly gencache ('%s')!" \ ! % win32com.__gen_path__) ! import pickle f = open(os.path.join(GetGeneratePath(), "dicts.dat"), "wb") try: ! p = pickle.Pickler(f) p.dump(pickleVersion) p.dump(clsidToTypelib) *************** *** 71,78 **** def _LoadDicts(): ! import cPickle # Load the dictionary from a .zip file if that is where we live. if hasattr(win32com, "__loader__"): ! import cStringIO loader = win32com.__loader__ arc_path = loader.archive --- 71,78 ---- def _LoadDicts(): ! import pickle # Load the dictionary from a .zip file if that is where we live. if hasattr(win32com, "__loader__"): ! import io loader = win32com.__loader__ arc_path = loader.archive *************** *** 101,110 **** # the dict) return ! f = cStringIO.StringIO(data) else: # NOTE: IOError on file open must be caught by caller. f = open(os.path.join(win32com.__gen_path__, "dicts.dat"), "rb") try: ! p = cPickle.Unpickler(f) version = p.load() global clsidToTypelib --- 101,110 ---- # the dict) return ! f = io.StringIO(data) else: # NOTE: IOError on file open must be caught by caller. f = open(os.path.join(win32com.__gen_path__, "dicts.dat"), "rb") try: ! p = pickle.Unpickler(f) version = p.load() global clsidToTypelib *************** *** 118,127 **** the file name (no extension) providing this support. """ ! return string.upper(str(clsid))[1:-1] + "x%sx%sx%s" % (lcid, major, minor) def SplitGeneratedFileName(fname): """Reverse of GetGeneratedFileName() """ ! return tuple(string.split(fname,'x',4)) def GetGeneratePath(): --- 118,127 ---- the file name (no extension) providing this support. """ ! return str(clsid).upper()[1:-1] + "x%sx%sx%s" % (lcid, major, minor) def SplitGeneratedFileName(fname): """Reverse of GetGeneratedFileName() """ ! return tuple(fname.split('x',4)) def GetGeneratePath(): *************** *** 235,241 **** # Force the generation. If this typelibrary has explicitly been added, # use it (it may not be registered, causing a lookup by clsid to fail) ! if demandGeneratedTypeLibraries.has_key(info): info = demandGeneratedTypeLibraries[info] ! import makepy makepy.GenerateChildFromTypeLibSpec(sub_mod, info) # Generate does an import... --- 235,241 ---- # Force the generation. If this typelibrary has explicitly been added, # use it (it may not be registered, causing a lookup by clsid to fail) ! if info in demandGeneratedTypeLibraries: info = demandGeneratedTypeLibraries[info] ! from . import makepy makepy.GenerateChildFromTypeLibSpec(sub_mod, info) # Generate does an import... *************** *** 259,265 **** # If the import worked, it doesn't mean we have actually added this # module to our cache though - check that here. ! if not mod.__dict__.has_key("_in_gencache_"): AddModuleToCache(typelibCLSID, lcid, major, minor) ! assert mod.__dict__.has_key("_in_gencache_") return mod --- 259,265 ---- # If the import worked, it doesn't mean we have actually added this # module to our cache though - check that here. ! if "_in_gencache_" not in mod.__dict__: AddModuleToCache(typelibCLSID, lcid, major, minor) ! assert "_in_gencache_" in mod.__dict__ return mod *************** *** 281,287 **** """ if bGUIProgress is not None: ! print "The 'bGuiProgress' param to 'MakeModuleForTypelib' is obsolete." ! import makepy try: makepy.GenerateFromTypeLibSpec( (typelibCLSID, lcid, major, minor), progressInstance=progressInstance, bForDemand = bForDemand, bBuildHidden = bBuildHidden) --- 281,287 ---- """ if bGUIProgress is not None: ! print("The 'bGuiProgress' param to 'MakeModuleForTypelib' is obsolete.") ! from . import makepy try: makepy.GenerateFromTypeLibSpec( (typelibCLSID, lcid, major, minor), progressInstance=progressInstance, bForDemand = bForDemand, bBuildHidden = bBuildHidden) *************** *** 304,308 **** use the GUI progress bar. """ ! import makepy try: makepy.GenerateFromTypeLibSpec( typelib_ob, progressInstance=progressInstance, bForDemand = bForDemandDefault, bBuildHidden = bBuildHidden) --- 304,308 ---- use the GUI progress bar. """ ! from . import makepy try: makepy.GenerateFromTypeLibSpec( typelib_ob, progressInstance=progressInstance, bForDemand = bForDemandDefault, bBuildHidden = bBuildHidden) *************** *** 360,366 **** except KeyError: # Not worth raising an exception - maybe they dont know we only remember for demand generated, etc. ! print "ForgetAboutTypelibInterface:: Warning - type library with info %s is not being remembered!" % (info,) # and drop any version redirects to it ! for key, val in versionRedirectMap.items(): if val==info: del versionRedirectMap[key] --- 360,366 ---- except KeyError: # Not worth raising an exception - maybe they dont know we only remember for demand generated, etc. ! print("ForgetAboutTypelibInterface:: Warning - type library with info %s is not being remembered!" % (info,)) # and drop any version redirects to it ! for key, val in list(versionRedirectMap.items()): if val==info: del versionRedirectMap[key] *************** *** 446,450 **** # Verify that type library is up to date. # If we have a differing MinorVersion or genpy has bumped versions, update the file ! import genpy if module.MinorVersion != tlbAttributes[4] or genpy.makepy_version != module.makepy_version: #print "Version skew: %d, %d" % (module.MinorVersion, tlbAttributes[4]) --- 446,450 ---- # Verify that type library is up to date. # If we have a differing MinorVersion or genpy has bumped versions, update the file ! from . import genpy if module.MinorVersion != tlbAttributes[4] or genpy.makepy_version != module.makepy_version: #print "Version skew: %d, %d" % (module.MinorVersion, tlbAttributes[4]) *************** *** 474,478 **** pyModTime = os.stat(filePath)[8] fModTimeSet = 1 ! except os.error, e: # If .py file fails, try .pyc file #print "Trying pyc stat", filePathPyc --- 474,478 ---- pyModTime = os.stat(filePath)[8] fModTimeSet = 1 ! except os.error as e: # If .py file fails, try .pyc file #print "Trying pyc stat", filePathPyc *************** *** 480,484 **** pyModTime = os.stat(filePathPyc)[8] fModTimeSet = 1 ! except os.error, e: pass #print "Trying stat typelib", pyModTime --- 480,484 ---- pyModTime = os.stat(filePathPyc)[8] fModTimeSet = 1 ! except os.error as e: pass #print "Trying stat typelib", pyModTime *************** *** 536,545 **** mod = EnsureModule(tla[0], tla[1], tla[3], tla[4], bForDemand=bForDemand) GetModuleForCLSID(disp_clsid) ! # Get the class from the module. ! import CLSIDToClass disp_class = CLSIDToClass.GetClass(str(disp_clsid)) disp = disp_class(disp._oleobj_) except pythoncom.com_error: ! raise TypeError, "This COM object can not automate the makepy process - please run makepy manually for this object" return disp --- 536,544 ---- mod = EnsureModule(tla[0], tla[1], tla[3], tla[4], bForDemand=bForDemand) GetModuleForCLSID(disp_clsid) ! from . import CLSIDToClass disp_class = CLSIDToClass.GetClass(str(disp_clsid)) disp = disp_class(disp._oleobj_) except pythoncom.com_error: ! raise TypeError("This COM object can not automate the makepy process - please run makepy manually for this object") return disp *************** *** 554,574 **** dict = mod.CLSIDToClassMap info = str(typelibclsid), lcid, major, minor ! for clsid, cls in dict.items(): clsidToTypelib[clsid] = info dict = mod.CLSIDToPackageMap ! for clsid, name in dict.items(): clsidToTypelib[clsid] = info dict = mod.VTablesToClassMap ! for clsid, cls in dict.items(): clsidToTypelib[clsid] = info dict = mod.VTablesToPackageMap ! for clsid, cls in dict.items(): clsidToTypelib[clsid] = info # If this lib was previously redirected, drop it ! if versionRedirectMap.has_key(info): del versionRedirectMap[info] if bFlushNow: --- 553,573 ---- dict = mod.CLSIDToClassMap info = str(typelibclsid), lcid, major, minor ! for clsid, cls in list(dict.items()): clsidToTypelib[clsid] = ... [truncated message content] |
From: Roger U. <ru...@us...> - 2008-08-29 08:33:22
|
Update of /cvsroot/pywin32/pywin32/com/win32comext/taskscheduler/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11821 Modified Files: Tag: py3k PyIProvideTaskPage.cpp PyIScheduledWorkItem.cpp PyITask.cpp PyITaskTrigger.cpp PyITaskTrigger.h taskscheduler.cpp Log Message: Changes to build for Py3k Index: PyITaskTrigger.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/win32comext/taskscheduler/src/PyITaskTrigger.cpp,v retrieving revision 1.2 retrieving revision 1.2.4.1 diff -C2 -d -r1.2 -r1.2.4.1 *** PyITaskTrigger.cpp 28 Apr 2004 05:21:44 -0000 1.2 --- PyITaskTrigger.cpp 29 Aug 2008 08:33:26 -0000 1.2.4.1 *************** *** 143,150 **** // @object PyTASK_TRIGGER|Python object representing a TASK_TRIGGER structure via the structmember Api ! static PyTypeObject PyTASK_TRIGGERType = { ! PyObject_HEAD_INIT(&PyType_Type) ! 0, "PyTASK_TRIGGER", sizeof(PyTASK_TRIGGER), --- 143,149 ---- // @object PyTASK_TRIGGER|Python object representing a TASK_TRIGGER structure via the structmember Api ! PyTypeObject PyTASK_TRIGGERType = { ! PYWIN_OBJECT_HEAD "PyTASK_TRIGGER", sizeof(PyTASK_TRIGGER), *************** *** 165,169 **** PyObject_GenericSetAttr, // PyTASK_TRIGGER::setattro, 0, // tp_as_buffer; ! Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, // tp_flags; 0, // tp_doc; /* Documentation string */ 0, // traverseproc tp_traverse; --- 164,168 ---- PyObject_GenericSetAttr, // PyTASK_TRIGGER::setattro, 0, // tp_as_buffer; ! Py_TPFLAGS_DEFAULT, // tp_flags; 0, // tp_doc; /* Documentation string */ 0, // traverseproc tp_traverse; Index: PyITask.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/win32comext/taskscheduler/src/PyITask.cpp,v retrieving revision 1.3 retrieving revision 1.3.2.1 diff -C2 -d -r1.3 -r1.3.2.1 *** PyITask.cpp 4 May 2008 13:02:08 -0000 1.3 --- PyITask.cpp 29 Aug 2008 08:33:26 -0000 1.3.2.1 *************** *** 35,45 **** if ( !PyArg_ParseTuple(args, "O:SetApplicationName", &obpwszApplicationName) ) return NULL; ! BOOL bPythonIsHappy = TRUE; ! if (bPythonIsHappy && !PyWinObject_AsBstr(obpwszApplicationName, &pwszApplicationName)) bPythonIsHappy = FALSE; ! if (!bPythonIsHappy) return NULL; HRESULT hr; PY_INTERFACE_PRECALL; hr = pIT->SetApplicationName( pwszApplicationName ); ! SysFreeString(pwszApplicationName); PY_INTERFACE_POSTCALL; --- 35,44 ---- if ( !PyArg_ParseTuple(args, "O:SetApplicationName", &obpwszApplicationName) ) return NULL; ! if (!PyWinObject_AsWCHAR(obpwszApplicationName, &pwszApplicationName)) ! return NULL; HRESULT hr; PY_INTERFACE_PRECALL; hr = pIT->SetApplicationName( pwszApplicationName ); ! PyWinObject_FreeWCHAR(pwszApplicationName); PY_INTERFACE_POSTCALL; *************** *** 87,97 **** if ( !PyArg_ParseTuple(args, "O:SetParameters", &obpwszParameters) ) return NULL; ! BOOL bPythonIsHappy = TRUE; ! if (bPythonIsHappy && !PyWinObject_AsBstr(obpwszParameters, &pwszParameters)) bPythonIsHappy = FALSE; ! if (!bPythonIsHappy) return NULL; HRESULT hr; PY_INTERFACE_PRECALL; hr = pIT->SetParameters( pwszParameters ); ! SysFreeString(pwszParameters); PY_INTERFACE_POSTCALL; --- 86,95 ---- if ( !PyArg_ParseTuple(args, "O:SetParameters", &obpwszParameters) ) return NULL; ! if (!PyWinObject_AsWCHAR(obpwszParameters, &pwszParameters)) ! return NULL; HRESULT hr; PY_INTERFACE_PRECALL; hr = pIT->SetParameters( pwszParameters ); ! PyWinObject_FreeWCHAR(pwszParameters); PY_INTERFACE_POSTCALL; *************** *** 139,149 **** if ( !PyArg_ParseTuple(args, "O:SetWorkingDirectory", &obpwszWorkingDirectory) ) return NULL; ! BOOL bPythonIsHappy = TRUE; ! if (bPythonIsHappy && !PyWinObject_AsBstr(obpwszWorkingDirectory, &pwszWorkingDirectory)) bPythonIsHappy = FALSE; ! if (!bPythonIsHappy) return NULL; HRESULT hr; PY_INTERFACE_PRECALL; hr = pIT->SetWorkingDirectory( pwszWorkingDirectory ); ! SysFreeString(pwszWorkingDirectory); PY_INTERFACE_POSTCALL; --- 137,146 ---- if ( !PyArg_ParseTuple(args, "O:SetWorkingDirectory", &obpwszWorkingDirectory) ) return NULL; ! if (!PyWinObject_AsWCHAR(obpwszWorkingDirectory, &pwszWorkingDirectory)) ! return NULL; HRESULT hr; PY_INTERFACE_PRECALL; hr = pIT->SetWorkingDirectory( pwszWorkingDirectory ); ! PyWinObject_FreeWCHAR(pwszWorkingDirectory); PY_INTERFACE_POSTCALL; Index: PyIProvideTaskPage.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/win32comext/taskscheduler/src/PyIProvideTaskPage.cpp,v retrieving revision 1.1 retrieving revision 1.1.4.1 diff -C2 -d -r1.1 -r1.1.4.1 *** PyIProvideTaskPage.cpp 18 Apr 2004 22:01:11 -0000 1.1 --- PyIProvideTaskPage.cpp 29 Aug 2008 08:33:26 -0000 1.1.4.1 *************** *** 36,40 **** // @pyparm bool|PersistChanges||Indicates if changes should be saved automatically HPROPSHEETPAGE phPage; ! BOOL bPersistChanges=FALSE; if ( !PyArg_ParseTuple(args, "ii:GetPage", &tpType, &bPersistChanges)) return NULL; --- 36,40 ---- // @pyparm bool|PersistChanges||Indicates if changes should be saved automatically HPROPSHEETPAGE phPage; ! BOOL bPersistChanges; if ( !PyArg_ParseTuple(args, "ii:GetPage", &tpType, &bPersistChanges)) return NULL; *************** *** 47,51 **** if ( FAILED(hr) ) return PyCom_BuildPyException(hr, pIPTP, IID_IProvideTaskPage ); ! return new PyHANDLE(phPage); } --- 47,51 ---- if ( FAILED(hr) ) return PyCom_BuildPyException(hr, pIPTP, IID_IProvideTaskPage ); ! return PyWinLong_FromHANDLE(phPage); } Index: taskscheduler.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/win32comext/taskscheduler/src/taskscheduler.cpp,v retrieving revision 1.2 retrieving revision 1.2.4.1 diff -C2 -d -r1.2 -r1.2.4.1 *** taskscheduler.cpp 18 Apr 2004 22:01:11 -0000 1.2 --- taskscheduler.cpp 29 Aug 2008 08:33:26 -0000 1.2.4.1 *************** *** 25,37 **** }; ! extern "C" __declspec(dllexport) void inittaskscheduler() { ! PyObject *module; module = Py_InitModule("taskscheduler", taskscheduler_methods); ! if (module==NULL) return; ! PyObject *dict = PyModule_GetDict(module); ! if (dict==NULL) return; // Register all of our interfaces, gateways and IIDs. --- 25,63 ---- }; ! ! extern "C" __declspec(dllexport) ! #if (PY_VERSION_HEX < 0x03000000) ! void inittaskscheduler(void) ! #else ! PyObject *PyInit_taskscheduler(void) ! #endif { ! PyObject *dict, *module; ! PyWinGlobals_Ensure(); ! ! #if (PY_VERSION_HEX < 0x03000000) ! #define RETURN_ERROR return; module = Py_InitModule("taskscheduler", taskscheduler_methods); ! if (!module) return; ! dict = PyModule_GetDict(module); ! if (!dict) return; + #else + #define RETURN_ERROR return NULL; + static PyModuleDef taskscheduler_def = { + PyModuleDef_HEAD_INIT, + "taskscheduler", + "Supports the Scheduled Tasks COM interfaces", + -1, + taskscheduler_methods + }; + module = PyModule_Create(&taskscheduler_def); + if (!module) + return NULL; + dict = PyModule_GetDict(module); + if (!dict) + return NULL; + #endif // Register all of our interfaces, gateways and IIDs. *************** *** 133,135 **** --- 159,164 ---- PyModule_AddIntConstant(module,"TASKPAGE_SETTINGS", TASKPAGE_SETTINGS); + #if (PY_VERSION_HEX >= 0x03000000) + return module; + #endif } Index: PyIScheduledWorkItem.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/win32comext/taskscheduler/src/PyIScheduledWorkItem.cpp,v retrieving revision 1.5 retrieving revision 1.5.2.1 diff -C2 -d -r1.5 -r1.5.2.1 *** PyIScheduledWorkItem.cpp 3 Jun 2007 14:53:07 -0000 1.5 --- PyIScheduledWorkItem.cpp 29 Aug 2008 08:33:26 -0000 1.5.2.1 *************** *** 389,399 **** if ( !PyArg_ParseTuple(args, "O:SetComment", &obpwszComment) ) return NULL; ! BOOL bPythonIsHappy = TRUE; ! if (bPythonIsHappy && !PyWinObject_AsBstr(obpwszComment, &pwszComment)) bPythonIsHappy = FALSE; ! if (!bPythonIsHappy) return NULL; HRESULT hr; PY_INTERFACE_PRECALL; hr = pISWI->SetComment( pwszComment ); ! SysFreeString(pwszComment); PY_INTERFACE_POSTCALL; --- 389,399 ---- if ( !PyArg_ParseTuple(args, "O:SetComment", &obpwszComment) ) return NULL; ! ! if (!PyWinObject_AsWCHAR(obpwszComment, &pwszComment)) ! return NULL; HRESULT hr; PY_INTERFACE_PRECALL; hr = pISWI->SetComment( pwszComment ); ! PyWinObject_FreeWCHAR(pwszComment); PY_INTERFACE_POSTCALL; *************** *** 439,449 **** if ( !PyArg_ParseTuple(args, "O:SetCreator", &obpwszCreator) ) return NULL; ! BOOL bPythonIsHappy = TRUE; ! if (bPythonIsHappy && !PyWinObject_AsBstr(obpwszCreator, &pwszCreator)) bPythonIsHappy = FALSE; ! if (!bPythonIsHappy) return NULL; HRESULT hr; PY_INTERFACE_PRECALL; hr = pISWI->SetCreator( pwszCreator ); ! SysFreeString(pwszCreator); PY_INTERFACE_POSTCALL; --- 439,448 ---- if ( !PyArg_ParseTuple(args, "O:SetCreator", &obpwszCreator) ) return NULL; ! if (!PyWinObject_AsWCHAR(obpwszCreator, &pwszCreator)) ! return NULL; HRESULT hr; PY_INTERFACE_PRECALL; hr = pISWI->SetCreator( pwszCreator ); ! PyWinObject_FreeWCHAR(pwszCreator); PY_INTERFACE_POSTCALL; Index: PyITaskTrigger.h =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/win32comext/taskscheduler/src/PyITaskTrigger.h,v retrieving revision 1.1 retrieving revision 1.1.4.1 diff -C2 -d -r1.1 -r1.1.4.1 *** PyITaskTrigger.h 10 Apr 2004 05:18:41 -0000 1.1 --- PyITaskTrigger.h 29 Aug 2008 08:33:26 -0000 1.1.4.1 *************** *** 10,13 **** --- 10,15 ---- BOOL PyTASK_TRIGGER_check(PyObject *ob); + extern __declspec(dllexport) PyTypeObject PyTASK_TRIGGERType; + class PyITaskTrigger : public PyIUnknown { |
From: Roger U. <ru...@us...> - 2008-08-29 08:33:03
|
Update of /cvsroot/pywin32/pywin32/com/win32comext/shell/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11793 Modified Files: Tag: py3k shell.cpp Log Message: Changes to build for Py3k Index: shell.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/win32comext/shell/src/shell.cpp,v retrieving revision 1.68 retrieving revision 1.68.2.1 diff -C2 -d -r1.68 -r1.68.2.1 *** shell.cpp 18 Aug 2008 13:01:43 -0000 1.68 --- shell.cpp 29 Aug 2008 08:33:13 -0000 1.68.2.1 *************** *** 2089,2093 **** if (attr && attr != Py_None) { fd->dwFlags |= FD_FILESIZE; ! ok = PyLong_AsTwoI32(attr, (int *)&fd->nFileSizeHigh, (unsigned *)&fd->nFileSizeLow); } Py_XDECREF(attr); --- 2089,2098 ---- if (attr && attr != Py_None) { fd->dwFlags |= FD_FILESIZE; ! ULARGE_INTEGER fsize; ! ok=PyWinObject_AsULARGE_INTEGER(attr, &fsize); ! if (ok){ ! fd->nFileSizeHigh=fsize.HighPart; ! fd->nFileSizeLow=fsize.LowPart; ! } } Py_XDECREF(attr); *************** *** 2239,2243 **** if (fd->dwFlags & FD_FILESIZE) { ! val = PyLong_FromTwoInts(fd->nFileSizeHigh, fd->nFileSizeLow); if (val) PyDict_SetItemString(sub, "nFileSize", val); Py_XDECREF(val); --- 2244,2251 ---- if (fd->dwFlags & FD_FILESIZE) { ! ULARGE_INTEGER fsize; ! fsize.LowPart=fd->nFileSizeLow; ! fsize.HighPart=fd->nFileSizeHigh; ! val = PyWinObject_FromULARGE_INTEGER(fsize); if (val) PyDict_SetItemString(sub, "nFileSize", val); Py_XDECREF(val); *************** *** 3190,3194 **** /* List of module functions */ ! // @module shell|A module, encapsulating the ActiveX Control interfaces static struct PyMethodDef shell_methods[]= { --- 3198,3202 ---- /* List of module functions */ ! // @module shell|A module wrapping Windows Shell functions and interfaces static struct PyMethodDef shell_methods[]= { *************** *** 3328,3342 **** #define ADD_IID(tok) AddIID(dict, #tok, tok) /* Module initialisation */ ! extern "C" __declspec(dllexport) void initshell() { ! char *modName = "shell"; ! PyObject *oModule; ! // Create the module and add the functions ! oModule = Py_InitModule(modName, shell_methods); ! if (!oModule) /* Eeek - some serious error! */ return; ! PyObject *dict = PyModule_GetDict(oModule); ! if (!dict) return; /* Another serious error!*/ PyDict_SetItemString(dict, "error", PyWinExc_COMError); --- 3336,3375 ---- #define ADD_IID(tok) AddIID(dict, #tok, tok) + /* Module initialisation */ ! extern "C" __declspec(dllexport) ! #if (PY_VERSION_HEX < 0x03000000) ! void initshell(void) ! #else ! PyObject *PyInit_shell(void) ! #endif { ! PyObject *dict, *module; ! PyWinGlobals_Ensure(); ! ! #if (PY_VERSION_HEX < 0x03000000) ! #define RETURN_ERROR return; ! module = Py_InitModule("shell", shell_methods); ! if (!module) return; ! dict = PyModule_GetDict(module); ! if (!dict) ! return; ! #else ! #define RETURN_ERROR return NULL; ! static PyModuleDef shell_def = { ! PyModuleDef_HEAD_INIT, ! "shell", ! "A module wrapping Windows Shell functions and interfaces", ! -1, ! shell_methods ! }; ! module = PyModule_Create(&shell_def); ! if (!module) ! return NULL; ! dict = PyModule_GetDict(module); ! if (!dict) ! return NULL; ! #endif PyDict_SetItemString(dict, "error", PyWinExc_COMError); *************** *** 3501,3503 **** --- 3534,3540 ---- # pragma message("Please update your SDK headers - IE5 features missing!") #endif + + #if (PY_VERSION_HEX >= 0x03000000) + return module; + #endif } |
From: Roger U. <ru...@us...> - 2008-08-29 08:32:50
|
Update of /cvsroot/pywin32/pywin32/com/win32comext/internet/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11771 Modified Files: Tag: py3k internet.cpp Log Message: Changes to build for Py3k Index: internet.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/win32comext/internet/src/internet.cpp,v retrieving revision 1.4 retrieving revision 1.4.2.1 diff -C2 -d -r1.4 -r1.4.2.1 *** internet.cpp 22 Oct 2007 04:35:24 -0000 1.4 --- internet.cpp 29 Aug 2008 08:32:58 -0000 1.4.2.1 *************** *** 188,192 **** /* List of module functions */ // @module internet|A module, encapsulating the ActiveX Internet interfaces ! static struct PyMethodDef internet_methods[]= { { "CoInternetIsFeatureEnabled", PyCoInternetIsFeatureEnabled}, // @pymeth CoInternetIsFeatureEnabled| --- 188,192 ---- /* List of module functions */ // @module internet|A module, encapsulating the ActiveX Internet interfaces ! static struct PyMethodDef internet_functions[]= { { "CoInternetIsFeatureEnabled", PyCoInternetIsFeatureEnabled}, // @pymeth CoInternetIsFeatureEnabled| *************** *** 220,233 **** /* Module initialisation */ ! extern "C" __declspec(dllexport) void initinternet() { ! char *modName = "internet"; ! PyObject *oModule; ! // Create the module and add the functions ! oModule = Py_InitModule(modName, internet_methods); ! if (!oModule) /* Eeek - some serious error! */ return; ! PyObject *dict = PyModule_GetDict(oModule); ! if (!dict) return; /* Another serious error!*/ // Register all of our interfaces, gateways and IIDs. --- 220,255 ---- /* Module initialisation */ ! extern "C" __declspec(dllexport) ! #if (PY_VERSION_HEX < 0x03000000) ! void initinternet(void) ! #else ! PyObject *PyInit_internet(void) ! #endif { ! PyObject *dict, *module; ! PyWinGlobals_Ensure(); ! ! #if (PY_VERSION_HEX < 0x03000000) ! module = Py_InitModule("internet", internet_functions); ! if (!module) return; ! dict = PyModule_GetDict(module); ! if (!dict) ! return; ! #else ! static PyModuleDef internet_def = { ! PyModuleDef_HEAD_INIT, ! "internet", ! "A module, encapsulating the ActiveX Internet interfaces", ! -1, ! internet_functions ! }; ! module = PyModule_Create(&internet_def); ! if (!module) ! return NULL; ! dict = PyModule_GetDict(module); ! if (!dict) ! return NULL; ! #endif // Register all of our interfaces, gateways and IIDs. *************** *** 279,281 **** --- 301,307 ---- // ADD_CONSTANT(); // @const internet|| + + #if (PY_VERSION_HEX >= 0x03000000) + return module; + #endif } |
From: Roger U. <ru...@us...> - 2008-08-29 08:32:39
|
Update of /cvsroot/pywin32/pywin32/com/win32comext/ifilter/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11748 Modified Files: Tag: py3k PyIFilter.cpp Log Message: Changes to build for Py3k Index: PyIFilter.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/win32comext/ifilter/src/PyIFilter.cpp,v retrieving revision 1.6 retrieving revision 1.6.4.1 diff -C2 -d -r1.6 -r1.6.4.1 *** PyIFilter.cpp 2 Mar 2005 02:25:02 -0000 1.6 --- PyIFilter.cpp 29 Aug 2008 08:32:47 -0000 1.6.4.1 *************** *** 283,287 **** #define ADD_IID(tok) AddIID(dict, #tok, tok) ! // @object PyIFilter|Description of the interface static struct PyMethodDef PyIFilter_methods[] = { --- 283,287 ---- #define ADD_IID(tok) AddIID(dict, #tok, tok) ! // @object PyIFilter|Wraps the interfaces used with Indexing Service filtering static struct PyMethodDef PyIFilter_methods[] = { *************** *** 300,304 **** ! static struct PyMethodDef g_methods[] = { { "LoadIFilter", pyLoadIFilter, 1 }, // @pymeth Init|Description of Init --- 300,304 ---- ! static struct PyMethodDef ifilter_functions[] = { { "LoadIFilter", pyLoadIFilter, 1 }, // @pymeth Init|Description of Init *************** *** 315,331 **** /* Module initialisation */ ! extern "C" __declspec(dllexport) void initifilter() { ! char *modName = "ifilter"; ! PyObject *oModule; ! PyWinGlobals_Ensure(); ! // Create the module and add the functions ! oModule = Py_InitModule(modName, g_methods); ! if (!oModule) /* Eeek - some serious error! */ return; ! PyObject *dict = PyModule_GetDict(oModule); ! if (!dict) return; /* Another serious error!*/ // Register all of our interfaces, gateways and IIDs. --- 315,351 ---- /* Module initialisation */ ! extern "C" __declspec(dllexport) ! #if (PY_VERSION_HEX < 0x03000000) ! void initifilter(void) ! #else ! PyObject *PyInit_ifilter(void) ! #endif { ! PyObject *dict, *module; PyWinGlobals_Ensure(); ! #if (PY_VERSION_HEX < 0x03000000) ! module = Py_InitModule("ifilter", ifilter_functions); ! if (!module) return; ! dict = PyModule_GetDict(module); ! if (!dict) ! return; ! #else ! ! static PyModuleDef ifilter_def = { ! PyModuleDef_HEAD_INIT, ! "ifilter", ! "Wraps the interfaces used with Indexing Service filtering", ! -1, ! ifilter_functions ! }; ! module = PyModule_Create(&ifilter_def); ! if (!module) ! return NULL; ! dict = PyModule_GetDict(module); ! if (!dict) ! return NULL; ! #endif // Register all of our interfaces, gateways and IIDs. *************** *** 380,382 **** ADD_CONSTANT(FILTER_S_LAST_TEXT); // NOTE: New constants should go in ifiltercon.py ! } \ No newline at end of file --- 400,406 ---- ADD_CONSTANT(FILTER_S_LAST_TEXT); // NOTE: New constants should go in ifiltercon.py ! ! #if (PY_VERSION_HEX >= 0x03000000) ! return module; ! #endif ! } |
From: Roger U. <ru...@us...> - 2008-08-29 08:32:25
|
Update of /cvsroot/pywin32/pywin32/com/win32comext/directsound/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11723 Modified Files: Tag: py3k PyDSBCAPS.cpp PyDSBUFFERDESC.cpp PyDSCAPS.cpp PyDSCBCAPS.cpp PyDSCBUFFERDESC.cpp PyDSCCAPS.cpp directsound.cpp Log Message: Changes to build for Py3k Index: PyDSBUFFERDESC.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/win32comext/directsound/src/PyDSBUFFERDESC.cpp,v retrieving revision 1.3 retrieving revision 1.3.4.1 diff -C2 -d -r1.3 -r1.3.4.1 *** PyDSBUFFERDESC.cpp 25 Mar 2005 01:52:11 -0000 1.3 --- PyDSBUFFERDESC.cpp 29 Aug 2008 08:32:34 -0000 1.3.4.1 *************** *** 48,53 **** PyTypeObject PyDSBUFFERDESCType = { ! PyObject_HEAD_INIT(&PyType_Type) ! 0, "PyDSBUFFERDESC", sizeof(PyDSBUFFERDESC), --- 48,52 ---- PyTypeObject PyDSBUFFERDESCType = { ! PYWIN_OBJECT_HEAD "PyDSBUFFERDESC", sizeof(PyDSBUFFERDESC), Index: PyDSCCAPS.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/win32comext/directsound/src/PyDSCCAPS.cpp,v retrieving revision 1.2 retrieving revision 1.2.4.1 diff -C2 -d -r1.2 -r1.2.4.1 *** PyDSCCAPS.cpp 25 Mar 2005 01:52:11 -0000 1.2 --- PyDSCCAPS.cpp 29 Aug 2008 08:32:34 -0000 1.2.4.1 *************** *** 43,48 **** PyTypeObject PyDSCCAPSType = { ! PyObject_HEAD_INIT(&PyType_Type) ! 0, "PyDSCCAPSType", sizeof(PyDSCCAPSType), --- 43,47 ---- PyTypeObject PyDSCCAPSType = { ! PYWIN_OBJECT_HEAD "PyDSCCAPSType", sizeof(PyDSCCAPSType), Index: PyDSCAPS.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/win32comext/directsound/src/PyDSCAPS.cpp,v retrieving revision 1.3 retrieving revision 1.3.4.1 diff -C2 -d -r1.3 -r1.3.4.1 *** PyDSCAPS.cpp 25 Mar 2005 01:52:11 -0000 1.3 --- PyDSCAPS.cpp 29 Aug 2008 08:32:34 -0000 1.3.4.1 *************** *** 43,48 **** PyTypeObject PyDSCAPSType = { ! PyObject_HEAD_INIT(&PyType_Type) ! 0, "PyDSCAPSType", sizeof(PyDSCAPSType), --- 43,47 ---- PyTypeObject PyDSCAPSType = { ! PYWIN_OBJECT_HEAD "PyDSCAPSType", sizeof(PyDSCAPSType), Index: directsound.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/win32comext/directsound/src/directsound.cpp,v retrieving revision 1.8 retrieving revision 1.8.4.1 diff -C2 -d -r1.8 -r1.8.4.1 *** directsound.cpp 25 Mar 2005 01:52:11 -0000 1.8 --- directsound.cpp 29 Aug 2008 08:32:34 -0000 1.8.4.1 *************** *** 261,274 **** /* Module initialisation */ ! extern "C" __declspec(dllexport) void initdirectsound() { ! char *modName = "directsound"; ! PyObject *oModule; ! // Create the module and add the functions ! oModule = Py_InitModule(modName, directsound_methods); ! if (!oModule) /* Eeek - some serious error! */ return; ! PyObject *dict = PyModule_GetDict(oModule); ! if (!dict) return; /* Another serious error!*/ // Register all of our interfaces, gateways and IIDs. --- 261,297 ---- /* 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) ! module = Py_InitModule("directsound", directsound_methods); ! if (!module) return; ! dict = PyModule_GetDict(module); ! if (!dict) ! return; ! #else ! ! static PyModuleDef directsound_def = { ! PyModuleDef_HEAD_INIT, ! "directsound", ! "A module encapsulating the DirectSound interfaces.", ! -1, ! directsound_methods ! }; ! module = PyModule_Create(&directsound_def); ! if (!module) ! return NULL; ! dict = PyModule_GetDict(module); ! if (!dict) ! return NULL; ! #endif // Register all of our interfaces, gateways and IIDs. *************** *** 401,404 **** --- 424,431 ---- PyDict_SetItemString(dict, "DSCBCAPSType", (PyObject *)&PyDSCBCAPSType); PyDict_SetItemString(dict, "DSCBUFFERDESCType", (PyObject *)&PyDSCBUFFERDESCType); + + #if (PY_VERSION_HEX >= 0x03000000) + return module; + #endif } Index: PyDSBCAPS.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/win32comext/directsound/src/PyDSBCAPS.cpp,v retrieving revision 1.3 retrieving revision 1.3.4.1 diff -C2 -d -r1.3 -r1.3.4.1 *** PyDSBCAPS.cpp 25 Mar 2005 01:52:11 -0000 1.3 --- PyDSBCAPS.cpp 29 Aug 2008 08:32:34 -0000 1.3.4.1 *************** *** 43,48 **** PyTypeObject PyDSBCAPSType = { ! PyObject_HEAD_INIT(&PyType_Type) ! 0, "PyDSBCAPS", sizeof(PyDSBCAPS), --- 43,47 ---- PyTypeObject PyDSBCAPSType = { ! PYWIN_OBJECT_HEAD "PyDSBCAPS", sizeof(PyDSBCAPS), Index: PyDSCBCAPS.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/win32comext/directsound/src/PyDSCBCAPS.cpp,v retrieving revision 1.2 retrieving revision 1.2.4.1 diff -C2 -d -r1.2 -r1.2.4.1 *** PyDSCBCAPS.cpp 25 Mar 2005 01:52:11 -0000 1.2 --- PyDSCBCAPS.cpp 29 Aug 2008 08:32:34 -0000 1.2.4.1 *************** *** 43,48 **** PyTypeObject PyDSCBCAPSType = { ! PyObject_HEAD_INIT(&PyType_Type) ! 0, "PyDSCBCAPSType", sizeof(PyDSCBCAPSType), --- 43,47 ---- PyTypeObject PyDSCBCAPSType = { ! PYWIN_OBJECT_HEAD "PyDSCBCAPSType", sizeof(PyDSCBCAPSType), Index: PyDSCBUFFERDESC.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/win32comext/directsound/src/PyDSCBUFFERDESC.cpp,v retrieving revision 1.2 retrieving revision 1.2.4.1 diff -C2 -d -r1.2 -r1.2.4.1 *** PyDSCBUFFERDESC.cpp 25 Mar 2005 01:52:11 -0000 1.2 --- PyDSCBUFFERDESC.cpp 29 Aug 2008 08:32:34 -0000 1.2.4.1 *************** *** 48,53 **** PyTypeObject PyDSCBUFFERDESCType = { ! PyObject_HEAD_INIT(&PyType_Type) ! 0, "PyDSCBUFFERDESC", sizeof(PyDSCBUFFERDESC), --- 48,52 ---- PyTypeObject PyDSCBUFFERDESCType = { ! PYWIN_OBJECT_HEAD "PyDSCBUFFERDESC", sizeof(PyDSCBUFFERDESC), |
From: Roger U. <ru...@us...> - 2008-08-29 08:32:12
|
Update of /cvsroot/pywin32/pywin32/com/win32comext/authorization/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11697 Modified Files: Tag: py3k authorization.cpp Log Message: Changes to build for Py3k Index: authorization.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/win32comext/authorization/src/authorization.cpp,v retrieving revision 1.2 retrieving revision 1.2.4.1 diff -C2 -d -r1.2 -r1.2.4.1 *** authorization.cpp 20 Mar 2006 03:10:57 -0000 1.2 --- authorization.cpp 29 Aug 2008 08:32:21 -0000 1.2.4.1 *************** *** 40,44 **** }; ! // @module win32com.authorization.authorization| static struct PyMethodDef authorization_methods[]= { --- 40,44 ---- }; ! // @module win32com.authorization.authorization|Module containing support for authorization COM interfaces static struct PyMethodDef authorization_methods[]= { *************** *** 47,61 **** }; ! extern "C" __declspec(dllexport) void initauthorization() { ! PyObject *module, *module_dict; module = Py_InitModule("authorization", authorization_methods); ! if(module==NULL) return; ! ! module_dict = PyModule_GetDict(module); ! if (module_dict==NULL) return; ! PyCom_RegisterExtensionSupport(module_dict, interface_info, sizeof(interface_info)/sizeof(PyCom_InterfaceSupportInfo)); } --- 47,88 ---- }; ! ! extern "C" __declspec(dllexport) ! #if (PY_VERSION_HEX < 0x03000000) ! void initauthorization(void) ! #else ! PyObject *PyInit_authorization(void) ! #endif { ! PyObject *dict, *module; ! PyWinGlobals_Ensure(); ! ! #if (PY_VERSION_HEX < 0x03000000) module = Py_InitModule("authorization", authorization_methods); ! if (!module) return; ! dict = PyModule_GetDict(module); ! if (!dict) return; ! #else ! static PyModuleDef authorization_def = { ! PyModuleDef_HEAD_INIT, ! "authorization", ! "Module containing support for authorization COM interfaces.", ! -1, ! authorization_methods ! }; ! module = PyModule_Create(&authorization_def); ! if (!module) ! return NULL; ! dict = PyModule_GetDict(module); ! if (!dict) ! return NULL; ! #endif + PyCom_RegisterExtensionSupport(dict, interface_info, sizeof(interface_info)/sizeof(PyCom_InterfaceSupportInfo)); + + #if (PY_VERSION_HEX >= 0x03000000) + return module; + #endif } |
From: Roger U. <ru...@us...> - 2008-08-29 08:27:28
|
Update of /cvsroot/pywin32/pywin32/com/win32com/src/extensions In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9945/extensions Modified Files: Tag: py3k PyFUNCDESC.cpp PyIType.cpp PySTGMEDIUM.cpp PyTYPEATTR.cpp PyVARDESC.cpp Log Message: Changes to build for Py3k Index: PyTYPEATTR.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/win32com/src/extensions/PyTYPEATTR.cpp,v retrieving revision 1.3 retrieving revision 1.3.2.1 diff -C2 -d -r1.3 -r1.3.2.1 *** PyTYPEATTR.cpp 24 May 2007 06:01:04 -0000 1.3 --- PyTYPEATTR.cpp 29 Aug 2008 08:27:37 -0000 1.3.2.1 *************** *** 29,33 **** // @object TYPEATTR|A TYPEATTR object represents a COM TYPEATTR structure. ! static struct PyMethodDef PyTYPEATTR_methods[] = { {NULL} }; --- 29,33 ---- // @object TYPEATTR|A TYPEATTR object represents a COM TYPEATTR structure. ! struct PyMethodDef PyTYPEATTR::methods[] = { {NULL} }; *************** *** 49,74 **** PyTypeObject PyTYPEATTR::Type = { ! PyObject_HEAD_INIT(&PyType_Type) ! 0, "PyTYPEATTR", sizeof(PyTYPEATTR), 0, ! PyTYPEATTR::deallocFunc, /* tp_dealloc */ ! 0, /* tp_print */ ! PyTYPEATTR::getattr, /* tp_getattr */ ! PyTYPEATTR::setattr, /* tp_setattr */ ! 0, /* tp_compare */ 0, /* tp_repr */ 0, /* tp_as_number */ &PyTYPEATTR_Sequence, /* tp_as_sequence */ 0, /* tp_as_mapping */ ! 0, 0, /* tp_call */ ! 0, /* tp_str */ }; #define OFF(e) offsetof(PyTYPEATTR, e) ! /*static*/ struct memberlist PyTYPEATTR::memberlist[] = { {"iid", T_OBJECT,OFF(iid)},// @prop <o PyIID>|iid|The IID {"lcid", T_INT, OFF(lcid)}, // @prop int|lcid|The lcid --- 49,95 ---- PyTypeObject PyTYPEATTR::Type = { ! PYWIN_OBJECT_HEAD "PyTYPEATTR", sizeof(PyTYPEATTR), 0, ! PyTYPEATTR::deallocFunc, /* tp_dealloc */ ! 0, /* tp_print */ ! 0, /* tp_getattr */ ! 0, /* tp_setattr */ ! 0, /* tp_compare */ 0, /* tp_repr */ 0, /* tp_as_number */ &PyTYPEATTR_Sequence, /* tp_as_sequence */ 0, /* tp_as_mapping */ ! 0, /* tp_hash */ 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 */ ! PyTYPEATTR::methods, /* tp_methods */ ! PyTYPEATTR::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(PyTYPEATTR, e) ! /*static*/ struct PyMemberDef PyTYPEATTR::members[] = { {"iid", T_OBJECT,OFF(iid)},// @prop <o PyIID>|iid|The IID {"lcid", T_INT, OFF(lcid)}, // @prop int|lcid|The lcid *************** *** 152,175 **** } - PyObject *PyTYPEATTR::getattr(PyObject *self, char *name) - { - PyObject *res; - - res = Py_FindMethod(PyTYPEATTR_methods, self, name); - if (res != NULL) - return res; - PyErr_Clear(); - return PyMember_Get((char *)self, memberlist, name); - } - - int PyTYPEATTR::setattr(PyObject *self, char *name, PyObject *v) - { - if (v == NULL) { - PyErr_SetString(PyExc_AttributeError, "can't delete PyTYPEATTR attributes"); - return -1; - } - return PyMember_Set((char *)self, memberlist, name, v); - } - /*static*/ void PyTYPEATTR::deallocFunc(PyObject *ob) { --- 173,176 ---- Index: PySTGMEDIUM.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/win32com/src/extensions/PySTGMEDIUM.cpp,v retrieving revision 1.8 retrieving revision 1.8.2.1 diff -C2 -d -r1.8 -r1.8.2.1 *** PySTGMEDIUM.cpp 3 Jun 2007 09:40:56 -0000 1.8 --- PySTGMEDIUM.cpp 29 Aug 2008 08:27:37 -0000 1.8.2.1 *************** *** 94,98 **** // @object PySTGMEDIUM|A STGMEDIUM object represents a COM STGMEDIUM structure. ! static struct PyMethodDef PySTGMEDIUM_methods[] = { {"set", PySet, 1}, // @pymeth set|Sets the type and data of the object {NULL} --- 94,98 ---- // @object PySTGMEDIUM|A STGMEDIUM object represents a COM STGMEDIUM structure. ! struct PyMethodDef PySTGMEDIUM::methods[] = { {"set", PySet, 1}, // @pymeth set|Sets the type and data of the object {NULL} *************** *** 101,121 **** PyTypeObject PySTGMEDIUM::Type = { ! PyObject_HEAD_INIT(&PyType_Type) ! 0, "PySTGMEDIUM", sizeof(PySTGMEDIUM), 0, PySTGMEDIUM::deallocFunc, /* tp_dealloc */ ! 0, /* tp_print */ ! PySTGMEDIUM::getattr, /* tp_getattr */ ! 0, /* tp_setattr */ ! 0, /* tp_compare */ 0, /* tp_repr */ 0, /* tp_as_number */ ! 0, /* tp_as_sequence */ 0, /* tp_as_mapping */ ! 0, 0, /* tp_call */ ! 0, /* tp_str */ }; --- 101,142 ---- PyTypeObject PySTGMEDIUM::Type = { ! PYWIN_OBJECT_HEAD "PySTGMEDIUM", sizeof(PySTGMEDIUM), 0, PySTGMEDIUM::deallocFunc, /* tp_dealloc */ ! 0, /* tp_print */ ! 0, /* tp_getattr */ ! 0, /* tp_setattr */ ! 0, /* tp_compare */ 0, /* tp_repr */ 0, /* tp_as_number */ ! 0, /* tp_as_sequence */ 0, /* tp_as_mapping */ ! 0, /* tp_hash */ 0, /* tp_call */ ! 0, /* tp_str */ ! PySTGMEDIUM::getattro, /* tp_getattro */ ! 0, /* 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 */ ! PySTGMEDIUM::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 */ }; *************** *** 205,216 **** } ! PyObject *PySTGMEDIUM::getattr(PyObject *self, char *name) { ! PyObject *res; PySTGMEDIUM *ps = (PySTGMEDIUM *)self; - res = Py_FindMethod(PySTGMEDIUM_methods, self, name); - if (res != NULL) - return res; - PyErr_Clear(); // @prop int|tymed|An integer indicating the type of data in the stgmedium if (strcmp(name, "tymed")==0) --- 226,236 ---- } ! PyObject *PySTGMEDIUM::getattro(PyObject *self, PyObject *obname) { ! char *name=PYWIN_ATTR_CONVERT(obname); ! if (name==NULL) ! return NULL; ! PySTGMEDIUM *ps = (PySTGMEDIUM *)self; // @prop int|tymed|An integer indicating the type of data in the stgmedium if (strcmp(name, "tymed")==0) *************** *** 289,293 **** } } ! return PyErr_Format(PyExc_AttributeError, "STGMEDIUM objects have no attribute '%s'", name); } --- 309,313 ---- } } ! return PyObject_GenericGetAttr(self, obname); } Index: PyIType.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/win32com/src/extensions/PyIType.cpp,v retrieving revision 1.9 retrieving revision 1.9.4.1 diff -C2 -d -r1.9 -r1.9.4.1 *** PyIType.cpp 5 Jul 2001 08:08:13 -0000 1.9 --- PyIType.cpp 29 Aug 2008 08:27:37 -0000 1.9.4.1 *************** *** 404,430 **** { // XXX - todo - merge this code with PyIDispatch::GetIDsOfNames UINT i; ! ! int argc = PyObject_Length(args); ! if ( argc == -1 ) ! return NULL; if ( argc < 1 ) { PyErr_SetString(PyExc_TypeError, "At least one argument must be supplied"); return NULL; } ! LCID lcid = LOCALE_SYSTEM_DEFAULT; UINT offset = 0; if ( argc > 1 ) { ! PyObject *ob = PySequence_GetItem(args, 0); ! if ( !ob ) ! return NULL; ! if ( PyInt_Check(ob) ) ! { ! lcid = PyInt_AS_LONG((PyIntObject *)ob); ! if ( lcid == -1 ) ! return NULL; offset = 1; - } } --- 404,427 ---- { // XXX - todo - merge this code with PyIDispatch::GetIDsOfNames + ITypeInfo *pti = PyITypeInfo::GetI(self); + if (pti==NULL) return NULL; UINT i; ! int argc = PyTuple_GET_SIZE(args); if ( argc < 1 ) { PyErr_SetString(PyExc_TypeError, "At least one argument must be supplied"); return NULL; } ! LCID lcid; UINT offset = 0; if ( argc > 1 ) { ! PyObject *ob = PyTuple_GET_ITEM(args, 0); ! lcid=PyLong_AsLong(ob); ! if (lcid==-1 && PyErr_Occurred()){ ! PyErr_Clear(); ! lcid=LOCALE_SYSTEM_DEFAULT; ! } ! else offset = 1; } *************** *** 434,445 **** for ( i = 0 ; i < cNames; ++i ) { ! PyObject *ob = PySequence_GetItem(args, i + offset); ! if ( !ob ) ! { ! for (;i>0;i--) ! PyWinObject_FreeBstr(rgszNames[i-1]); ! delete [] rgszNames; ! return NULL; ! } if (!PyWinObject_AsBstr(ob, rgszNames+i)) { for (;i>0;i--) --- 431,435 ---- for ( i = 0 ; i < cNames; ++i ) { ! PyObject *ob = PyTuple_GET_ITEM(args, i + offset); if (!PyWinObject_AsBstr(ob, rgszNames+i)) { for (;i>0;i--) *************** *** 448,466 **** return NULL; } - Py_DECREF(ob); } DISPID FAR* rgdispid = new DISPID[cNames]; - ITypeInfo *pti = PyITypeInfo::GetI(self); - if (pti==NULL) return NULL; PY_INTERFACE_PRECALL; HRESULT hr = pti->GetIDsOfNames(rgszNames, cNames, rgdispid); PY_INTERFACE_POSTCALL; delete [] rgszNames; ! if ( FAILED(hr) ) return PyCom_BuildPyException(hr, pti, IID_ITypeInfo); ! PyObject *result; --- 438,456 ---- return NULL; } } DISPID FAR* rgdispid = new DISPID[cNames]; PY_INTERFACE_PRECALL; HRESULT hr = pti->GetIDsOfNames(rgszNames, cNames, rgdispid); PY_INTERFACE_POSTCALL; + for (i=0;i<cNames;i++) + PyWinObject_FreeBstr(rgszNames[i]); delete [] rgszNames; ! if ( FAILED(hr) ){ ! delete [] rgdispid; return PyCom_BuildPyException(hr, pti, IID_ITypeInfo); ! } PyObject *result; Index: PyVARDESC.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/win32com/src/extensions/PyVARDESC.cpp,v retrieving revision 1.6 retrieving revision 1.6.2.1 diff -C2 -d -r1.6 -r1.6.2.1 *** PyVARDESC.cpp 1 Jul 2008 01:22:14 -0000 1.6 --- PyVARDESC.cpp 29 Aug 2008 08:27:37 -0000 1.6.2.1 *************** *** 25,29 **** // @object VARDESC|A VARDESC object represents a COM VARDESC structure. ! static struct PyMethodDef PyVARDESC_methods[] = { {NULL} }; --- 25,29 ---- // @object VARDESC|A VARDESC object represents a COM VARDESC structure. ! struct PyMethodDef PyVARDESC::methods[] = { {NULL} }; *************** *** 96,121 **** PyTypeObject PyVARDESC::Type = { ! PyObject_HEAD_INIT(&PyType_Type) ! 0, "PyVARDESC", sizeof(PyVARDESC), 0, PyVARDESC::deallocFunc, /* tp_dealloc */ ! 0, /* tp_print */ ! PyVARDESC::getattr, /* tp_getattr */ ! PyVARDESC::setattr, /* tp_setattr */ ! 0, /* tp_compare */ 0, /* tp_repr */ 0, /* tp_as_number */ &PyVARDESC_Sequence, /* tp_as_sequence */ 0, /* tp_as_mapping */ ! 0, 0, /* tp_call */ ! 0, /* tp_str */ }; #define OFF(e) offsetof(PyVARDESC, e) ! /*static*/ struct memberlist PyVARDESC::memberlist[] = { {"memid", T_INT, OFF(memid)}, // @prop int|memid|The dispid of the member {"value", T_OBJECT,OFF(value)}, // @prop int/object|value|A value for the variant. If PERINSTANCE then an offset into the instance, otherwise a variant converted to a Python object. --- 96,142 ---- PyTypeObject PyVARDESC::Type = { ! PYWIN_OBJECT_HEAD "PyVARDESC", sizeof(PyVARDESC), 0, PyVARDESC::deallocFunc, /* tp_dealloc */ ! 0, /* tp_print */ ! 0, /* tp_getattr */ ! 0, /* tp_setattr */ ! 0, /* tp_compare */ 0, /* tp_repr */ 0, /* tp_as_number */ &PyVARDESC_Sequence, /* tp_as_sequence */ 0, /* tp_as_mapping */ ! 0, /* tp_hash */ 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 */ ! PyVARDESC::methods, /* tp_methods */ ! PyVARDESC::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(PyVARDESC, e) ! /*static*/ struct PyMemberDef PyVARDESC::members[] = { {"memid", T_INT, OFF(memid)}, // @prop int|memid|The dispid of the member {"value", T_OBJECT,OFF(value)}, // @prop int/object|value|A value for the variant. If PERINSTANCE then an offset into the instance, otherwise a variant converted to a Python object. *************** *** 196,219 **** } - PyObject *PyVARDESC::getattr(PyObject *self, char *name) - { - PyObject *res; - - res = Py_FindMethod(PyVARDESC_methods, self, name); - if (res != NULL) - return res; - PyErr_Clear(); - return PyMember_Get((char *)self, memberlist, name); - } - - int PyVARDESC::setattr(PyObject *self, char *name, PyObject *v) - { - if (v == NULL) { - PyErr_SetString(PyExc_AttributeError, "can't delete PyVARDESC attributes"); - return -1; - } - return PyMember_Set((char *)self, memberlist, name, v); - } - /*static*/ void PyVARDESC::deallocFunc(PyObject *ob) { --- 217,220 ---- Index: PyFUNCDESC.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/win32com/src/extensions/PyFUNCDESC.cpp,v retrieving revision 1.2 retrieving revision 1.2.2.1 diff -C2 -d -r1.2 -r1.2.2.1 *** PyFUNCDESC.cpp 24 May 2007 06:01:04 -0000 1.2 --- PyFUNCDESC.cpp 29 Aug 2008 08:27:37 -0000 1.2.2.1 *************** *** 100,104 **** // The object itself. ! static struct PyMethodDef PyFUNCDESC_methods[] = { {NULL} }; --- 100,104 ---- // The object itself. ! struct PyMethodDef PyFUNCDESC::methods[] = { {NULL} }; *************** *** 122,147 **** PyTypeObject PyFUNCDESC::Type = { ! PyObject_HEAD_INIT(&PyType_Type) ! 0, "PyFUNCDESC", sizeof(PyFUNCDESC), 0, PyFUNCDESC::deallocFunc, /* tp_dealloc */ ! 0, /* tp_print */ ! PyFUNCDESC::getattr, /* tp_getattr */ ! PyFUNCDESC::setattr, /* tp_setattr */ ! 0, /* tp_compare */ 0, /* tp_repr */ 0, /* tp_as_number */ &PyFUNCDESC_Sequence, /* tp_as_sequence */ 0, /* tp_as_mapping */ ! 0, 0, /* tp_call */ ! 0, /* tp_str */ }; #define OFF(e) offsetof(PyFUNCDESC, e) ! /*static*/ struct memberlist PyFUNCDESC::memberlist[] = { {"memid", T_INT, OFF(memid)}, // @prop integer|memid| {"scodeArray", T_OBJECT,OFF(scodeArray)}, // @prop (int, ...)|scodeArray| --- 122,168 ---- PyTypeObject PyFUNCDESC::Type = { ! PYWIN_OBJECT_HEAD "PyFUNCDESC", sizeof(PyFUNCDESC), 0, PyFUNCDESC::deallocFunc, /* tp_dealloc */ ! 0, /* tp_print */ ! 0, /* tp_getattr */ ! 0, /* tp_setattr */ ! 0, /* tp_compare */ 0, /* tp_repr */ 0, /* tp_as_number */ &PyFUNCDESC_Sequence, /* tp_as_sequence */ 0, /* tp_as_mapping */ ! 0, /* tp_hash */ 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 */ ! PyFUNCDESC::methods, /* tp_methods */ ! PyFUNCDESC::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(PyFUNCDESC, e) ! /*static*/ struct PyMemberDef PyFUNCDESC::members[] = { {"memid", T_INT, OFF(memid)}, // @prop integer|memid| {"scodeArray", T_OBJECT,OFF(scodeArray)}, // @prop (int, ...)|scodeArray| *************** *** 194,217 **** } - PyObject *PyFUNCDESC::getattr(PyObject *self, char *name) - { - PyObject *res; - - res = Py_FindMethod(PyFUNCDESC_methods, self, name); - if (res != NULL) - return res; - PyErr_Clear(); - return PyMember_Get((char *)self, memberlist, name); - } - - int PyFUNCDESC::setattr(PyObject *self, char *name, PyObject *v) - { - if (v == NULL) { - PyErr_SetString(PyExc_AttributeError, "can't delete PyFUNCDESC attributes"); - return -1; - } - return PyMember_Set((char *)self, memberlist, name, v); - } - /*static*/ void PyFUNCDESC::deallocFunc(PyObject *ob) { --- 215,218 ---- |
From: Roger U. <ru...@us...> - 2008-08-29 08:27:28
|
Update of /cvsroot/pywin32/pywin32/com/win32com/src/include In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9945/include Modified Files: Tag: py3k PyComTypeObjects.h PythonCOM.h Log Message: Changes to build for Py3k Index: PyComTypeObjects.h =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/win32com/src/include/PyComTypeObjects.h,v retrieving revision 1.5 retrieving revision 1.5.2.1 diff -C2 -d -r1.5 -r1.5.2.1 *** PyComTypeObjects.h 24 May 2007 06:01:04 -0000 1.5 --- PyComTypeObjects.h 29 Aug 2008 08:27:38 -0000 1.5.2.1 *************** *** 32,45 **** static void deallocFunc(PyObject *ob); - static PyObject *getitem(PyObject *self, Py_ssize_t index); static Py_ssize_t getlength(PyObject *self); - static PyObject *getattr(PyObject *self, char *name); - static int setattr(PyObject *self, char *name, PyObject *v); ! #pragma warning( disable : 4251 ) ! static struct memberlist memberlist[]; static PyTypeObject Type; - #pragma warning( default : 4251 ) int memid; --- 32,41 ---- static void deallocFunc(PyObject *ob); static PyObject *getitem(PyObject *self, Py_ssize_t index); static Py_ssize_t getlength(PyObject *self); ! static struct PyMemberDef members[]; ! static struct PyMethodDef methods[]; static PyTypeObject Type; int memid; *************** *** 66,76 **** static PyObject *getitem(PyObject *self, Py_ssize_t index); static Py_ssize_t getlength(PyObject *self); - static PyObject *getattr(PyObject *self, char *name); - static int setattr(PyObject *self, char *name, PyObject *v); ! #pragma warning( disable : 4251 ) ! static struct memberlist memberlist[]; static PyTypeObject Type; - #pragma warning( default : 4251 ) protected: --- 62,69 ---- static PyObject *getitem(PyObject *self, Py_ssize_t index); static Py_ssize_t getlength(PyObject *self); ! static struct PyMemberDef members[]; ! static struct PyMethodDef methods[]; static PyTypeObject Type; protected: *************** *** 105,115 **** static PyObject *getitem(PyObject *self, Py_ssize_t index); static Py_ssize_t getlength(PyObject *self); ! static PyObject *getattr(PyObject *self, char *name); ! static int setattr(PyObject *self, char *name, PyObject *v); ! ! #pragma warning( disable : 4251 ) ! static struct memberlist memberlist[]; static PyTypeObject Type; - #pragma warning( default : 4251 ) int memid; --- 98,104 ---- static PyObject *getitem(PyObject *self, Py_ssize_t index); static Py_ssize_t getlength(PyObject *self); ! static struct PyMemberDef members[]; ! static struct PyMethodDef methods[]; static PyTypeObject Type; int memid; *************** *** 130,139 **** BOOL CopyTo(STGMEDIUM *pDest); static void deallocFunc(PyObject *ob); ! static PyObject *getattr(PyObject *self, char *name); STGMEDIUM medium; ! #pragma warning( disable : 4251 ) ! static struct memberlist memberlist[]; static PyTypeObject Type; - #pragma warning( default : 4251 ) }; --- 119,126 ---- BOOL CopyTo(STGMEDIUM *pDest); static void deallocFunc(PyObject *ob); ! static PyObject *getattro(PyObject *self, PyObject *obname); STGMEDIUM medium; ! static struct PyMethodDef methods[]; static PyTypeObject Type; }; Index: PythonCOM.h =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/win32com/src/include/PythonCOM.h,v retrieving revision 1.27 retrieving revision 1.27.2.1 diff -C2 -d -r1.27 -r1.27.2.1 *** PythonCOM.h 8 Apr 2008 11:51:26 -0000 1.27 --- PythonCOM.h 29 Aug 2008 08:27:38 -0000 1.27.2.1 *************** *** 158,166 **** // is the given object an interface type object? (e.g. PyIUnknown) ! static BOOL is_interface_type(const PyObject *ob); public: - PyMethodChain chain; - PyComTypeObject *baseType; PyIUnknown * (* ctor)(IUnknown *); }; --- 158,164 ---- // is the given object an interface type object? (e.g. PyIUnknown) ! static BOOL is_interface_type(PyObject *ob); public: PyIUnknown * (* ctor)(IUnknown *); }; *************** *** 210,214 **** virtual PyObject *iter() {return NULL;} virtual PyObject *iternext() {return NULL;} - static struct PyMethodDef PyIBase::empty_methods[]; protected: PyIBase(); --- 208,211 ---- *************** *** 216,225 **** public: ! static BOOL is_object( const PyObject *, PyComTypeObject *which); BOOL is_object(PyComTypeObject *which); static void dealloc(PyObject *ob); static PyObject *repr(PyObject *ob); static PyObject *getattro(PyObject *self, PyObject *name); ! static int setattr(PyObject *op, char *name, PyObject *v); static int cmp(PyObject *ob1, PyObject *ob2); }; --- 213,222 ---- public: ! static BOOL is_object(PyObject *, PyComTypeObject *which); BOOL is_object(PyComTypeObject *which); static void dealloc(PyObject *ob); static PyObject *repr(PyObject *ob); static PyObject *getattro(PyObject *self, PyObject *name); ! static int setattro(PyObject *op, PyObject *obname, PyObject *v); static int cmp(PyObject *ob1, PyObject *ob2); }; |
Update of /cvsroot/pywin32/pywin32/com/win32com/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9945 Modified Files: Tag: py3k ErrorUtils.cpp MiscTypes.cpp PyComHelpers.cpp PyGatewayBase.cpp PyIBase.cpp PyIDispatch.cpp PyIUnknown.cpp PyRecord.cpp PythonCOM.cpp Register.cpp dllmain.cpp oleargs.cpp univgw.cpp univgw_dataconv.cpp Log Message: Changes to build for Py3k Index: PyGatewayBase.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/win32com/src/PyGatewayBase.cpp,v retrieving revision 1.17 retrieving revision 1.17.2.1 diff -C2 -d -r1.17 -r1.17.2.1 *** PyGatewayBase.cpp 4 Sep 2007 10:53:29 -0000 1.17 --- PyGatewayBase.cpp 29 Aug 2008 08:27:37 -0000 1.17.2.1 *************** *** 18,22 **** #include <malloc.h> ! #if _MSC_VER < 1400 // _malloca is the new 'safe' one #define _malloca _alloca --- 18,25 ---- #include <malloc.h> ! // When building with the 2003 Platform SDK 64-bit compiloer, _MSC_VER is 1400, ! // but _malloca is not defined ! // #if _MSC_VER < 1400 ! #ifndef _malloca // _malloca is the new 'safe' one #define _malloca _alloca Index: PyIUnknown.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/win32com/src/PyIUnknown.cpp,v retrieving revision 1.12 retrieving revision 1.12.2.1 diff -C2 -d -r1.12 -r1.12.2.1 *** PyIUnknown.cpp 4 Jul 2007 18:03:18 -0000 1.12 --- PyIUnknown.cpp 29 Aug 2008 08:27:37 -0000 1.12.2.1 *************** *** 182,186 **** { PyObject *obiid; ! PyObject *obUseIID = NULL; // @pyparm IID|iid||The IID requested. // @pyparm IID|useIID|None|If provided and not None, will return an --- 182,186 ---- { PyObject *obiid; ! PyObject *obUseIID = Py_None; // @pyparm IID|iid||The IID requested. // @pyparm IID|useIID|None|If provided and not None, will return an *************** *** 210,227 **** IID useIID; /* used if obUseIID != NULL */ ! if ( obUseIID != NULL ) ! { ! if ( obUseIID == Py_None ) ! obUseIID = NULL; ! else if ( PyInt_Check(obUseIID) ) ! { ! if ( PyInt_AS_LONG((PyIntObject *)obUseIID) ) ! useIID = IID_IUnknown; ! else ! obUseIID = NULL; ! } ! else if ( !PyWinObject_AsIID(obUseIID, &useIID) ) return NULL; - } IUnknown *pMyUnknown = GetI(self); --- 210,218 ---- IID useIID; /* used if obUseIID != NULL */ ! // This used to allow an int, with 1 indicating IUnknown ! // Doesn't seem to be used anywhere, so it has been removed ! if (obUseIID != Py_None) ! if ( !PyWinObject_AsIID(obUseIID, &useIID) ) return NULL; IUnknown *pMyUnknown = GetI(self); *************** *** 244,248 **** /* we may have been asked to use a different interface */ ! if ( rc == NULL && obUseIID != NULL ) { PyErr_Clear(); --- 235,240 ---- /* we may have been asked to use a different interface */ ! /* ??? useIID will be ignored if interface successfully created ??? */ ! if ( rc == NULL && obUseIID != Py_None) { PyErr_Clear(); Index: dllmain.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/win32com/src/dllmain.cpp,v retrieving revision 1.15 retrieving revision 1.15.4.1 diff -C2 -d -r1.15 -r1.15.4.1 *** dllmain.cpp 23 Mar 2006 06:59:20 -0000 1.15 --- dllmain.cpp 29 Aug 2008 08:27:37 -0000 1.15.4.1 *************** *** 312,317 **** { // A scope for _celp CEnterLeavePython _celp; ! PySys_SetArgv(argc, argv); if (PyRun_SimpleFile(fp, (char *)fileName) != 0) { --- 312,320 ---- { // A scope for _celp CEnterLeavePython _celp; ! #if (PY_VERSION_HEX < 0x03000000) PySys_SetArgv(argc, argv); + #else + PySys_SetArgv(argc, __wargv); + #endif; if (PyRun_SimpleFile(fp, (char *)fileName) != 0) { Index: univgw.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/win32com/src/univgw.cpp,v retrieving revision 1.11 retrieving revision 1.11.4.1 diff -C2 -d -r1.11 -r1.11.4.1 *** univgw.cpp 25 Jan 2005 13:33:15 -0000 1.11 --- univgw.cpp 29 Aug 2008 08:27:37 -0000 1.11.4.1 *************** *** 688,692 **** // HRESULT hr; ! PyObject *module = Py_InitModule("pythoncom.__univgw", univgw_functions); if (!module) /* Eeek - some serious error! */ return FALSE; --- 688,705 ---- // HRESULT hr; ! PyObject *module; ! ! #if (PY_VERSION_HEX < 0x03000000) ! module = Py_InitModule("pythoncom.__univgw", univgw_functions); ! #else ! static PyModuleDef univgw_def = { ! PyModuleDef_HEAD_INIT, ! "pythoncom.__univgw", ! "Univeral gateway", ! -1, ! univgw_functions ! }; ! module = PyModule_Create(&univgw_def); ! #endif if (!module) /* Eeek - some serious error! */ return FALSE; Index: Register.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/win32com/src/Register.cpp,v retrieving revision 1.18 retrieving revision 1.18.2.1 diff -C2 -d -r1.18 -r1.18.2.1 *** Register.cpp 22 Jan 2008 12:11:59 -0000 1.18 --- Register.cpp 29 Aug 2008 08:27:37 -0000 1.18.2.1 *************** *** 131,134 **** --- 131,154 ---- } + /* PyType_Ready assures that the type's tp_base is ready, but it does *not* call + itself for entries in tp_bases, leading to a crash or indecipherable errors + if one of multiple bases is not itself ready. + http://bugs.python.org:80/issue3453 + This code is also in win32uimodule.cpp, should move into pywintypes. + */ + int PyWinType_Ready(PyTypeObject *pT) + { + if (pT->tp_flags & Py_TPFLAGS_READY) + return 0; + if (pT->tp_bases){ + for (Py_ssize_t b=0; b<PyTuple_GET_SIZE(pT->tp_bases); b++){ + PyTypeObject *base_type = (PyTypeObject *)PyTuple_GET_ITEM(pT->tp_bases, b); + if (PyWinType_Ready(base_type) == -1) + return -1; + } + } + return PyType_Ready(pT); + } + int PyCom_RegisterSupportedInterfaces( const PyCom_InterfaceSupportInfo *pInterfaces, int numEntries) { *************** *** 136,139 **** --- 156,162 ---- int i; for ( i = numEntries; i--; ) { + if (pInterfaces[i].pTypeOb) + if (PyWinType_Ready(pInterfaces[i].pTypeOb) == -1) + return -1; if ( pInterfaces[i].pTypeOb && PyCom_RegisterClientType(pInterfaces[i].pTypeOb, pInterfaces[i].pGUID) != 0 ) return -1; Index: MiscTypes.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/win32com/src/MiscTypes.cpp,v retrieving revision 1.8 retrieving revision 1.8.4.1 diff -C2 -d -r1.8 -r1.8.4.1 *** MiscTypes.cpp 14 Mar 2006 12:12:44 -0000 1.8 --- MiscTypes.cpp 29 Aug 2008 08:27:37 -0000 1.8.4.1 *************** *** 10,15 **** // ### an object). static PyTypeObject PyInterfaceType_Type = { ! PyObject_HEAD_INIT(&PyType_Type) ! 0, /* Number of items for varobject */ "interface-type", /* Name of this type */ sizeof(PyTypeObject), /* Basic object size */ --- 10,14 ---- // ### an object). static PyTypeObject PyInterfaceType_Type = { ! PYWIN_OBJECT_HEAD "interface-type", /* Name of this type */ sizeof(PyTypeObject), /* Basic object size */ *************** *** 37,49 **** { // originally, this copied the typeobject of the parent, but as it is impossible ! // to gurantee order of static object construction, I went this way. This is // probably better, as is forces _all_ python objects have the same type sig. static const PyTypeObject type_template = { ! #ifdef OLD_PYTHON_TYPES ! PyObject_HEAD_INIT(&PyInterfaceType_Type) ! #else ! PyObject_HEAD_INIT(&PyType_Type) ! #endif ! 0, /*ob_size*/ "PythonComTypeTemplate", /*tp_name*/ sizeof(PyIBase), /*tp_basicsize*/ --- 36,43 ---- { // originally, this copied the typeobject of the parent, but as it is impossible ! // to guarantee order of static object construction, I went this way. This is // probably better, as is forces _all_ python objects have the same type sig. static const PyTypeObject type_template = { ! PYWIN_OBJECT_HEAD "PythonComTypeTemplate", /*tp_name*/ sizeof(PyIBase), /*tp_basicsize*/ *************** *** 52,57 **** (destructor) PyIBase::dealloc, /*tp_dealloc*/ 0, /*tp_print*/ ! 0, /*tp_getattr*/ ! (setattrfunc) PyIBase::setattr, /*tp_setattr*/ PyIBase::cmp, /*tp_compare*/ (reprfunc)PyIBase::repr, /*tp_repr*/ --- 46,51 ---- (destructor) PyIBase::dealloc, /*tp_dealloc*/ 0, /*tp_print*/ ! 0, /*tp_getattr*/ ! 0, /*tp_setattr*/ PyIBase::cmp, /*tp_compare*/ (reprfunc)PyIBase::repr, /*tp_repr*/ *************** *** 62,69 **** 0, /*tp_call*/ 0, /*tp_str*/ ! PyIBase::getattro, /* tp_getattro */ ! 0, /*tp_setattro */ 0, /* tp_as_buffer */ ! 0, /* tp_flags */ 0, /* tp_doc */ 0, /* tp_traverse */ --- 56,63 ---- 0, /*tp_call*/ 0, /*tp_str*/ ! PyIBase::getattro, /* tp_getattro */ ! PyIBase::setattro, /*tp_setattro */ 0, /* tp_as_buffer */ ! Py_TPFLAGS_DEFAULT, /* tp_flags */ 0, /* tp_doc */ 0, /* tp_traverse */ *************** *** 76,92 **** 0, /* tp_members */ 0, /* tp_getset */ ! #ifdef OLD_PYTHON_TYPES ! 0, /* tp_base */ ! #else ! &PyInterfaceType_Type, ! #endif }; *((PyTypeObject *)this) = type_template; - - chain.methods = methodList; - chain.link = pBase ? &pBase->chain : NULL; - - baseType = pBase; ctor = thector; --- 70,77 ---- 0, /* tp_members */ 0, /* tp_getset */ ! 0, // &PyInterfaceType_Type, /* tp_base */ }; *((PyTypeObject *)this) = type_template; ctor = thector; *************** *** 94,110 **** tp_name = (char *)name; tp_basicsize = typeSize; } PyComTypeObject::~PyComTypeObject() { } ! /* static */ BOOL PyComTypeObject::is_interface_type(const PyObject *ob) { ! #ifdef OLD_PYTHON_TYPES ! return ob->ob_type == &PyInterfaceType_Type; ! #else ! return ob->ob_type == &PyType_Type && ! ((PyTypeObject *)ob)->tp_base == &PyInterfaceType_Type; ! #endif } --- 79,100 ---- tp_name = (char *)name; tp_basicsize = typeSize; + ((PyObject *)this)->ob_type=&PyType_Type; + tp_methods=methodList; + + // All interfaces are based on PyInterfaceType, so this type will inherit from it thru pBase + // tp_bases=Py_BuildValue("OO", &PyInterfaceType_Type, pBase); + if (pBase) + tp_base=pBase; + else + tp_base=&PyInterfaceType_Type; } + PyComTypeObject::~PyComTypeObject() { } ! /* static */ BOOL PyComTypeObject::is_interface_type(PyObject *ob) { ! return PyObject_IsSubclass(ob, (PyObject *)&PyInterfaceType_Type); } *************** *** 115,119 **** --- 105,112 ---- tp_iter = iter; tp_iternext = iternext; + // Py3k does not have this flag, and depends just on presence of tp_iter + #if (PY_VERSION_HEX < 0x03000000) tp_flags |= Py_TPFLAGS_HAVE_ITER; + #endif } *************** *** 167,171 **** --- 160,166 ---- tp_iter = iter; // tp_iternext remains NULL + #if (PY_VERSION_HEX < 0x03000000) tp_flags |= Py_TPFLAGS_HAVE_ITER; + #endif } *************** *** 216,221 **** PyTypeObject PyOleEmptyType = { ! PyObject_HEAD_INIT(&PyType_Type) ! 0, "PyOleEmpty", sizeof(PyOleEmpty), --- 211,215 ---- PyTypeObject PyOleEmptyType = { ! PYWIN_OBJECT_HEAD "PyOleEmpty", sizeof(PyOleEmpty), *************** *** 247,252 **** PYCOM_EXPORT PyTypeObject PyOleMissingType = { ! PyObject_HEAD_INIT(&PyType_Type) ! 0, "PyOleMissing", sizeof(PyOleMissing), --- 241,245 ---- PYCOM_EXPORT PyTypeObject PyOleMissingType = { ! PYWIN_OBJECT_HEAD "PyOleMissing", sizeof(PyOleMissing), *************** *** 277,282 **** PyTypeObject PyOleArgNotFoundType = { ! PyObject_HEAD_INIT(&PyType_Type) ! 0, "ArgNotFound", sizeof(PyOleArgNotFound), --- 270,274 ---- PyTypeObject PyOleArgNotFoundType = { ! PYWIN_OBJECT_HEAD "ArgNotFound", sizeof(PyOleArgNotFound), Index: PyIDispatch.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/win32com/src/PyIDispatch.cpp,v retrieving revision 1.11 retrieving revision 1.11.4.1 diff -C2 -d -r1.11 -r1.11.4.1 *** PyIDispatch.cpp 13 Feb 2006 01:17:01 -0000 1.11 --- PyIDispatch.cpp 29 Aug 2008 08:27:37 -0000 1.11.4.1 *************** *** 56,79 **** // @pyparmalt1 [string, ...]|[name, ...]||A sequence of string names to query // @comm Currently the LCID can not be specified, and LOCALE_SYSTEM_DEFAULT is used. ! int argc = PyObject_Length(args); ! if ( argc == -1 ) ! return NULL; if ( argc < 1 ) return PyErr_Format(PyExc_TypeError, "At least one argument must be supplied"); ! LCID lcid = LOCALE_SYSTEM_DEFAULT; UINT offset = 0; ! if ( argc > 1 ) ! { ! PyObject *ob = PySequence_GetItem(args, 0); ! if ( !ob ) ! return NULL; ! if ( PyInt_Check(ob) ) ! { ! lcid = PyInt_AS_LONG((PyIntObject *)ob); offset = 1; } - Py_DECREF(ob); - } UINT cNames = argc - offset; --- 56,75 ---- // @pyparmalt1 [string, ...]|[name, ...]||A sequence of string names to query // @comm Currently the LCID can not be specified, and LOCALE_SYSTEM_DEFAULT is used. ! int argc = PyTuple_GET_SIZE(args); if ( argc < 1 ) return PyErr_Format(PyExc_TypeError, "At least one argument must be supplied"); ! LCID lcid; UINT offset = 0; ! if ( argc > 1 ){ ! PyObject *ob = PyTuple_GET_ITEM(args, 0); ! lcid=PyLong_AsLong(ob); ! if (lcid==-1 && PyErr_Occurred()){ ! PyErr_Clear(); ! lcid=LOCALE_SYSTEM_DEFAULT; ! } ! else offset = 1; } UINT cNames = argc - offset; Index: oleargs.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/win32com/src/oleargs.cpp,v retrieving revision 1.41 retrieving revision 1.41.2.1 diff -C2 -d -r1.41 -r1.41.2.1 *** oleargs.cpp 8 Apr 2008 11:51:26 -0000 1.41 --- oleargs.cpp 29 Aug 2008 08:27:37 -0000 1.41.2.1 *************** *** 116,120 **** V_I4(var) = PyInt_AsLong(obj); } ! else if (PyInstance_Check(obj) && PyObject_HasAttrString(obj, "_oleobj_")) { if (PyCom_InterfaceFromPyInstanceOrObject(obj, IID_IDispatch, (void **)&V_DISPATCH(var), FALSE)) --- 116,122 ---- V_I4(var) = PyInt_AsLong(obj); } ! // PyInstance_Check had disappeared in py3k ! // else if (PyInstance_Check(obj) && PyObject_HasAttrString(obj, "_oleobj_")) ! else if (PyObject_HasAttrString(obj, "_oleobj_")) { if (PyCom_InterfaceFromPyInstanceOrObject(obj, IID_IDispatch, (void **)&V_DISPATCH(var), FALSE)) *************** *** 165,169 **** PyWinObject_AsDATE(obj, &(V_DATE(var))); } ! else if (PyBuffer_Check(obj)) { // We have a buffer object - convert to safe array of VT_UI1 if (!PyCom_SAFEARRAYFromPyObject(obj, &V_ARRAY(var), VT_UI1)) --- 167,173 ---- PyWinObject_AsDATE(obj, &(V_DATE(var))); } ! // PyBuffer_Check has gone away in py3k ! // else if (PyBuffer_Check(obj)) { ! else if (obj->ob_type->tp_as_buffer) { // We have a buffer object - convert to safe array of VT_UI1 if (!PyCom_SAFEARRAYFromPyObject(obj, &V_ARRAY(var), VT_UI1)) *************** *** 193,206 **** V_VT(var) = VT_CY; } ! /* ! else if (obj->ob_type == &AutomatedType) ! { ! } ! */ if (V_VT(var) == VT_EMPTY && !bGoodEmpty) { // Must ensure we have a Python error set if we fail! if (!PyErr_Occurred()) { char *extraMessage = ""; ! if (obj->ob_type->tp_as_buffer && obj->ob_type->tp_as_buffer->bf_getreadbuffer) extraMessage = " (but obtaining the buffer() of this object could)"; PyErr_Format(PyExc_TypeError, "Objects of type '%s' can not be converted to a COM VARIANT%s", obj->ob_type->tp_name, extraMessage); --- 197,206 ---- V_VT(var) = VT_CY; } ! if (V_VT(var) == VT_EMPTY && !bGoodEmpty) { // Must ensure we have a Python error set if we fail! if (!PyErr_Occurred()) { char *extraMessage = ""; ! if (obj->ob_type->tp_as_buffer) extraMessage = " (but obtaining the buffer() of this object could)"; PyErr_Format(PyExc_TypeError, "Objects of type '%s' can not be converted to a COM VARIANT%s", obj->ob_type->tp_name, extraMessage); *************** *** 274,278 **** // The result may be too large for a simple "long". If so, // we must return a long. ! if (V_UI4(&varValue) <= (unsigned)PyInt_GetMax()) result = PyInt_FromLong(V_UI4(&varValue)); else --- 274,278 ---- // The result may be too large for a simple "long". If so, // we must return a long. ! if (V_UI4(&varValue) <= INT_MAX) result = PyInt_FromLong(V_UI4(&varValue)); else *************** *** 399,426 **** // (only support single segment buffers for now) if (dimNo==nDims && vt==VT_UI1 && obj->ob_type->tp_as_buffer) { ! PyBufferProcs *pb = obj->ob_type->tp_as_buffer; ! Py_ssize_t bufSize; ! if (pb->bf_getreadbuffer && ! pb->bf_getsegcount && ! (*pb->bf_getsegcount)(obj, &bufSize)==1) ! { ! if (PyWin_SAFE_DOWNCAST(bufSize, Py_ssize_t, LONG) != numElements) { ! OleSetTypeError("Internal error - the buffer length is not the sequence length!"); ! return FALSE; } ! void *ob_buf, *sa_buf; ! HRESULT hr = SafeArrayAccessData(pSA,&sa_buf); ! if (FAILED(hr)) { ! PyCom_BuildPyException(hr); ! return FALSE; } ! pb->bf_getreadbuffer(obj, 0, &ob_buf); ! memcpy(sa_buf, ob_buf, bufSize); ! SafeArrayUnaccessData(pSA); ! // All done without a single loop :-) ! return TRUE; } // Otherwise just fall through into the standard mechanisms ! } BOOL ok = TRUE; for (int index=0;index<(int)numElements && ok;index++) { --- 399,424 ---- // (only support single segment buffers for now) if (dimNo==nDims && vt==VT_UI1 && obj->ob_type->tp_as_buffer) { ! DWORD bufSize; ! void *ob_buf, *sa_buf; ! if (!PyWinObject_AsReadBuffer(obj, &ob_buf, &bufSize)) ! return FALSE; ! ! if (bufSize != numElements) { ! OleSetTypeError("Internal error - the buffer length is not the sequence length!"); ! return FALSE; } ! ! HRESULT hr = SafeArrayAccessData(pSA,&sa_buf); ! if (FAILED(hr)) { ! PyCom_BuildPyException(hr); ! return FALSE; } ! memcpy(sa_buf, ob_buf, bufSize); ! SafeArrayUnaccessData(pSA); ! // All done without a single loop :-) ! return TRUE; } // Otherwise just fall through into the standard mechanisms ! BOOL ok = TRUE; for (int index=0;index<(int)numElements && ok;index++) { *************** *** 499,503 **** Py_ssize_t lObjectSize; ! if (PyBuffer_Check(obItemCheck)) // buffers are a special case - they define 1 new dimension. return lReturnDimension+1; --- 497,501 ---- Py_ssize_t lObjectSize; ! if (obItemCheck->ob_type->tp_as_buffer) // buffers are a special case - they define 1 new dimension. return lReturnDimension+1; *************** *** 841,854 **** if (ret!=NULL) { // Access the buffer object using the buffer interfaces. ! PyBufferProcs *pb = ret->ob_type->tp_as_buffer; ! if (!pb->bf_getwritebuffer || ! !pb->bf_getsegcount || ! (*pb->bf_getsegcount)(ret, NULL)!=1) { ! PyErr_SetString(PyExc_RuntimeError, "New buffer has no buffer interfaces!!"); SafeArrayUnaccessData(psa); Py_DECREF(ret); return NULL; } - long count = pb->bf_getwritebuffer(ret, 0, &ob_buf); if (count != cElems) { PyErr_SetString(PyExc_RuntimeError, "buffer size is not what we created!"); --- 839,848 ---- if (ret!=NULL) { // Access the buffer object using the buffer interfaces. ! DWORD count; ! if (!PyWinObject_AsWriteBuffer(ret, &ob_buf, &count)){ SafeArrayUnaccessData(psa); Py_DECREF(ret); return NULL; } if (count != cElems) { PyErr_SetString(PyExc_RuntimeError, "buffer size is not what we created!"); Index: univgw_dataconv.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/win32com/src/univgw_dataconv.cpp,v retrieving revision 1.10 retrieving revision 1.10.4.1 diff -C2 -d -r1.10 -r1.10.4.1 *** univgw_dataconv.cpp 13 Feb 2006 01:23:48 -0000 1.10 --- univgw_dataconv.cpp 29 Aug 2008 08:27:37 -0000 1.10.4.1 *************** *** 191,197 **** BYTE *pbArgs; BYTE *pbArg; ! UINT cArgs; UINT uiIndirectionLevel = 0; ! UINT i; if (!PyArg_ParseTuple(args, "OOO:WriteFromOutTuple", &obRetValues, &obArgTypes, &obPtr)) --- 191,197 ---- BYTE *pbArgs; BYTE *pbArg; ! Py_ssize_t cArgs; UINT uiIndirectionLevel = 0; ! Py_ssize_t i; if (!PyArg_ParseTuple(args, "OOO:WriteFromOutTuple", &obRetValues, &obArgTypes, &obPtr)) *************** *** 461,474 **** BYTE *pb = *(BYTE **)pbArg; BYTE *pbOutBuffer = NULL; ! UINT cb = 0; ! if (PyBuffer_Check(obOutValue)) { ! cb = obOutValue->ob_type->tp_as_buffer->bf_getreadbuffer(obOutValue, 0, (void **)&pbOutBuffer); memcpy(pb, pbOutBuffer, cb); } ! else if (PyString_Check(obOutValue)) { ! pbOutBuffer = (BYTE *)PyString_AS_STRING(obOutValue); ! cb = PyString_GET_SIZE(obOutValue); memcpy(pb, pbOutBuffer, cb); } --- 461,476 ---- BYTE *pb = *(BYTE **)pbArg; BYTE *pbOutBuffer = NULL; ! if (PyString_Check(obOutValue)) { ! pbOutBuffer = (BYTE *)PyString_AS_STRING(obOutValue); ! Py_ssize_t cb = PyString_GET_SIZE(obOutValue); memcpy(pb, pbOutBuffer, cb); } ! // keep this after string check since string can act as buffers ! else if (obOutValue->ob_type->tp_as_buffer) { ! DWORD cb; ! if (!PyWinObject_AsReadBuffer(obOutValue, (void **)&pbOutBuffer, &cb)) ! goto Error; memcpy(pb, pbOutBuffer, cb); } *************** *** 615,619 **** BYTE *pb; BYTE *pbArg; ! UINT cArgs, i; PyObject *obArgs = NULL; PyObject *obArg; --- 617,621 ---- BYTE *pb; BYTE *pbArg; ! Py_ssize_t cArgs, i; PyObject *obArgs = NULL; PyObject *obArg; Index: PyIBase.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/win32com/src/PyIBase.cpp,v retrieving revision 1.7 retrieving revision 1.7.4.1 diff -C2 -d -r1.7 -r1.7.4.1 *** PyIBase.cpp 2 Nov 2003 09:55:27 -0000 1.7 --- PyIBase.cpp 29 Aug 2008 08:27:37 -0000 1.7.4.1 *************** *** 10,28 **** } ! /*static*/BOOL PyIBase::is_object(const PyObject *ob, PyComTypeObject *which) { ! // First, is the object an instance of an interface type? ! if ( !PyComTypeObject::is_interface_type((PyObject *)ob->ob_type) ) ! return FALSE; ! ! // now check for inheritance. ! PyComTypeObject *thisType = (PyComTypeObject *)ob->ob_type; ! while (thisType) { ! if (which==thisType) ! return TRUE; ! thisType = thisType->baseType; ! } ! return FALSE; } BOOL PyIBase::is_object(PyComTypeObject *which) { --- 10,18 ---- } ! /*static*/BOOL PyIBase::is_object(PyObject *ob, PyComTypeObject *which) { ! return PyObject_IsInstance(ob, (PyObject *)which); } + BOOL PyIBase::is_object(PyComTypeObject *which) { *************** *** 33,36 **** --- 23,27 ---- PyIBase::getattro(PyObject *self, PyObject *name) { + /* if (PyString_Check(name)) { PyObject *rc = ((PyIBase *)self)->getattr(PyString_AsString(name)); *************** *** 39,50 **** PyErr_Clear(); } // Using PyObject_GenericGetAttr allows some special type magic // (ie, - #ifdef OLD_PYTHON_TYPES - PyErr_SetObject(PyExc_AttributeError, name); - return NULL; - #else return PyObject_GenericGetAttr(self, name); - #endif } --- 30,37 ---- PyErr_Clear(); } + */ // Using PyObject_GenericGetAttr allows some special type magic // (ie, return PyObject_GenericGetAttr(self, name); } *************** *** 52,63 **** PyIBase::getattr(char *name) { ! return Py_FindMethodInChain(&((PyComTypeObject *)ob_type)->chain, this, name); } ! /*static*/int PyIBase::setattr(PyObject *op, char *name, PyObject *v) { PyIBase* bc = (PyIBase *)op; return bc->setattr(name,v); } int PyIBase::setattr(char *name, PyObject *v) { --- 39,54 ---- PyIBase::getattr(char *name) { ! return PyObject_GetAttrString(this, name); } ! /*static*/int PyIBase::setattro(PyObject *op,PyObject *obname, PyObject *v) { + char *name=PYWIN_ATTR_CONVERT(obname); + if (name==NULL) + return -1; PyIBase* bc = (PyIBase *)op; return bc->setattr(name,v); } + int PyIBase::setattr(char *name, PyObject *v) { *************** *** 77,81 **** TCHAR buf[80]; wsprintf(buf, _T("<%hs at %p>"),ob_type->tp_name, (PyObject *)this); ! return PyString_FromTCHAR(buf); } --- 68,72 ---- TCHAR buf[80]; wsprintf(buf, _T("<%hs at %p>"),ob_type->tp_name, (PyObject *)this); ! return PyWinObject_FromTCHAR(buf); } Index: PythonCOM.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/win32com/src/PythonCOM.cpp,v retrieving revision 1.52 retrieving revision 1.52.2.1 diff -C2 -d -r1.52 -r1.52.2.1 *** PythonCOM.cpp 27 Jul 2008 13:01:17 -0000 1.52 --- PythonCOM.cpp 29 Aug 2008 08:27:37 -0000 1.52.2.1 *************** *** 15,23 **** #include "PythonCOMServer.h" #include "PyFactory.h" #include "OleAcc.h" // for ObjectFromLresult proto... - // keep a reference to pythoncom'm __dict__ so the COM currency format can be looked up dynamically - extern PyObject *pythoncom_dict=NULL; - extern int PyCom_RegisterCoreIIDs(PyObject *dict); --- 15,21 ---- #include "PythonCOMServer.h" #include "PyFactory.h" + #include "PyComTypeObjects.h" #include "OleAcc.h" // for ObjectFromLresult proto... extern int PyCom_RegisterCoreIIDs(PyObject *dict); *************** *** 1975,1982 **** /* Module initialisation */ ! extern "C" __declspec(dllexport) void initpythoncom() { - PyObject *oModule; - // The DLL Load inited the module. // All we do here is init COM itself. Done here --- 1973,1983 ---- /* Module initialisation */ ! extern "C" __declspec(dllexport) ! #if (PY_VERSION_HEX < 0x03000000) ! void initpythoncom() ! #else ! PyObject *PyInit_pythoncom(void) ! #endif { // The DLL Load inited the module. // All we do here is init COM itself. Done here *************** *** 2000,2016 **** // manually CoInit() to see! // ensure the framework has valid state to work with. PyWinGlobals_Ensure(); PyCom_RegisterCoreSupport(); - // Create the module and add the functions - oModule = Py_InitModule(modName, pythoncom_methods); - if (!oModule) /* Eeek - some serious error! */ - return; - - PyObject *dict = PyModule_GetDict(oModule); - if (!dict) return; /* Another serious error!*/ - pythoncom_dict=dict; - PyDict_SetItemString(dict, "TypeIIDs", g_obPyCom_MapIIDToType); PyDict_SetItemString(dict, "ServerInterfaces", g_obPyCom_MapGatewayIIDToName); --- 2001,2034 ---- // manually CoInit() to see! + PyObject *dict, *module; + #if (PY_VERSION_HEX < 0x03000000) + #define RETURN_ERROR return; + module = Py_InitModule("pythoncom", pythoncom_methods); + if (!module) + return; + dict = PyModule_GetDict(module); + if (!dict) + return; + #else + #define RETURN_ERROR return NULL; + static PyModuleDef pythoncom_def = { + PyModuleDef_HEAD_INIT, + "pythoncom", + "A module, encapsulating the OLE automation API", + -1, + pythoncom_methods + }; + module = PyModule_Create(&pythoncom_def); + if (!module) + return NULL; + dict = PyModule_GetDict(module); + if (!dict) + return NULL; + #endif + // ensure the framework has valid state to work with. PyWinGlobals_Ensure(); PyCom_RegisterCoreSupport(); PyDict_SetItemString(dict, "TypeIIDs", g_obPyCom_MapIIDToType); PyDict_SetItemString(dict, "ServerInterfaces", g_obPyCom_MapGatewayIIDToName); *************** *** 2028,2069 **** // Add some symbolic constants to the module // pycom_Error = PyString_FromString("pythoncom.error"); ! PyObject *pycom_Error = PyWinExc_COMError; ! if (pycom_Error == NULL || PyDict_SetItemString(dict, "error", pycom_Error) != 0) ! { ! PyErr_SetString(PyExc_MemoryError, "can't define error"); ! return; ! } ! if (PyWinExc_COMError==NULL || PyDict_SetItemString(dict, "ole_error", PyWinExc_COMError) != 0) { PyErr_SetString(PyExc_MemoryError, "can't define ole_error"); ! return; } // Add the same constant, but with a "new name" if (PyDict_SetItemString(dict, "com_error", PyWinExc_COMError) != 0) ! { ! PyErr_SetString(PyExc_MemoryError, "can't define com_error"); ! return; ! } PyCom_InternalError = PyErr_NewException("pythoncom.internal_error", NULL, NULL); if (PyDict_SetItemString(dict, "internal_error", PyCom_InternalError) != 0) ! { ! PyErr_SetString(PyExc_MemoryError, "can't define internal_error"); ! return; ! } // Add the IIDs if (PyCom_RegisterCoreIIDs(dict) != 0) ! return; // Setup our sub-modules if (!initunivgw(dict)) ! return; ! ! // Add a few types. ! // NOTE - We do not autoduck these types, as they are for b/w compat only ! // New code should use the functions in pywintypes. ! PyDict_SetItemString(dict, "PyTimeType", (PyObject *)&PyTimeType); ! PyDict_SetItemString(dict, "PyIIDType", (PyObject *)&PyIIDType); ! PyDict_SetItemString(dict, "PyUnicodeType", (PyObject *)&PyUnicodeType); // Load function pointers. --- 2046,2083 ---- // Add some symbolic constants to the module // pycom_Error = PyString_FromString("pythoncom.error"); ! if (PyWinExc_COMError==NULL) { + // This is created by PyWin_Globals_Ensure PyErr_SetString(PyExc_MemoryError, "can't define ole_error"); ! RETURN_ERROR; } + PyObject *pycom_Error = PyWinExc_COMError; + if (PyDict_SetItemString(dict, "ole_error", PyWinExc_COMError) != 0) + RETURN_ERROR; + if (PyDict_SetItemString(dict, "error", pycom_Error) != 0) + RETURN_ERROR; + // Add the same constant, but with a "new name" if (PyDict_SetItemString(dict, "com_error", PyWinExc_COMError) != 0) ! RETURN_ERROR; ! PyCom_InternalError = PyErr_NewException("pythoncom.internal_error", NULL, NULL); if (PyDict_SetItemString(dict, "internal_error", PyCom_InternalError) != 0) ! RETURN_ERROR; // Add the IIDs if (PyCom_RegisterCoreIIDs(dict) != 0) ! RETURN_ERROR; ! ! // Initialize various non-interface types ! if (PyType_Ready(&PyFUNCDESC::Type) == -1 || ! PyType_Ready(&PySTGMEDIUM::Type) == -1 || ! PyType_Ready(&PyTYPEATTR::Type) == -1 || ! PyType_Ready(&PyVARDESC::Type) == -1) ! RETURN_ERROR; // Setup our sub-modules if (!initunivgw(dict)) ! RETURN_ERROR; // Load function pointers. *************** *** 2416,2419 **** --- 2430,2437 ---- // @property int|pythoncom|frozen|1 if the host is a frozen program, else 0 // @property int|pythoncom|dcom|1 if the system is DCOM aware, else 0. Only Win95 without DCOM extensions should return 0 + + #if (PY_VERSION_HEX >= 0x03000000) + return module; + #endif; } Index: ErrorUtils.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/win32com/src/ErrorUtils.cpp,v retrieving revision 1.30 retrieving revision 1.30.2.1 diff -C2 -d -r1.30 -r1.30.2.1 *** ErrorUtils.cpp 4 Sep 2007 10:32:03 -0000 1.30 --- ErrorUtils.cpp 29 Aug 2008 08:27:37 -0000 1.30.2.1 *************** *** 60,64 **** if (szException==NULL) szException = "<bad exception>"; if (szValue==NULL) szValue = "<bad exception value>"; ! int len = strlen(szBaseMessage) + strlen(szException) + 2 + strlen(szValue) + 1; // 2 for ": " // message could be quite long - be safe. --- 60,64 ---- if (szException==NULL) szException = "<bad exception>"; if (szValue==NULL) szValue = "<bad exception value>"; ! size_t len = strlen(szBaseMessage) + strlen(szException) + 2 + strlen(szValue) + 1; // 2 for ": " // message could be quite long - be safe. *************** *** 199,204 **** // so we need to check the class explicitely. if (v==PyWinExc_COMError || // String exceptions ! (PyInstance_Check(v) && // Class exceptions ! (PyObject *)(((PyInstanceObject *)v)->in_class)==PyWinExc_COMError) ) { // Client side error // Clear the state of the excep info. --- 199,204 ---- // so we need to check the class explicitely. if (v==PyWinExc_COMError || // String exceptions ! (PyObject_IsInstance(v, PyExc_Exception) && // Class exceptions ! ((PyObject *)v->ob_type==PyWinExc_COMError))) { // Client side error // Clear the state of the excep info. *************** *** 486,491 **** // Protected by Python lock static TCHAR buff[8196]; ! int buf_len = sizeof(buff) / sizeof(buff[0]); ! int prefix_len = strlen(prefix); assert(prefix_len<100); strcpy(buff, prefix); --- 486,491 ---- // Protected by Python lock static TCHAR buff[8196]; ! size_t buf_len = sizeof(buff) / sizeof(buff[0]); ! size_t prefix_len = strlen(prefix); assert(prefix_len<100); strcpy(buff, prefix); *************** *** 632,637 **** PyErr_NormalizeException( &exc_typ, &exc_val, &exc_tb); rc = (!PyErr_GivenExceptionMatches(exc_val, PyWinExc_COMError) || ! ((PyInstance_Check(exc_val) && ! (PyObject *)(((PyInstanceObject *)exc_val)->in_class)==PyWinExc_COMError))); } PyErr_Restore(exc_typ, exc_val, exc_tb); --- 632,637 ---- PyErr_NormalizeException( &exc_typ, &exc_val, &exc_tb); rc = (!PyErr_GivenExceptionMatches(exc_val, PyWinExc_COMError) || ! (PyObject_IsInstance(exc_val, PyExc_Exception) && ! PyObject_IsSubclass((PyObject *)exc_val->ob_type, PyWinExc_COMError))); } PyErr_Restore(exc_typ, exc_val, exc_tb); Index: PyRecord.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/win32com/src/PyRecord.cpp,v retrieving revision 1.11 retrieving revision 1.11.4.1 diff -C2 -d -r1.11 -r1.11.4.1 *** PyRecord.cpp 11 Jul 2006 13:27:48 -0000 1.11 --- PyRecord.cpp 29 Aug 2008 08:27:37 -0000 1.11.4.1 *************** *** 10,16 **** return SafeArrayGetRecordInfo(psa, prinfo); } ! HRESULT PyGetRecordInfoFromGuids( REFGUID g, ULONG maj, ULONG min, LCID lcid, REFGUID gti, IRecordInfo **ppr) { ! return GetRecordInfoFromGuids( g, maj, min, lcid, gti, ppr); } #else --- 10,16 ---- return SafeArrayGetRecordInfo(psa, prinfo); } ! HRESULT PyGetRecordInfoFromGuids( REFGUID g, ULONG major, ULONG minor, LCID lcid, REFGUID gti, IRecordInfo **ppr) { ! return GetRecordInfoFromGuids( g, major, minor, lcid, gti, ppr); } #else *************** *** 34,38 **** return (*pfnSAGRI)(psa, prinfo); } ! HRESULT PyGetRecordInfoFromGuids( REFGUID g, ULONG maj, ULONG min, LCID lcid, REFGUID gti, IRecordInfo **ppr) { static HRESULT (STDAPICALLTYPE *pfnGRIFG)(REFGUID, ULONG, ULONG, LCID, REFGUID, IRecordInfo **) = NULL; --- 34,38 ---- return (*pfnSAGRI)(psa, prinfo); } ! HRESULT PyGetRecordInfoFromGuids( REFGUID g, ULONG major, ULONG minor, LCID lcid, REFGUID gti, IRecordInfo **ppr) { static HRESULT (STDAPICALLTYPE *pfnGRIFG)(REFGUID, ULONG, ULONG, LCID, REFGUID, IRecordInfo **) = NULL; *************** *** 46,50 **** return E_NOTIMPL; } ! return (*pfnGRIFG)(g, maj, min, lcid, gti, ppr); } #endif // LINK_AGAINST_RECORDINFO --- 46,50 ---- return E_NOTIMPL; } ! return (*pfnGRIFG)(g, major, minor, lcid, gti, ppr); } #endif // LINK_AGAINST_RECORDINFO *************** *** 95,102 **** static void tp_dealloc(PyObject *ob); ! static PyObject *tp_getattr(PyObject *self, char *name); ! static int tp_setattr(PyObject *self, char *name, PyObject *v); static PyObject *tp_repr(PyObject *self); static int tp_compare(PyObject *self, PyObject *other); static PyTypeObject Type; --- 95,103 ---- static void tp_dealloc(PyObject *ob); ! static PyObject *getattro(PyObject *self, PyObject *obname); ! static int setattro(PyObject *self, PyObject *obname, PyObject *v); static PyObject *tp_repr(PyObject *self); static int tp_compare(PyObject *self, PyObject *other); + static struct PyMethodDef methods[]; static PyTypeObject Type; *************** *** 210,224 **** PyObject *pythoncom_GetRecordFromGuids(PyObject *self, PyObject *args) { ! char *data = NULL; ! PyObject *obGuid, *obInfoGuid; ! int maj, min, lcid; int cb = 0; ! if (!PyArg_ParseTuple(args, "OiiiO|z#:GetRecordFromGuids", &obGuid, // @pyparm <o PyIID>|iid||The GUID of the type library ! &maj, // @pyparm int|verMajor||The major version number of the type lib. ! &min, // @pyparm int|verMinor||The minor version number of the type lib. &lcid, // @pyparm int|lcid||The LCID of the type lib. &obInfoGuid, // @pyparm <o PyIID>|infoIID||The GUID of the record info in the library ! &data, &cb)) // @pyparm string|data|None|The raw data to initialize the record with. return NULL; GUID guid, infoGuid; --- 211,227 ---- PyObject *pythoncom_GetRecordFromGuids(PyObject *self, PyObject *args) { ! void *data = NULL; ! PyObject *obGuid, *obInfoGuid, *obdata=Py_None; ! int major, minor, lcid; int cb = 0; ! if (!PyArg_ParseTuple(args, "OiiiO|O:GetRecordFromGuids", &obGuid, // @pyparm <o PyIID>|iid||The GUID of the type library ! &major, // @pyparm int|verMajor||The major version number of the type lib. ! &minor, // @pyparm int|verMinor||The minor version number of the type lib. &lcid, // @pyparm int|lcid||The LCID of the type lib. &obInfoGuid, // @pyparm <o PyIID>|infoIID||The GUID of the record info in the library ! &obdata)) // @pyparm string or buffer|data|None|The raw data to initialize the record with. ! return NULL; ! if (!PyWinObject_AsReadBuffer(obdata, &data, &cb, TRUE)) return NULL; GUID guid, infoGuid; *************** *** 228,232 **** return NULL; IRecordInfo *i = NULL; ! HRESULT hr = PyGetRecordInfoFromGuids(guid, maj, min, lcid, infoGuid, &i); if (FAILED(hr)) return PyCom_BuildPyException(hr); --- 231,235 ---- return NULL; IRecordInfo *i = NULL; ! HRESULT hr = PyGetRecordInfoFromGuids(guid, major, minor, lcid, infoGuid, &i); if (FAILED(hr)) return PyCom_BuildPyException(hr); *************** *** 281,301 **** PyTypeObject PyRecord::Type = { ! PyObject_HEAD_INIT(&PyType_Type) ! 0, "com_record", sizeof(PyRecord), 0, ! PyRecord::tp_dealloc, /* tp_dealloc */ ! 0, /* tp_print */ ! PyRecord::tp_getattr, /* tp_getattr */ ! PyRecord::tp_setattr, /* tp_setattr */ ! PyRecord::tp_compare, /* tp_compare */ ! &PyRecord::tp_repr, /* tp_repr */ 0, /* tp_as_number */ 0, /* tp_as_sequence */ 0, /* tp_as_mapping */ ! 0, 0, /* tp_call */ ! 0, /* tp_str */ }; --- 284,325 ---- PyTypeObject PyRecord::Type = { ! PYWIN_OBJECT_HEAD "com_record", sizeof(PyRecord), 0, ! PyRecord::tp_dealloc, /* tp_dealloc */ ! 0, /* tp_print */ ! 0, /* tp_getattr */ ! 0, /* tp_setattr */ ! PyRecord::tp_compare, /* tp_compare */ ! &PyRecord::tp_repr, /* tp_repr */ 0, /* tp_as_number */ 0, /* tp_as_sequence */ 0, /* tp_as_mapping */ ! 0, /* tp_hash */ 0, /* tp_call */ ! 0, /* tp_str */ ! PyRecord::getattro, /* tp_getattro */ ! PyRecord::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 */ ! PyRecord::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 */ }; *************** *** 342,357 **** goto done; } ! { // scope for locals avoiding goto ! PyObject *obtlbguid = PyWinObject_FromIID(pta->guid); ! PyObject *obstructguid = PyWinObject_FromIID(structguid); ! ret = Py_BuildValue("O(NiiiNs#)", obFunc, ! obtlbguid, pta->wMajorVerNum, pta->wMinorVerNum, pta->lcid, ! obstructguid, ! pyrec->pdata, cb); ! } // end scope done: if (pta&& pti) --- 366,378 ---- goto done; } ! ret = Py_BuildValue("O(NHHiNN)", obFunc, ! PyWinObject_FromIID(pta->guid), pta->wMajorVerNum, pta->wMinorVerNum, pta->lcid, ! PyWinObject_FromIID(structguid), ! PyString_FromStringAndSize((char *)pyrec->pdata, cb)); ! done: if (pta&& pti) *************** *** 362,369 **** return ret; } // The object itself. // Any method names should be "__blah__", as they override // structure names! ! static struct PyMethodDef PyRecord_methods[] = { {"__reduce__", PyRecord_reduce, 1}, // This allows the copy module to work! {NULL} --- 383,391 ---- return ret; } + // The object itself. // Any method names should be "__blah__", as they override // structure names! ! struct PyMethodDef PyRecord::methods[] = { {"__reduce__", PyRecord_reduce, 1}, // This allows the copy module to work! {NULL} *************** *** 400,441 **** delete[] strings; } PyObject *PyRecord::tp_repr(PyObject *self) { ULONG i; PyRecord *pyrec = (PyRecord *)self; - ULONG num_names; - PyObject *s = PyString_FromString("com_struct{"); - BSTR *strings = _GetFieldNames(pyrec->pri, &num_names); ! if (strings==NULL) return NULL; ! PyObject *comma = PyString_FromString(", "); ! PyObject *equals = PyString_FromString(" = "); ! for (i = 0; i < num_names && s != NULL; i++) { ! char *name; ! if (PyWin_WCHAR_AsString(strings[i], (DWORD)-1, &name)) { ! if (i > 0) ! PyString_Concat(&s, comma); ! PyString_ConcatAndDel(&s, PyString_FromString(name)); ! PyString_Concat(&s, equals); ! PyObject *sub_object = PyRecord::tp_getattr(self, name); ! PyString_ConcatAndDel(&s, PyObject_Repr(sub_object)); ! Py_XDECREF(sub_object); ! PyWinObject_FreeString(name); } ! } ! Py_XDECREF(comma); ! Py_XDECREF(equals); ! PyString_ConcatAndDel(&s, PyString_FromString("}")); ! _FreeFieldNames(strings, num_names); ! return s; } ! PyObject *PyRecord::tp_getattr(PyObject *self, char *name) { PyObject *res; PyRecord *pyrec = (PyRecord *)self; ! if (strcmp(name, "__members__")==0) { ULONG cnames = 0; --- 422,528 ---- delete[] strings; } + PyObject *PyRecord::tp_repr(PyObject *self) { ULONG i; PyRecord *pyrec = (PyRecord *)self; ULONG num_names; BSTR *strings = _GetFieldNames(pyrec->pri, &num_names); ! if (strings==NULL) ! return NULL; ! PyObject *obrepr=NULL, *obattrname; ! BOOL bsuccess=FALSE; ! #if (PY_VERSION_HEX < 0x03000000) ! static PyObject *comma = PyString_FromString(", "); ! static PyObject *equals = PyString_FromString(" = "); ! obrepr = PyString_FromString("com_struct{"); ! if (obrepr==NULL || comma==NULL || equals==NULL) ! goto done; ! for (i = 0; i < num_names && obrepr != NULL; i++) { ! obattrname=PyString_FromUnicode(strings[i]); ! if (obattrname==NULL) ! goto done; // missing some cleanup here ! if (i > 0){ ! PyString_Concat(&obrepr, comma); ! if (!obrepr) ! goto done; ! } ! PyString_ConcatAndDel(&obrepr, obattrname); ! if (!obrepr) ! goto done; ! PyString_Concat(&obrepr, equals); ! if (!obrepr) ! goto done; ! PyObject *sub_object = PyRecord::getattro(self, obattrname); ! if (!sub_object) ! goto done; ! PyString_ConcatAndDel(&obrepr, PyObject_Repr(sub_object)); } ! PyString_ConcatAndDel(&obrepr, PyString_FromString("}")); ! ! #else ! // Create unicode repr in py3k ! static PyObject *comma = PyWinObject_FromWCHAR(L", "); ! static PyObject *equals = PyWinObject_FromWCHAR(L" = "); ! static PyObject *closing_paren=PyWinObject_FromWCHAR(L")"); ! obrepr = PyWinObject_FromWCHAR(L"com_struct{"); ! PyObject *tmp=NULL; ! for (i = 0; i < num_names && obrepr != NULL; i++) { ! obattrname=PyWinObject_FromWCHAR(strings[i]); ! if (obattrname==NULL) ! goto done; ! if (i > 0){ ! tmp=PyUnicode_Concat(obrepr, comma); ! if (!tmp) ! goto done; ! Py_DECREF(obrepr); ! obrepr=tmp; ! } ! tmp=PyUnicode_Concat(obrepr, obattrname); ! if (!tmp) ! goto done; ! Py_DECREF(obrepr); ! obrepr=tmp; ! Py_DECREF(obattrname); ! tmp=PyUnicode_Concat(obrepr, equals); ! if (!tmp) ! goto done; ! Py_DECREF(obrepr); ! obrepr=tmp; ! PyObject *sub_object = PyRecord::getattro(self, obattrname); ! if (!sub_object) ! goto done; ! tmp=PyUnicode_Concat(obrepr, PyObject_Repr(sub_object)); ! if (!tmp) ! goto done; ! Py_DECREF(obrepr); ! obrepr=tmp; ! Py_DECREF(sub_object); // ??? still missing a DECREF for subobject's repr ??? ! } ! tmp=PyUnicode_Concat(obrepr, closing_paren); ! if (!tmp) ! goto done; ! Py_DECREF(obrepr); ! obrepr=tmp; ! #endif ! bsuccess=TRUE; ! done: ! if (strings) ! _FreeFieldNames(strings, num_names); ! if (!bsuccess){ ! Py_XDECREF(obrepr); ! obrepr=NULL; ! } ! return obrepr; } ! PyObject *PyRecord::getattro(PyObject *self, PyObject *obname) { PyObject *res; PyRecord *pyrec = (PyRecord *)self; ! char *name=PYWIN_ATTR_CONVERT(obname); ! if (name==NULL) ! return NULL; if (strcmp(name, "__members__")==0) { ULONG cnames = 0; *************** *** 451,473 **** return PyCom_BuildPyException(hr, pyrec->pri, g_IID_IRecordInfo); } ! PyObject *ret = PyList_New(cnames); ! for (ULONG i=0;i<cnames && ret != NULL;i++) { PyObject *item = PyString_FromUnicode(strs[i]); SysFreeString(strs[i]); if (item==NULL) { ! Py_DECREF(ret); ! ret = NULL; } else ! PyList_SET_ITEM(ret, i, item); // ref count swallowed. } free(strs); ! return ret; } ! res = Py_FindMethod(PyRecord_methods, self, name); if (res != NULL) return res; PyErr_Clear(); WCHAR *wname; ! if (!PyWin_String_AsWCHAR(name, (DWORD)-1, &wname)) return NULL; --- 538,562 ---- return PyCom_BuildPyException(hr, pyrec->pri, g_IID_IRecordInfo); } ! res = PyList_New(cnames); ! for (ULONG i=0;i<cnames && res != NULL;i++) { PyObject *item = PyString_FromUnicode(strs[i]); SysFreeString(strs[i]); if (item==NULL) { ! Py_DECREF(res); ! res = NULL; } else ! PyList_SET_ITEM(res, i, item); // ref count swallowed. } free(strs); ! return res; } ! ! res = PyObject_GenericGetAttr(self, obname); if (res != NULL) return res; + PyErr_Clear(); WCHAR *wname; ! if (!PyWinObject_AsWCHAR(obname, &wname)) return NULL; *************** *** 479,490 **** HRESULT hr = pyrec->pri->GetFieldNoCopy(pyrec->pdata, wname, &vret, &sub_data); PY_INTERFACE_POSTCALL; ! PyWinObject_FreeString(wname); if (FAILED(hr)) { ! if (hr == TYPE_E_FIELDNOTFOUND) ! return PyErr_Format(PyExc_AttributeError, ! "This record has no field named '%s'", name); return PyCom_BuildPyException(hr, pyrec->pri, g_IID_IRecordInfo); } // Short-circuit sub-structs and arrays here, so we dont allocate a new chunk // of memory and copy it - we need sub-structs to persist. --- 568,584 ---- HRESULT hr = pyrec->pri->GetFieldNoCopy(pyrec->pdata, wname, &vret, &sub_data); PY_INTERFACE_POSTCALL; ! if (FAILED(hr)) { ! if (hr == TYPE_E_FIELDNOTFOUND){ ! PyErr_Format(PyExc_AttributeError, ! "This record has no field named '%s'", wname); ! PyWinObject_FreeWCHAR(wname); ! return NULL; ! } ! PyWinObject_FreeWCHAR(wname); return PyCom_BuildPyException(hr, pyrec->pri, g_IID_IRecordInfo); } + PyWinObject_FreeWCHAR(wname); // Short-circuit sub-structs and arrays here, so we dont allocate a new chunk // of memory and copy it - we need sub-structs to persist. *************** *** 535,539 **** } ! int PyRecord::tp_setattr(PyObject *self, char *name, PyObject *v) { VARIANT val; --- 629,633 ---- } ! int PyRecord::setattro(PyObject *self, PyObject *obname, PyObject *v) { VARIANT val; *************** *** 544,548 **** WCHAR *wname; ! if (!PyWin_String_AsWCHAR(name, (DWORD)-1, &wname)) return -1; --- 638,642 ---- WCHAR *wname; ! if (!PyWinObject_AsWCHAR(obname, &wname, FALSE)) return -1; *************** *** 550,554 **** HRESULT hr = pyrec->pri->PutField(INVOKE_PROPERTYPUT, pyrec->pdata, wname, &val); PY_INTERFACE_POSTCALL; ! PyWinObject_FreeString(wname); VariantClear(&val); if (FAILED(hr)) { --- 644,648 ---- HRESULT hr = pyrec->pri->PutField(INVOKE_PROPERTYPUT, pyrec->pdata, wname, &val); PY_INTERFACE_POSTCALL; ! PyWinObject_FreeWCHAR(wname); VariantClear(&val); if (FAILED(hr)) { *************** *** 576,592 **** for (ULONG i=0;i<num_names;i++) { ret = 0; ! char *name; ! if (PyWin_WCHAR_AsString(strings[i], (DWORD)-1, &name)) { ! PyObject *self_sub = PyRecord::tp_getattr(self, name); ! if (self_sub) { ! PyObject *other_sub = PyRecord::tp_getattr(other, name); ! if (other_sub) { ! ret = PyObject_Compare(self_sub, other_sub); ! Py_DECREF(other_sub); } } ! Py_XDECREF(self_sub); ! PyWinObject_FreeString(name); ! } if (ret != 0) break; --- 670,701 ---- for (ULONG i=0;i<num_names;i++) { ret = 0; ! PyObject *obattrname; ! #if (PY_VERSION_HEX < 0x03000000) ! obattrname=PyString_FromUnicode(strings[i]); ! #else ! // Py3k passes attr names as unicode ! obattrname=PyWinObject_FromWCHAR(strings[i]); ! #endif ! if (obattrname==NULL) ! return -2; ! // There appear to be several problems here. This will leave an exception hanging ! // if an attribute is not found, and should probably return False if other does not ! // have an attr that self does ??? ! PyObject *self_sub = PyRecord::getattro(self, obattrname); ! if (self_sub) { ! PyObject *other_sub = PyRecord::getattro(other, obattrname); ! if (other_sub){ ! ret = PyObject_Compare(self_sub, other_sub); ! Py_DECREF(other_sub); } + else{ + PyErr_Clear(); + ret=1; + } + Py_DECREF(self_sub); } ! else ! PyErr_Clear(); ! Py_DECREF(obattrname); if (ret != 0) break; Index: PyComHelpers.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/win32com/src/PyComHelpers.cpp,v retrieving revision 1.15 retrieving revision 1.15.2.1 diff -C2 -d -r1.15 -r1.15.2.1 *** PyComHelpers.cpp 22 Jan 2008 12:09:34 -0000 1.15 --- PyComHelpers.cpp 29 Aug 2008 08:27:37 -0000 1.15.2.1 *************** *** 11,15 **** extern PyObject *g_obPyCom_MapIIDToType; extern PyObject *g_obPyCom_MapServerIIDToGateway; - extern PyObject *pythoncom_dict; // String conversions --- 11,14 ---- *************** *** 45,96 **** PyObject *PyObject_FromCurrency(CURRENCY &cy) { - static BOOL decimal_imported=FALSE; static PyObject *decimal_module=NULL; - static BOOL warned_future_currency=FALSE; PyObject *result = NULL; - - // Use decimal module if available and __future_currency__ evaluates to True, otherwise use old behaviour - PyObject *__future_currency__; - BOOL use_decimal; - __future_currency__=PyDict_GetItemString(pythoncom_dict,"__future_currency__"); - if (__future_currency__==NULL){ // should not happen ! - PyErr_Print(); - use_decimal=FALSE; - } - else - use_decimal=PyObject_IsTrue(__future_currency__); - if (!use_decimal && !warned_future_currency) { - #if (PY_VERSION_HEX >= 0x02030000) - PyErr_Warn(PyExc_FutureWarning, - "Currency objects will soon be changed so a decimal.Decimal instance is used." - "\n (set pythoncom.__future_currency__ to get these objects now.)"); - #endif - warned_future_currency = TRUE; - } ! if (use_decimal && !decimal_imported){ decimal_module=PyImport_ImportModule("decimal"); if (!decimal_module) { PyErr_Clear(); decimal_module=PyImport_ImportModule("win32com.decimal_23"); } ! decimal_imported=TRUE; ! if (decimal_module==NULL) ! PyErr_Print(); ! } ! if (use_decimal && (decimal_module==NULL)){ ! PyErr_Warn(NULL,"Can't find decimal module, reverting to using tuple for currency"); ! use_decimal=FALSE; ! } ! if (!use_decimal) ! result = Py_BuildValue("ll", cy.Hi, cy.Lo); ! else { ! PyObject *unscaled_result; ! unscaled_result=PyObject_CallMethod(decimal_module, "Decimal", "L", cy.int64); ! if (unscaled_result!=NULL){ ! result=PyObject_CallMethod(unscaled_result, "__div__", "l", 10000); ! Py_DECREF(unscaled_result); } - } return result; } --- 44,66 ---- PyObject *PyObject_FromCurrency(CURRENCY &cy) { static PyObject *decimal_module=NULL; PyObject *result = NULL; ! if (decimal_module==NULL){ decimal_module=PyImport_ImportModule("decimal"); if (!decimal_module) { PyErr_Clear(); decimal_module=PyImport_ImportModule("win32com.decimal_23"); + } } ! if (decimal_module==NULL) ! return NULL; ! ! PyObject *unscaled_result; ! unscaled_result=PyObject_CallMethod(decimal_module, "Decimal", "L", cy.int64); ! if (unscaled_result!=NULL){ ! result=PyObject_CallMethod(unscaled_result, "__div__", "l", 10000); ! Py_DECREF(unscaled_result); } return result; } *************** *** 186,202 **** BOOL PyCom_InterfaceFromPyInstanceOrObject(PyObject *ob, REFIID iid, LPVOID *ppv, BOOL bNoneOK /* = TRUE */) { ! if (ob && PyInstance_Check(ob)) { ! // Get the _oleobj_ attribute ! ob = PyObject_GetAttrString(ob, "_oleobj_"); ! if (ob==NULL) { ! PyErr_Clear(); ! PyErr_SetString(PyExc_TypeError, "The Python instance can not be converted to a COM object"); ! return FALSE; } - } else { - Py_XINCREF(ob); - } BOOL rc = PyCom_InterfaceFromPyObject(ob, iid, ppv, bNoneOK ); ! Py_XDECREF(ob); return rc; } --- 156,178 ---- BOOL PyCom_InterfaceFromPyInstanceOrObject(PyObject *ob, REFIID iid, LPVOID *ppv, BOOL bNoneOK /* = TRUE */) { ! if (ob == Py_None){ ! *ppv = NULL; ! if (bNoneOK) ! return TRUE; ! PyErr_SetString(PyExc_TypeError, "None is not a valid interface object in this context"); ! return FALSE; ! } ! ! if (PyObject_IsInstance(ob, (PyObject *)&PyIUnknown::type)) ! return PyCom_InterfaceFromPyObject(ob, iid, ppv, bNoneOK ); ! ! ob = PyObject_GetAttrString(ob, "_oleobj_"); ! if (ob==NULL) { ! PyErr_Clear(); ! PyErr_SetString(PyExc_TypeError, "The Python instance can not be converted to a COM object"); ! return FALSE; } BOOL rc = PyCom_InterfaceFromPyObject(ob, iid, ppv, bNoneOK ); ! Py_DECREF(ob); return rc; } |
From: Roger U. <ru...@us...> - 2008-08-29 07:44:45
|
Update of /cvsroot/pywin32/pywin32/win32/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24253 Modified Files: Tag: py3k PyHANDLE.cpp Log Message: Return unicode for PyHANDLE's repr Index: PyHANDLE.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/src/PyHANDLE.cpp,v retrieving revision 1.16.2.1 retrieving revision 1.16.2.2 diff -C2 -d -r1.16.2.1 -r1.16.2.2 *** PyHANDLE.cpp 29 Aug 2008 04:59:25 -0000 1.16.2.1 --- PyHANDLE.cpp 29 Aug 2008 07:44:54 -0000 1.16.2.2 *************** *** 343,349 **** PyObject * PyHANDLE::asStr(void) { ! TCHAR resBuf[160]; ! wsprintf(resBuf, _T("<%s:%Id>"), GetTypeName(), m_handle); ! return PyString_FromTCHAR(resBuf); } --- 343,353 ---- PyObject * PyHANDLE::asStr(void) { ! char resBuf[160]; ! snprintf(resBuf, 160, "<%s:%Id>", GetTypeName(), m_handle); ! #if (PY_VERSION_HEX < 0x03000000) ! return PyString_FromString(resBuf); ! #else ! return PyUnicode_FromString(resBuf); ! #endif } |